Package org.apache.curator

Examples of org.apache.curator.RetryPolicy


   *
   * @param config The service configuration.
   * @return A zookeeper client.
   */
  private ZooKeeperClient setupZookeeperClient(final AgentConfig config, final String id) {
    final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);
    final CuratorFramework curator = new CuratorClientFactoryImpl().newClient(
        config.getZooKeeperConnectionString(),
        config.getZooKeeperSessionTimeoutMillis(),
        config.getZooKeeperConnectionTimeoutMillis(),
        zooKeeperRetryPolicy,
View Full Code Here


   *
   * @param config The service configuration.
   * @return A zookeeper client.
   */
  private ZooKeeperClient setupZookeeperClient(final MasterConfig config) {
    final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);
    final CuratorFramework curator = curatorClientFactory.newClient(
        config.getZooKeeperConnectionString(),
        config.getZooKeeperSessionTimeoutMillis(),
        config.getZooKeeperConnectionTimeoutMillis(),
        zooKeeperRetryPolicy,
View Full Code Here

  public void test() throws Exception {
    startDefaultMaster("--zk-namespace", NAMESPACE);
    startDefaultAgent(testHost(), "--zk-namespace", NAMESPACE);
    awaitHostRegistered(testHost(), LONG_WAIT_SECONDS, SECONDS);
    awaitHostStatus(testHost(), UP, LONG_WAIT_SECONDS, SECONDS);
    final RetryPolicy zooKeeperRetryPolicy = new ExponentialBackoffRetry(1000, 3);

    final CuratorFramework framework = CuratorFrameworkFactory.builder()
        .retryPolicy(zooKeeperRetryPolicy)
        .connectString(zk().connectString())
        .connectionTimeoutMs(30000)
View Full Code Here

  private ZooKeeperTestManager zk = new ZooKeeperTestingServerManager();

  @Before
  public void setup() throws Exception {
    final RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
    final CuratorFramework curator = CuratorFrameworkFactory.newClient(zk.connectString(),
                                                                       retryPolicy);
    curator.start();
    client = new DefaultZooKeeperClient(curator);
View Full Code Here

        if ( availableBackups.contains(backup) )
        {
            return UploadResult.DUPLICATE;
        }

        RetryPolicy retryPolicy = makeRetryPolicy(configValues);
        Throttle    throttle = makeThrottle(configValues);

        String                          key = toKey(backup, configValues);

        if ( source.length() < MIN_S3_PART_SIZE )
View Full Code Here

    @Override
    public BackupStream getBackupStream(Exhibitor exhibitor, BackupMetaData backup, Map<String, String> configValues) throws Exception
    {
        long            startMs = System.currentTimeMillis();
        RetryPolicy     retryPolicy = makeRetryPolicy(configValues);
        S3Object        object = null;
        int             retryCount = 0;
        while ( object == null )
        {
            try
            {
                object = s3Client.getObject(configValues.get(CONFIG_BUCKET.getKey()), toKey(backup, configValues));
            }
            catch ( AmazonS3Exception e)
            {
                if ( e.getErrorType() == AmazonServiceException.ErrorType.Client )
                {
                    exhibitor.getLog().add(ActivityLog.Type.ERROR, "Amazon client error: " + ActivityLog.getExceptionMessage(e));
                    return null;
                }

                if ( !retryPolicy.allowRetry(retryCount++, System.currentTimeMillis() - startMs, RetryLoop.getDefaultRetrySleeper()) )
                {
                    exhibitor.getLog().add(ActivityLog.Type.ERROR, "Retries exhausted: " + ActivityLog.getExceptionMessage(e));
                    return null;
                }
            }
View Full Code Here

    public void downloadBackup(Exhibitor exhibitor, BackupMetaData backup, OutputStream destination, Map<String, String> configValues) throws Exception
    {
        byte[]          buffer = new byte[MIN_S3_PART_SIZE];

        long            startMs = System.currentTimeMillis();
        RetryPolicy     retryPolicy = makeRetryPolicy(configValues);
        int             retryCount = 0;
        boolean         done = false;

        while ( !done )
        {
            Throttle            throttle = makeThrottle(configValues);
            InputStream         in = null;
            try
            {
                S3Object            object = s3Client.getObject(configValues.get(CONFIG_BUCKET.getKey()), toKey(backup, configValues));
                in = object.getObjectContent();

                for(;;)
                {
                    int     bytesRead = in.read(buffer);
                    if ( bytesRead < 0 )
                    {
                        break;
                    }

                    throttle.throttle(bytesRead);
                    destination.write(buffer, 0, bytesRead);
                }

                done = true;
            }
            catch ( Exception e )
            {
                if ( !retryPolicy.allowRetry(retryCount++, System.currentTimeMillis() - startMs, RetryLoop.getDefaultRetrySleeper()) )
                {
                    done = true;
                }
            }
            finally
View Full Code Here

TOP

Related Classes of org.apache.curator.RetryPolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.