Search in sources :

Example 1 with ForeverRetryPolicy

use of rpc.turbo.zk.common.ForeverRetryPolicy in project turbo-rpc by hank-whu.

the class ZooKeeperRegister method init.

@Override
public void init(List<HostPort> hostPorts) {
    watcherMap = new ConcurrentHashMap<>();
    String connectString = hostPorts.stream().map(i -> i.toString()).collect(Collectors.joining(","));
    RetryPolicy retryPolicy = new ForeverRetryPolicy(1000, 60 * 1000);
    client = CuratorFrameworkFactory.newClient(connectString, 1000 * 10, 1000 * 3, retryPolicy);
    client.start();
}
Also used : CreateMode(org.apache.zookeeper.CreateMode) CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) Register(rpc.turbo.registry.Register) IOException(java.io.IOException) Protocol(rpc.turbo.config.server.Protocol) Collectors(java.util.stream.Collectors) PathChildrenCacheListener(org.apache.curator.framework.recipes.cache.PathChildrenCacheListener) AddressWithWeight(rpc.turbo.config.AddressWithWeight) StandardCharsets(java.nio.charset.StandardCharsets) StartMode(org.apache.curator.framework.recipes.cache.PathChildrenCache.StartMode) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) ConcurrentMap(java.util.concurrent.ConcurrentMap) Objects(java.util.Objects) List(java.util.List) CuratorFramework(org.apache.curator.framework.CuratorFramework) HostPort(rpc.turbo.config.HostPort) RetryPolicy(org.apache.curator.RetryPolicy) PathChildrenCacheEvent(org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent) PathChildrenCache(org.apache.curator.framework.recipes.cache.PathChildrenCache) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) ConcurrentHashMap(org.jboss.netty.util.internal.ConcurrentHashMap) HexUtils(rpc.turbo.util.HexUtils) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) RetryPolicy(org.apache.curator.RetryPolicy)

Example 2 with ForeverRetryPolicy

use of rpc.turbo.zk.common.ForeverRetryPolicy in project turbo-rpc by hank-whu.

the class ZooKeeperDiscover method init.

@Override
public void init(List<HostPort> hostPorts) {
    watchers = new ConcurrentArrayList<>();
    String connectString = hostPorts.stream().map(i -> i.toString()).collect(Collectors.joining(","));
    RetryPolicy retryPolicy = new ForeverRetryPolicy(1000, 60 * 1000);
    client = CuratorFrameworkFactory.newClient(connectString, 1000 * 10, 1000 * 3, retryPolicy);
    client.start();
}
Also used : CuratorFrameworkFactory(org.apache.curator.framework.CuratorFrameworkFactory) Discover(rpc.turbo.discover.Discover) ConcurrentArrayList(rpc.turbo.util.concurrent.ConcurrentArrayList) IOException(java.io.IOException) Protocol(rpc.turbo.config.server.Protocol) Collectors(java.util.stream.Collectors) PathChildrenCacheListener(org.apache.curator.framework.recipes.cache.PathChildrenCacheListener) AddressWithWeight(rpc.turbo.config.AddressWithWeight) StartMode(org.apache.curator.framework.recipes.cache.PathChildrenCache.StartMode) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) ConcurrentMap(java.util.concurrent.ConcurrentMap) Objects(java.util.Objects) List(java.util.List) CuratorFramework(org.apache.curator.framework.CuratorFramework) HostPort(rpc.turbo.config.HostPort) DiscoverListener(rpc.turbo.discover.DiscoverListener) RetryPolicy(org.apache.curator.RetryPolicy) PathChildrenCacheEvent(org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent) PathChildrenCache(org.apache.curator.framework.recipes.cache.PathChildrenCache) Log(org.apache.commons.logging.Log) LogFactory(org.apache.commons.logging.LogFactory) ConcurrentHashMap(org.jboss.netty.util.internal.ConcurrentHashMap) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) ForeverRetryPolicy(rpc.turbo.zk.common.ForeverRetryPolicy) RetryPolicy(org.apache.curator.RetryPolicy)

Aggregations

IOException (java.io.IOException)2 List (java.util.List)2 Objects (java.util.Objects)2 ConcurrentMap (java.util.concurrent.ConcurrentMap)2 Collectors (java.util.stream.Collectors)2 Log (org.apache.commons.logging.Log)2 LogFactory (org.apache.commons.logging.LogFactory)2 RetryPolicy (org.apache.curator.RetryPolicy)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 CuratorFrameworkFactory (org.apache.curator.framework.CuratorFrameworkFactory)2 PathChildrenCache (org.apache.curator.framework.recipes.cache.PathChildrenCache)2 StartMode (org.apache.curator.framework.recipes.cache.PathChildrenCache.StartMode)2 PathChildrenCacheEvent (org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent)2 PathChildrenCacheListener (org.apache.curator.framework.recipes.cache.PathChildrenCacheListener)2 ConcurrentHashMap (org.jboss.netty.util.internal.ConcurrentHashMap)2 AddressWithWeight (rpc.turbo.config.AddressWithWeight)2 HostPort (rpc.turbo.config.HostPort)2 Protocol (rpc.turbo.config.server.Protocol)2 ForeverRetryPolicy (rpc.turbo.zk.common.ForeverRetryPolicy)2 StandardCharsets (java.nio.charset.StandardCharsets)1