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


Java RetryPolicies.exponentialBackoffRetry方法代码示例

本文整理汇总了Java中org.apache.hadoop.io.retry.RetryPolicies.exponentialBackoffRetry方法的典型用法代码示例。如果您正苦于以下问题:Java RetryPolicies.exponentialBackoffRetry方法的具体用法?Java RetryPolicies.exponentialBackoffRetry怎么用?Java RetryPolicies.exponentialBackoffRetry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.io.retry.RetryPolicies的用法示例。


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

示例1: createNNProxyWithNamenodeProtocol

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNNProxyWithNamenodeProtocol(
    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<String, RetryPolicy> methodNameToPolicyMap
         = new HashMap<String, RetryPolicy>();
    methodNameToPolicyMap.put("getBlocks", timeoutPolicy);
    methodNameToPolicyMap.put("getAccessKeys", timeoutPolicy);
    NamenodeProtocol translatorProxy =
        new NamenodeProtocolTranslatorPB(proxy);
    return (NamenodeProtocol) RetryProxy.create(
        NamenodeProtocol.class, translatorProxy, methodNameToPolicyMap);
  } else {
    return new NamenodeProtocolTranslatorPB(proxy);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:NameNodeProxies.java

示例2: createNNProxyWithNamenodeProtocol

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNNProxyWithNamenodeProtocol(
    InetSocketAddress address, Configuration conf, UserGroupInformation ugi,
    boolean withRetries) throws IOException {
  NamenodeProtocolPB proxy = (NamenodeProtocolPB) createNameNodeProxy(
      address, conf, ugi, NamenodeProtocolPB.class, 0);
  if (withRetries) { // create the proxy with retries
    RetryPolicy timeoutPolicy = RetryPolicies.exponentialBackoffRetry(5, 200,
            TimeUnit.MILLISECONDS);
    Map<String, RetryPolicy> methodNameToPolicyMap
         = new HashMap<String, RetryPolicy>();
    methodNameToPolicyMap.put("getBlocks", timeoutPolicy);
    methodNameToPolicyMap.put("getAccessKeys", timeoutPolicy);
    NamenodeProtocol translatorProxy =
        new NamenodeProtocolTranslatorPB(proxy);
    return (NamenodeProtocol) RetryProxy.create(
        NamenodeProtocol.class, translatorProxy, methodNameToPolicyMap);
  } else {
    return new NamenodeProtocolTranslatorPB(proxy);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:21,代码来源:NameNodeProxies.java

示例3: createNamenode

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNamenode(Configuration conf)
  throws IOException {
  InetSocketAddress nameNodeAddr = NameNode.getServiceAddress(conf, true);
  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);

  UserGroupInformation ugi = UserGroupInformation.getCurrentUser();

  return (NamenodeProtocol) RetryProxy.create(
      NamenodeProtocol.class,
      RPC.getProxy(NamenodeProtocol.class,
          NamenodeProtocol.versionID,
          nameNodeAddr,
          ugi,
          conf,
          NetUtils.getDefaultSocketFactory(conf)),
      methodNameToPolicyMap);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:27,代码来源:Balancer.java

示例4: createNamenode

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
protected static NamenodeProtocol createNamenode(InetSocketAddress nameNodeAddr, Configuration conf)
  throws IOException {
  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);

  UserGroupInformation ugi;
  try {
    ugi = UnixUserGroupInformation.login(conf);
  } catch (javax.security.auth.login.LoginException e) {
    throw new IOException(StringUtils.stringifyException(e));
  }

  return (NamenodeProtocol) RetryProxy.create(
      NamenodeProtocol.class,
      RPC.getProxy(NamenodeProtocol.class,
          NamenodeProtocol.versionID,
          nameNodeAddr,
          ugi,
          conf,
          NetUtils.getDefaultSocketFactory(conf)),
      methodNameToPolicyMap);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:30,代码来源:Balancer.java

示例5: createNamenode

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNamenode(Configuration conf)
  throws IOException {
  InetSocketAddress nameNodeAddr = NameNode.getServiceAddress(conf, true);
  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);

  UserGroupInformation ugi;
  ugi = UserGroupInformation.getCurrentUser();

  return (NamenodeProtocol) RetryProxy.create(
      NamenodeProtocol.class,
      RPC.getProxy(NamenodeProtocol.class,
          NamenodeProtocol.versionID,
          nameNodeAddr,
          ugi,
          conf,
          NetUtils.getDefaultSocketFactory(conf)),
      methodNameToPolicyMap);
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:28,代码来源:Balancer.java

示例6: createNamenode

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNamenode(InetSocketAddress nameNodeAddr, Configuration conf)
  throws IOException {
  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);

  UserGroupInformation ugi;
  try {
    ugi = UnixUserGroupInformation.login(conf);
  } catch (javax.security.auth.login.LoginException e) {
    throw new IOException(StringUtils.stringifyException(e));
  }

  return (NamenodeProtocol) RetryProxy.create(
      NamenodeProtocol.class,
      RPC.getProxy(NamenodeProtocol.class,
          NamenodeProtocol.versionID,
          nameNodeAddr,
          ugi,
          conf,
          NetUtils.getDefaultSocketFactory(conf)),
      methodNameToPolicyMap);
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:30,代码来源:Balancer.java

示例7: createNamenode

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
private static NamenodeProtocol createNamenode(Configuration conf)
  throws IOException {
  InetSocketAddress nameNodeAddr = NameNode.getAddress(conf);
  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);

  UserGroupInformation ugi;
  try {
    ugi = UnixUserGroupInformation.login(conf);
  } catch (javax.security.auth.login.LoginException e) {
    throw new IOException(StringUtils.stringifyException(e));
  }

  return (NamenodeProtocol) RetryProxy.create(
      NamenodeProtocol.class,
      RPC.getProxy(NamenodeProtocol.class,
          NamenodeProtocol.versionID,
          nameNodeAddr,
          ugi,
          conf,
          NetUtils.getDefaultSocketFactory(conf)),
      methodNameToPolicyMap);
}
 
开发者ID:thisisvoa,项目名称:hadoop-0.20,代码行数:31,代码来源:Balancer.java

示例8: testGetNextRetryTime

import org.apache.hadoop.io.retry.RetryPolicies; //导入方法依赖的package包/类
@Test
public void testGetNextRetryTime() throws Exception {
  GenericTestUtils.setLogLevel(UserGroupInformation.LOG, Level.DEBUG);
  final long reloginInterval = 1;
  final long reloginIntervalMs = reloginInterval * 1000;
  // Relogin happens every 1 second.
  conf.setLong(HADOOP_KERBEROS_MIN_SECONDS_BEFORE_RELOGIN, reloginInterval);
  SecurityUtil.setAuthenticationMethod(AuthenticationMethod.KERBEROS, conf);
  UserGroupInformation.setConfiguration(conf);

  // Suppose tgt start time is now, end time is 20 seconds from now.
  final long now = Time.now();
  final Date endDate = new Date(now + 20000);

  // Explicitly test the exponential back-off logic.
  // Suppose some time (10 seconds) passed.
  // Verify exponential backoff and max=(login interval before endTime).
  final long currentTime = now + 10000;
  final long endTime = endDate.getTime();

  assertEquals(0, UserGroupInformation.metrics.getRenewalFailures().value());
  RetryPolicy rp = RetryPolicies.exponentialBackoffRetry(Long.SIZE - 2,
      1000, TimeUnit.MILLISECONDS);
  long lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  assertWithinBounds(
      UserGroupInformation.metrics.getRenewalFailures().value(),
      lastRetry, reloginIntervalMs, currentTime);

  UserGroupInformation.metrics.getRenewalFailures().incr();
  lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  assertWithinBounds(
      UserGroupInformation.metrics.getRenewalFailures().value(),
      lastRetry, reloginIntervalMs, currentTime);

  UserGroupInformation.metrics.getRenewalFailures().incr();
  lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  assertWithinBounds(
      UserGroupInformation.metrics.getRenewalFailures().value(),
      lastRetry, reloginIntervalMs, currentTime);

  UserGroupInformation.metrics.getRenewalFailures().incr();
  lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  assertWithinBounds(
      UserGroupInformation.metrics.getRenewalFailures().value(),
      lastRetry, reloginIntervalMs, currentTime);

  // last try should be right before expiry.
  UserGroupInformation.metrics.getRenewalFailures().incr();
  lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  String str =
      "5th retry, now:" + currentTime + ", retry:" + lastRetry;
  LOG.info(str);
  assertEquals(str, endTime - reloginIntervalMs, lastRetry);

  // make sure no more retries after (tgt endTime - login interval).
  UserGroupInformation.metrics.getRenewalFailures().incr();
  lastRetry =
      UserGroupInformation.getNextTgtRenewalTime(endTime, currentTime, rp);
  str = "overflow retry, now:" + currentTime + ", retry:" + lastRetry;
  LOG.info(str);
  assertEquals(str, endTime - reloginIntervalMs, lastRetry);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:68,代码来源:TestUserGroupInformation.java


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