Search in sources :

Example 1 with ClusterIdGeneratorConfig

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);
    }
}
Also used : ClusterIdGeneratorConfig(com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGeneratorConfig) ClusterRuntimeException(com.ctrip.framework.dal.cluster.client.exception.ClusterRuntimeException)

Example 2 with ClusterIdGeneratorConfig

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;
}
Also used : ClusterIdGeneratorConfig(com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGeneratorConfig) ClusterIdGenerator(com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGenerator) ClusterIdGenerator(com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGenerator)

Aggregations

ClusterIdGeneratorConfig (com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGeneratorConfig)2 ClusterRuntimeException (com.ctrip.framework.dal.cluster.client.exception.ClusterRuntimeException)1 ClusterIdGenerator (com.ctrip.framework.dal.cluster.client.sharding.idgen.ClusterIdGenerator)1