use of com.ctrip.framework.dal.cluster.client.database.DatabaseCategory in project dal by ctripcorp.
the class DefaultClusterTest method getDatabaseCategoryTest.
@Test
public void getDatabaseCategoryTest() {
final DatabaseCategory databaseCategory = cluster.getDatabaseCategory();
Assert.assertEquals(MYSQL, databaseCategory);
}
use of com.ctrip.framework.dal.cluster.client.database.DatabaseCategory in project dal by ctripcorp.
the class ClusterConfigXMLParser method parseCluster.
private ClusterConfig parseCluster(Node clusterNode, DalConfigCustomizedOption customizedOption) throws IOException {
String name = getAttribute(clusterNode, NAME);
if (StringUtils.isEmpty(name))
throw new ClusterConfigException("cluster name undefined");
ClusterType clusterType = ClusterType.NORMAL;
String clusterTypeText = getAttribute(clusterNode, TYPE);
if (!StringUtils.isEmpty(clusterTypeText))
clusterType = ClusterType.parse(clusterTypeText);
DatabaseCategory dbCategory = DatabaseCategory.parse(getAttribute(clusterNode, DB_CATEGORY));
int version = Integer.parseInt(getAttribute(clusterNode, VERSION));
ClusterConfigImpl clusterConfig = new ClusterConfigImpl(name, clusterType, dbCategory, version);
clusterConfig.setCustomizedOption(customizedOption);
Node databaseShardsNode = getChildNode(clusterNode, DATABASE_SHARDS);
if (databaseShardsNode != null) {
List<Node> databaseShardNodes = getChildNodes(databaseShardsNode, DATABASE_SHARD);
for (Node databaseShardNode : databaseShardNodes) parseDatabaseShard(clusterConfig, databaseShardNode);
}
Node shardStrategiesNode = getChildNode(clusterNode, SHARD_STRATEGIES);
if (shardStrategiesNode != null)
parseShardStrategies(clusterConfig, shardStrategiesNode);
Node idGeneratorsNode = getChildNode(clusterNode, ID_GENERATORS);
if (idGeneratorsNode != null)
parseIdGenerators(clusterConfig, idGeneratorsNode);
Node routeStrategiesNode = getChildNode(clusterNode, ROUTE_STRATEGIES);
if (!StringUtils.isEmpty(customizedOption.getRouteStrategy())) {
initRouteStrategy(clusterConfig, customizedOption);
} else if (routeStrategiesNode != null)
parseRouteStrategies(clusterConfig, routeStrategiesNode);
else
initRouteStrategy(clusterConfig);
parseDrcConfig(clusterConfig, clusterNode);
return clusterConfig;
}
Aggregations