Examples of RetryPolicy


Examples of org.apache.hadoop.io.retry.RetryPolicy

  }
 
  private static NativeFileSystemStore createDefaultStore(Configuration conf) {
    NativeFileSystemStore store = new Jets3tNativeFileSystemStore();
   
    RetryPolicy basePolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(
        conf.getInt("fs.s3.maxRetries", 4),
        conf.getLong("fs.s3.sleepTimeSeconds", 10), TimeUnit.SECONDS);
    Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    exceptionToPolicyMap.put(IOException.class, basePolicy);
    exceptionToPolicyMap.put(S3Exception.class, basePolicy);
   
    RetryPolicy methodPolicy = RetryPolicies.retryByException(
        RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap);
    Map<String, RetryPolicy> methodNameToPolicyMap =
      new HashMap<String, RetryPolicy>();
    methodNameToPolicyMap.put("storeFile", methodPolicy);
   
View Full Code Here

Examples of org.apache.hadoop.io.retry.RetryPolicy

  }
 
  private static NativeFileSystemStore createDefaultStore(Configuration conf) {
    NativeFileSystemStore store = new Jets3tNativeFileSystemStore();
   
    RetryPolicy basePolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(
        conf.getInt("fs.s3.maxRetries", 4),
        conf.getLong("fs.s3.sleepTimeSeconds", 10), TimeUnit.SECONDS);
    Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    exceptionToPolicyMap.put(IOException.class, basePolicy);
    exceptionToPolicyMap.put(S3Exception.class, basePolicy);
   
    RetryPolicy methodPolicy = RetryPolicies.retryByException(
        RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap);
    Map<String, RetryPolicy> methodNameToPolicyMap =
      new HashMap<String, RetryPolicy>();
    methodNameToPolicyMap.put("storeFile", methodPolicy);
    methodNameToPolicyMap.put("rename", methodPolicy);
View Full Code Here

Examples of org.apache.hadoop.io.retry.RetryPolicy

      InetSocketAddress address, Configuration conf, UserGroupInformation ugi,
      boolean withRetries) throws IOException {
    NamenodeProtocolPB proxy = (NamenodeProtocolPB) createNameNodeProxy(
        address, conf, ugi, NamenodeProtocolPB.class);
    if (withRetries) { // create the proxy with retries
      RetryPolicy timeoutPolicy = RetryPolicies.exponentialBackoffRetry(5, 200,
          TimeUnit.MILLISECONDS);
      Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap
                     = new HashMap<Class<? extends Exception>, RetryPolicy>();
      RetryPolicy methodPolicy = RetryPolicies.retryByException(timeoutPolicy,
          exceptionToPolicyMap);
      Map<String, RetryPolicy> methodNameToPolicyMap
                     = new HashMap<String, RetryPolicy>();
      methodNameToPolicyMap.put("getBlocks", methodPolicy);
      methodNameToPolicyMap.put("getAccessKeys", methodPolicy);
View Full Code Here

Examples of org.apache.yoko.orb.OB.RetryPolicy

            policyTypes[0] = org.apache.yoko.orb.OB.RETRY_POLICY_ID.value;
            Policy[] policy = pm.get_policy_overrides(policyTypes);
            TEST(policy.length == 1
                    && policy[0].policy_type() == org.apache.yoko.orb.OB.RETRY_POLICY_ID.value);

            RetryPolicy p = RetryPolicyHelper.narrow(policy[0]);
            TEST(p.retry_mode() == org.apache.yoko.orb.OB.RETRY_ALWAYS.value);
        }

        {
            try {
                Policy[] pl = new Policy[2];
                Any any = orb.create_any();
                any.insert_short(org.apache.yoko.orb.OB.RETRY_STRICT.value);
                pl[0] = orb.create_policy(
                        org.apache.yoko.orb.OB.RETRY_POLICY_ID.value, any);
                any = orb.create_any();
                any.insert_ulong(3000);
                pl[1] = orb.create_policy(
                        org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value, any);

                pm.set_policy_overrides(pl, SetOverrideType.ADD_OVERRIDE);

            } catch (PolicyError ex) {
                TEST(false);
            } catch (InvalidPolicies ex) {
                TEST(false);
            }

            policyTypes = new int[2];
            policyTypes[0] = org.apache.yoko.orb.OB.RETRY_POLICY_ID.value;
            policyTypes[1] = org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value;

            Policy[] policies = pm.get_policy_overrides(policyTypes);
            TEST(policies.length == 2);

            for (int i = 0; i < policies.length; ++i) {
                switch (policies[i].policy_type()) {
                case org.apache.yoko.orb.OB.RETRY_POLICY_ID.value: {
                    try {
                        RetryPolicy policy = RetryPolicyHelper
                                .narrow(policies[i]);
                        TEST(policy != null);
                        TEST(policy.retry_mode() == org.apache.yoko.orb.OB.RETRY_STRICT.value);
                    } catch (BAD_PARAM ex) {
                        TEST(false);
                    }
                    break;
                }
                case org.apache.yoko.orb.OB.TIMEOUT_POLICY_ID.value: {
                    try {
                        TimeoutPolicy policy = TimeoutPolicyHelper
                                .narrow(policies[i]);
                        TEST(policy != null);
                        TEST(policy.value() == 3000);
                    } catch (BAD_PARAM ex) {
                        TEST(false);
                    }
                    break;
                }
View Full Code Here

Examples of org.apache.yoko.orb.OB.RetryPolicy

    private static RetryAttributes getRetry(org.omg.CORBA.Policy[] policies) {
        RetryAttributes attributes = new RetryAttributes();
        for (int i = 0; i < policies.length; i++) {
            if (policies[i].policy_type() == RETRY_POLICY_ID.value) {
                RetryPolicy policy = (RetryPolicy) policies[i];

                attributes.mode = policy.retry_mode();
                attributes.interval = policy.retry_interval();
                attributes.max = policy.retry_max();
                attributes.remote = policy.retry_remote();

                return attributes;
            }
        }
        attributes.mode = RETRY_STRICT.value;
View Full Code Here

Examples of org.mule.api.retry.RetryPolicy

    }

    public RetryContext execute(RetryCallback callback, WorkManager workManager) throws Exception
    {
        PolicyStatus status = null;
        RetryPolicy policy = createRetryInstance();
        DefaultRetryContext context = new DefaultRetryContext(callback.getWorkDescription(),
            metaInfo);
        context.setMuleContext(muleContext);

        try
        {
            Exception cause = null;
            do
            {
                try
                {
                    callback.doWork(context);
                    if (notifier != null)
                    {
                        notifier.onSuccess(context);
                    }
                    break;
                }
                catch (Exception e)
                {
                    cause = e;
                    if (logger.isDebugEnabled())
                    {
                        logger.debug(cause);
                    }
                    if (notifier != null)
                    {
                        notifier.onFailure(context, cause);
                    }
                    if (cause instanceof InterruptedException || cause instanceof InterruptedIOException)
                    {
                        logger.error("Process was interrupted (InterruptedException), ceasing process");
                        break;
                    }
                    else
                    {
                        status = policy.applyPolicy(cause);
                    }
                }
            }
            while (status.isOk());
View Full Code Here

Examples of org.springframework.retry.RetryPolicy

   * Delegate to the policy currently activated in the context.
   *
   * @see org.springframework.retry.RetryPolicy#canRetry(org.springframework.retry.RetryContext)
   */
  public boolean canRetry(RetryContext context) {
    RetryPolicy policy = (RetryPolicy) context;
    return policy.canRetry(context);
  }
View Full Code Here

Examples of tachyon.retry.RetryPolicy

    if (mIsShutdown) {
      throw new IOException("Client is shutdown, will not try to connect");
    }

    Exception lastException = null;
    RetryPolicy retry = new ExponentialBackoffRetry(50, Constants.SECOND_MS, MAX_CONNECT_TRY);
    do {
      mMasterAddress = getMasterAddress();

      LOG.info("Tachyon client (version " + Version.VERSION + ") is trying to connect master @ "
          + mMasterAddress);

      mProtocol =
          new TBinaryProtocol(new TFramedTransport(new TSocket(
              NetworkUtils.getFqdnHost(mMasterAddress), mMasterAddress.getPort())));
      mClient = new MasterService.Client(mProtocol);
      try {
        mProtocol.getTransport().open();

        mHeartbeatThread =
            new HeartbeatThread("Master_Client Heartbeat", new MasterClientHeartbeatExecutor(this),
                UserConf.get().HEARTBEAT_INTERVAL_MS / 2);
        mHeartbeatThread.start();
      } catch (TTransportException e) {
        lastException = e;
        LOG.error("Failed to connect (" + retry.getRetryCount() + ") to master " + mMasterAddress
            + " : " + e.getMessage());
        if (mHeartbeatThread != null) {
          mHeartbeatThread.shutdown();
        }
        continue;
      }

      try {
        mUserId = mClient.user_getUserId();
      } catch (TException e) {
        lastException = e;
        LOG.error(e.getMessage(), e);
        continue;
      }
      LOG.info("User registered at the master " + mMasterAddress + " got UserId " + mUserId);

      mConnected = true;
      return;
    } while (retry.attemptRetry() && !mIsShutdown);

    // Reaching here indicates that we did not successfully connect.
    throw new IOException("Failed to connect to master " + mMasterAddress + " after "
        + (retry.getRetryCount()) + " attempts", lastException);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.