use of com.ctrip.framework.dal.cluster.client.sharding.strategy.ShardStrategy in project dal by ctripcorp.
the class ClusterConfigImpl method innerGenerate.
private Cluster innerGenerate() {
DefaultCluster cluster = (clusterType != ClusterType.DRC && unitStrategyId == null ? new DefaultCluster(this) : new DefaultDrcCluster(this));
for (DatabaseShardConfig databaseShardConfig : databaseShardConfigs) cluster.addDatabaseShard(databaseShardConfig.generate());
ShardStrategyProxy shardStrategy = new ShardStrategyProxy(defaultShardStrategy);
for (ShardStrategy strategy : shardStrategies) shardStrategy.addStrategy(strategy);
cluster.setShardStrategy(shardStrategy);
cluster.setIdGeneratorConfig(idGeneratorConfig);
cluster.setRouteStrategyConfig(routeStrategyConfig);
LocalizationState localizationState = LocalizationState.NONE;
if (clusterType == ClusterType.DRC)
localizationState = LocalizationState.ACTIVE;
else if (unitStrategyId != null)
localizationState = LocalizationState.PREPARED;
cluster.setLocalizationConfig(new LocalizationConfigImpl(unitStrategyId, zoneId, localizationState, drcConsistencyType));
cluster.setCustomizedOption(customizedOption);
cluster.setCustomProperties(customProperties);
cluster.validate();
return cluster;
}
use of com.ctrip.framework.dal.cluster.client.sharding.strategy.ShardStrategy in project dal by ctripcorp.
the class ClusterConfigXMLParser method parseCustomStrategy.
private void parseCustomStrategy(ClusterConfigImpl clusterConfig, Node strategyNode) {
String className = getAttribute(strategyNode, CLASS);
try {
ShardStrategy strategy = instancingCustomShardStrategy(clusterConfig, className);
parseShardStrategy(clusterConfig, strategyNode, strategy);
} catch (Throwable t) {
if (!clusterConfig.getCustomizedOption().isIgnoreShardingResourceNotFound()) {
throw new ClusterRuntimeException("invalid custom strategy impl class", t);
}
}
}
Aggregations