Search in sources :

Example 1 with ZookeeperRegistryCenter

use of com.paascloud.core.registry.zookeeper.ZookeeperRegistryCenter in project paascloud-master by paascloud.

the class RegistryCenterFactory method createCoordinatorRegistryCenter.

/**
 * 创建注册中心.
 *
 * @param zookeeperProperties the zookeeper properties
 *
 * @return 注册中心对象 coordinator registry center
 */
public static CoordinatorRegistryCenter createCoordinatorRegistryCenter(ZookeeperProperties zookeeperProperties) {
    Hasher hasher = Hashing.md5().newHasher().putString(zookeeperProperties.getZkAddressList(), Charsets.UTF_8);
    HashCode hashCode = hasher.hash();
    CoordinatorRegistryCenter result = REG_CENTER_REGISTRY.get(hashCode);
    if (null != result) {
        return result;
    }
    result = new ZookeeperRegistryCenter(zookeeperProperties);
    result.init();
    REG_CENTER_REGISTRY.put(hashCode, result);
    return result;
}
Also used : ZookeeperRegistryCenter(com.paascloud.core.registry.zookeeper.ZookeeperRegistryCenter) Hasher(com.google.common.hash.Hasher) HashCode(com.google.common.hash.HashCode) CoordinatorRegistryCenter(com.paascloud.core.registry.base.CoordinatorRegistryCenter)

Aggregations

HashCode (com.google.common.hash.HashCode)1 Hasher (com.google.common.hash.Hasher)1 CoordinatorRegistryCenter (com.paascloud.core.registry.base.CoordinatorRegistryCenter)1 ZookeeperRegistryCenter (com.paascloud.core.registry.zookeeper.ZookeeperRegistryCenter)1