当前位置: 首页>>代码示例>>Java>>正文


Java BoundedExponentialBackoffRetry类代码示例

本文整理汇总了Java中org.apache.curator.retry.BoundedExponentialBackoffRetry的典型用法代码示例。如果您正苦于以下问题:Java BoundedExponentialBackoffRetry类的具体用法?Java BoundedExponentialBackoffRetry怎么用?Java BoundedExponentialBackoffRetry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BoundedExponentialBackoffRetry类属于org.apache.curator.retry包,在下文中一共展示了BoundedExponentialBackoffRetry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeCurator

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
private Completable initializeCurator()
{
    // Create/start CuratorFramework client
    RetryPolicy retryPolicy = new BoundedExponentialBackoffRetry(retryBaseTime, retryMaxTime, retryLimit);
    EnsembleProvider ensembleProvider = new FixedEnsembleProvider(connectionString);
    curator = CuratorFrameworkFactory.builder()
        .ensembleProvider(ensembleProvider)
        .retryPolicy(retryPolicy)
        .namespace(namespace)
        .sessionTimeoutMs(sessionTimeout)
        .connectionTimeoutMs(connectionTimeout)
        .build();
    curator.start();

    // Create a NodeCache for each config descriptor
    // This creates N node caches at a time on the RxJava IO scheduler thread pool.
    return Observable.from(configDescriptors)
        .flatMap(desc -> buildNodeCache(desc)
            .subscribeOn(Schedulers.io())
            .map(nc -> this.configNodeCaches.put(desc, nc)), getConcurrentNodeCacheCreations())
        .toCompletable();
}
 
开发者ID:kikinteractive,项目名称:ice,代码行数:23,代码来源:ZooKeeperDynamicConfigSource.java

示例2: init

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
@Before
public void init() throws Throwable {
    zkRootClient = CuratorFrameworkFactory.builder()
            .connectString(server.getConnectString())
            .retryPolicy(new BoundedExponentialBackoffRetry(10, 100, 7))
            .build();
    zkRootClient.start();

    ZooKeeper zk = zkRootClient.getZookeeperClient().getZooKeeper();
    ZKPaths.mkdirs(zk, "/"+ CloudConfigCommon.CONFIG_ROOT);
    ZKPaths.mkdirs(zk, "/"+CloudConfigCommon.PROPERTY_ROOT);

    zkConfigClient = zkRootClient.usingNamespace(CloudConfigCommon.CONFIG_ROOT);
    zkPropsClient  = zkRootClient.usingNamespace(CloudConfigCommon.PROPERTY_ROOT);

    prepare();
}
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:18,代码来源:BaseTestClass.java

示例3: before

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
@Override
protected void before() throws Throwable
{
    ts = new TestingServer();
    curator = CuratorFrameworkFactory.builder()
                                     .namespace("ezkr")
                                     .connectString(ts.getConnectString())
                                     .retryPolicy(new BoundedExponentialBackoffRetry(10, 100, 7))
                                     .build();
    curator.getConnectionStateListenable().addListener(new ConnectionStateListener()
    {
        @Override
        public void stateChanged(final CuratorFramework client, final ConnectionState newState)
        {

        }
    });
    curator.start();
}
 
开发者ID:brianm,项目名称:dx,代码行数:20,代码来源:EmbeddedZooKeeperRule.java

示例4: nextId

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public long nextId(final String namespace) {
    final String[] paths = calcPathIdAndPathLock(namespace);
    final String pathId = paths[0];
    final String pathLock = paths[1];

    RetryPolicy retryPolicyMutex = new BoundedExponentialBackoffRetry(10, 1000, 5);
    PromotedToLock promotedToLock = PromotedToLock.builder().retryPolicy(retryPolicyMutex)
            .lockPath(pathLock).build();
    RetryPolicy retryPolicyOptimistic = new RetryNTimes(3, 100);
    DistributedAtomicLong dal = new DistributedAtomicLong(curatorFramework, pathId,
            retryPolicyOptimistic, promotedToLock);
    semaphore.acquireUninterruptibly();
    try {
        AtomicValue<Long> value = dal.increment();
        if (value != null && value.succeeded()) {
            return value.postValue();
        }
        return -1;
    } catch (Exception e) {
        throw e instanceof IdException ? (IdException) e : new IdException(e);
    } finally {
        semaphore.release();
    }
}
 
开发者ID:DDTH,项目名称:ddth-id,代码行数:29,代码来源:ZookeeperIdGenerator.java

