use of com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGeneratorConfig in project dal by ctripcorp.
the class ClusterConfigXMLParser method parseIdGenerators.
private void parseIdGenerators(ClusterConfigImpl clusterConfig, Node idGeneratorsNode) {
List<Node> idGeneratorNodes = getChildNodes(idGeneratorsNode, ID_GENERATOR);
if (idGeneratorNodes.size() > 1)
throw new ClusterRuntimeException("multiple idGenerators configured");
if (idGeneratorNodes.size() == 1) {
Node idGeneratorNode = idGeneratorNodes.get(0);
ClusterIdGeneratorConfig idGeneratorConfig = getIdGeneratorConfigXMLParser().parse(clusterConfig.getClusterName(), idGeneratorNode);
clusterConfig.setIdGeneratorConfig(idGeneratorConfig);
}
}
use of com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGeneratorConfig in project dal by ctripcorp.
the class ClusterIdGeneratorConfigAdapter method getIdGenerator.
@Override
public IdGenerator getIdGenerator(String name) {
ClusterIdGeneratorConfig idGeneratorConfig = getIdGeneratorConfig();
if (idGeneratorConfig == null)
return null;
ClusterIdGenerator idGenerator = idGeneratorConfig.getIdGenerator(name);
if (idGenerator instanceof IdGenerator)
return (IdGenerator) idGenerator;
return null;
}
Aggregations