示例5: currentId

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public long currentId(final String namespace) {
    final String[] paths = calcPathIdAndPathLock(namespace);
    final String pathId = paths[0];
    final String pathLock = paths[1];

    RetryPolicy retryPolicyMutex = new BoundedExponentialBackoffRetry(10, 1000, 5);
    PromotedToLock promotedToLock = PromotedToLock.builder().retryPolicy(retryPolicyMutex)
            .lockPath(pathLock).build();
    RetryPolicy retryPolicyOptimistic = new RetryNTimes(3, 100);
    DistributedAtomicLong dal = new DistributedAtomicLong(curatorFramework, pathId,
            retryPolicyOptimistic, promotedToLock);
    try {
        AtomicValue<Long> value = dal.get();
        if (value != null && value.succeeded()) {
            return value.postValue();
        }
        throw new IdException("Operation was not successful!");
    } catch (Exception e) {
        throw e instanceof IdException ? (IdException) e : new IdException(e);
    }
}
 
开发者ID:DDTH,项目名称:ddth-id,代码行数:26,代码来源:ZookeeperIdGenerator.java

示例6: retryPolicy

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
public RetryPolicy retryPolicy() {
    /**
     * int baseSleepTimeMs, int maxSleepTimeMs, int maxRetries
     **/
    int baseSleepTimeMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.base.sleep.time.ms", "1000"));
    int maxSleepTimeMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.max.sleep.time.ms", "5000"));
    int maxRetries = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.max.retries", "29"));
    return new BoundedExponentialBackoffRetry(baseSleepTimeMs,
            maxSleepTimeMs, maxRetries);
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:14,代码来源:HelloClientConfig.java

示例7: retryPolicy

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
public RetryPolicy retryPolicy() {
	int baseSleepTimeMs = Integer.parseInt(env.getProperty(
			"rpc.server.zookeeper.base.sleep.time.ms", "1000"));
	int maxSleepTimeMs = Integer.parseInt(env.getProperty(
			"rpc.server.zookeeper.max.sleep.time.ms", "5000"));
	int maxRetries = Integer.parseInt(env.getProperty(
			"rpc.server.zookeeper.max.retries", "29"));
	return new BoundedExponentialBackoffRetry(baseSleepTimeMs,
			maxSleepTimeMs, maxRetries);
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:11,代码来源:HelloServerConfig.java

示例8: retryPolicy

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
@Bean
public RetryPolicy retryPolicy() {
    int baseSleepTimeMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.base.sleep.time.ms", "1000"));
    int maxSleepTimeMs = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.max.sleep.time.ms", "5000"));
    int maxRetries = Integer.parseInt(env.getProperty(
            "rpc.client.zookeeper.max.retries", "29"));
    return new BoundedExponentialBackoffRetry(baseSleepTimeMs,
            maxSleepTimeMs, maxRetries);
}
 
开发者ID:jigsaw-projects,项目名称:jigsaw-payment,代码行数:12,代码来源:HelloClientConfig.java

示例9: getCuratorClient

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
public static CuratorFramework getCuratorClient(final TrellisConfiguration config) {
    final CuratorFramework curator = newClient(config.getZookeeper().getEnsembleServers(),
            new BoundedExponentialBackoffRetry(config.getZookeeper().getRetryMs(),
                config.getZookeeper().getRetryMaxMs(), config.getZookeeper().getRetryMax()));
    curator.start();
    return curator;
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:8,代码来源:TrellisUtils.java

示例10: init

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
public void init(Map<String, Object> conf, String participantId) {
    Preconditions.checkNotNull(participantId, "participantId can not be null");
    Preconditions.checkNotNull(conf, "conf can not be null");

    this.conf = conf;
    this.serverUrl = participantId;
    this.leaderLatchListener = createLeaderLatchListener();

    LOG.info("Received configuration : [{}]", conf);

    CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder();
    String url = (String) conf.get(CONNECT_URL);
    String rootPrefix = (String) conf.get("root");
    builder.connectString(url);
    builder.connectionTimeoutMs((Integer) conf.getOrDefault(CONNECTION_TIMEOUT_MS, DEFAULT_CONN_TIMOUT));
    builder.sessionTimeoutMs((Integer) conf.getOrDefault(SESSION_TIMEOUT_MS, DEFAULT_SESSION_TIMEOUT));

    builder.retryPolicy(
            new BoundedExponentialBackoffRetry(
                    (Integer) conf.getOrDefault(RETRY_BASE_SLEEP_TIME_MS, DEFAULT_BASE_SLEEP_TIME),
                    (Integer) conf.getOrDefault(RETRY_MAX_SLEEP_TIME_MS, DEFAULT_MAX_SLEEP_TIME),
                    (Integer) conf.getOrDefault(RETRY_LIMIT, DEFAULT_RETRY_LIMIT)

            ));

    curatorFramework = builder.build();
    leaderLatchPath = rootPrefix + LEADER_LOCK_NODE_PATH;
    leaderLatchRef = new AtomicReference<>(createLeaderLatch());
    curatorFramework.start();
}
 
开发者ID:hortonworks,项目名称:registry,代码行数:31,代码来源:ZKLeadershipParticipant.java

示例11: setup

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
@BeforeMethod
private void setup() throws Exception {
    _zooKeeperServer = new TestingServer();
    _curator = CuratorFrameworkFactory.newClient(_zooKeeperServer.getConnectString(),
            new BoundedExponentialBackoffRetry(100, 1000, 5));
    _curator.start();
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:8,代码来源:LocalDataCenterEndPointProviderTest.java

示例12: ZkRegistry

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
public ZkRegistry(ZkConfig zkConfig) {

        zkClient = CuratorFrameworkFactory.builder().connectString(zkConfig.getZkAddress())
                .sessionTimeoutMs(zkConfig.getZkTimeout())
                .retryPolicy(new BoundedExponentialBackoffRetry(zkConfig.getBaseSleepTimeMs(),
                        zkConfig.getMaxSleepTimeMs(), zkConfig.getMaxRetries()))
                .build();

        zkClient.start();
    }
 
开发者ID:ketao1989,项目名称:ourea,代码行数:11,代码来源:ZkRegistry.java

示例13: prepare

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
private static void prepare(TestingServer server) throws Exception {
        CuratorFramework zkRootClient = null;
        try {
            zkRootClient = CuratorFrameworkFactory.builder()
                    .connectString(server.getConnectString())
                    .retryPolicy(new BoundedExponentialBackoffRetry(10, 100, 7))
                    .build();
            zkRootClient.start();

            ZooKeeper zk = zkRootClient.getZookeeperClient().getZooKeeper();
            ZKPaths.mkdirs(zk, "/" + CloudConfigCommon.CONFIG_ROOT);
            ZKPaths.mkdirs(zk, "/"+CloudConfigCommon.PROPERTY_ROOT);

            CuratorFramework zkConfigClient = zkRootClient.usingNamespace(CloudConfigCommon.CONFIG_ROOT);
//        CuratorFramework zkPropsClient  = zkRootClient.usingNamespace(CloudConfigCommon.PROPERTY_ROOT);

            String config = "{\n" +
                    "    \"driverClassName\" : \"com.mysql.jdbc.Driver\",\n" +
                    "    \"userName\" : \"root\",\n" +
                    "    \"password\" : \"1111\", \n"+
                    "    \"jdbcUrl\" : \"jdbc:mysql://127.0.0.1:3306/a?characterEncoding=utf8&createDatabaseIfNotExist=true\"\n"+
                    "}";

            zkConfigClient.create().creatingParentsIfNeeded().forPath("/database/mydb", config.getBytes());
        } finally {
            if(zkRootClient!=null) {
                zkRootClient.close();
            }
        }
    }
 
开发者ID:hekailiang,项目名称:cloud-config,代码行数:31,代码来源:CloudConfigSample.java

示例14: curatorSupplier

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
private static Supplier<CuratorFramework> curatorSupplier() {
    return new Supplier<CuratorFramework>() {
        @Override public CuratorFramework get() {
            final String quorum = System.getProperty("zk.quorum", "localhost");
            final int sessionTimeout = Integer.parseInt(
                    System.getProperty("zk.session.timeout", "30000"));
            final int connectionTimeout = Integer.parseInt(
                    System.getProperty("zk.connection.timeout", "15000"));
            final int initialDelay = Integer.parseInt(
                    System.getProperty("zk.retry.initialDelay", "10"));
            final int maxDelay = Integer.parseInt(
                    System.getProperty("zk.retry.maxDelay", "200"));
            final int maxCount = Integer.parseInt(
                    System.getProperty("zk.retry.maxCount", "10"));


            logger.info("Initializing the Zookeeper client for quorum: {}", quorum);

            final CuratorFramework curator = CuratorFrameworkFactory.newClient(quorum, sessionTimeout, connectionTimeout,
                    new BoundedExponentialBackoffRetry(initialDelay, maxDelay, maxCount));

            curator.start();

            Runtime.getRuntime().addShutdownHook(new Thread() {
                @Override
                public void run() {
                    logger.info("Shutting down the Zookeeper client...");
                    curator.close();
                }
            });

            return curator;
        }
    };
}
 
开发者ID:adobe-research,项目名称:cross-preferences,代码行数:36,代码来源:ZkManager.java

示例15: build

import org.apache.curator.retry.BoundedExponentialBackoffRetry; //导入依赖的package包/类
@Override
RetryPolicy build(Config config) {
  return new BoundedExponentialBackoffRetry(
      getMillis(config, "baseSleepDuration"),
      getMillis(config, "maxSleepDuration"),
      config.getInt("maxRetries"));
}
 
开发者ID:xjdr,项目名称:xio,代码行数:8,代码来源:ZooKeeperClientFactory.java


注:本文中的org.apache.curator.retry.BoundedExponentialBackoffRetry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。