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


Java RetryCounter.useRetry方法代码示例

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


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

示例1: exists

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * exists is an idempotent operation. Retry before throwing exception
 * @return A Stat instance
 */
public Stat exists(String path, Watcher watcher)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.exists(path, watcher);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "exists");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:RecoverableZooKeeper.java

示例2: getChildren

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * getChildren is an idempotent operation. Retry before throwing exception
 * @return List of children znodes
 */
public List<String> getChildren(String path, Watcher watcher)
  throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.getChildren(path, watcher);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "getChildren");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:RecoverableZooKeeper.java

示例3: getData

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * getData is an idempotent operation. Retry before throwing exception
 * @return Data
 */
public byte[] getData(String path, Watcher watcher, Stat stat)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      byte[] revData = zk.getData(path, watcher, stat);       
      return this.removeMetaData(revData);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "getData");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:28,代码来源:RecoverableZooKeeper.java

示例4: multi

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * Run multiple operations in a transactional manner. Retry before throwing exception
 */
public List<OpResult> multi(Iterable<Op> ops)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  Iterable<Op> multiOps = prepareZKMulti(ops);
  while (true) {
    try {
      return zk.multi(multiOps);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "multi");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:27,代码来源:RecoverableZooKeeper.java

示例5: exists

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * exists is an idempotent operation. Retry before throwing exception
 * @return A Stat instance
 */
public Stat exists(String path, boolean watch)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.exists(path, watch);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "exists");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:Huawei-Hadoop,项目名称:hindex,代码行数:27,代码来源:RecoverableZooKeeper.java

示例6: getChildren

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * getChildren is an idempotent operation. Retry before throwing exception
 * @return List of children znodes
 */
public List<String> getChildren(String path, boolean watch)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.getChildren(path, watch);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "getChildren");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:daidong,项目名称:DominoHBase,代码行数:27,代码来源:RecoverableZooKeeper.java

示例7: delete

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * delete is an idempotent operation. Retry before throwing exception.
 * This function will not throw NoNodeException if the path does not
 * exist.
 */
public void delete(String path, int version)
throws InterruptedException, KeeperException {
  RetryCounter retryCounter = retryCounterFactory.create();
  boolean isRetry = false; // False for first attempt, true for all retries.
  while (true) {
    try {
      zk.delete(path, version);
      return;
    } catch (KeeperException e) {
      switch (e.code()) {
        case NONODE:
          if (isRetry) {
            LOG.info("Node " + path + " already deleted. Assuming that a " +
                "previous attempt succeeded.");
            return;
          }
          LOG.warn("Node " + path + " already deleted, and this is not a " +
                   "retry");
          throw e;

        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "delete");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
    isRetry = true;
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:41,代码来源:RecoverableZooKeeper.java

示例8: setData

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * setData is NOT an idempotent operation. Retry may cause BadVersion Exception
 * Adding an identifier field into the data to check whether 
 * badversion is caused by the result of previous correctly setData
 * @return Stat instance
 */
public Stat setData(String path, byte[] data, int version)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  byte[] newData = appendMetaData(data);
  while (true) {
    try {
      return zk.setData(path, newData, version);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "setData");
          break;
        case BADVERSION:
          // try to verify whether the previous setData success or not
          try{
            Stat stat = new Stat();
            byte[] revData = zk.getData(path, false, stat);
            if (Bytes.equals(revData, newData)) {
              // the bad version is caused by previous successful setData
              return stat;
            }
          } catch(KeeperException keeperException){
            // the ZK is not reliable at this moment. just throwing exception
            throw keeperException;
          }            
        
        // throw other exceptions and verified bad version exceptions
        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:44,代码来源:RecoverableZooKeeper.java

示例9: createSequential

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
private String createSequential(String path, byte[] data, 
    List<ACL> acl, CreateMode createMode)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  boolean first = true;
  String newPath = path+this.identifier;
  while (true) {
    try {
      if (!first) {
        // Check if we succeeded on a previous attempt
        String previousResult = findPreviousSequentialNode(newPath);
        if (previousResult != null) {
          return previousResult;
        }
      }
      first = false;
      return zk.create(newPath, data, acl, createMode);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "create");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:34,代码来源:RecoverableZooKeeper.java

示例10: createSequential

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
private String createSequential(String path, byte[] data, 
    List<ACL> acl, CreateMode createMode)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  boolean first = true;
  String newPath = path+this.identifier;
  while (true) {
    try {
      if (!first) {
        // Check if we succeeded on a previous attempt
        String previousResult = findPreviousSequentialNode(newPath);
        if (previousResult != null) {
          return previousResult;
        }
      }
      first = false;
      return zk.create(newPath, data, acl, createMode);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case OPERATIONTIMEOUT:
          LOG.warn("Possibly transient ZooKeeper exception: " + e);
          if (!retryCounter.shouldRetry()) {
            LOG.error("ZooKeeper create failed after "
              + retryCounter.getMaxRetries() + " retries");
            throw e;
          }
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:38,代码来源:RecoverableZooKeeper.java

示例11: delete

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * delete is an idempotent operation. Retry before throw out exception.
 * This function will not throw out NoNodeException if the path is not existed
 * @param path
 * @param version
 * @throws InterruptedException
 * @throws KeeperException
 */
public void delete(String path, int version)
throws InterruptedException, KeeperException {
  RetryCounter retryCounter = retryCounterFactory.create();
  boolean isRetry = false; // False for first attempt, true for all retries.
  while (true) {
    try {
      zk.delete(path, version);
      return;
    } catch (KeeperException e) {
      switch (e.code()) {
        case NONODE:
          if (isRetry) {
            LOG.info("Node " + path + " already deleted. Assuming that a " +
                "previous attempt succeeded.");
            return;
          }
          LOG.warn("Node " + path + " already deleted, and this is not a " +
                   "retry");
          throw e;

        case CONNECTIONLOSS:
        case OPERATIONTIMEOUT:
          LOG.warn("Possibly transient ZooKeeper exception: " + e);
          if (!retryCounter.shouldRetry()) {
            LOG.error("ZooKeeper delete failed after "
              + retryCounter.getMaxRetries() + " retries");
            throw e;
          }
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
    isRetry = true;
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:48,代码来源:RecoverableZooKeeper.java

示例12: exists

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * exists is an idempotent operation. Retry before throw out exception
 * @param path
 * @param watcher
 * @return A Stat instance
 * @throws KeeperException
 * @throws InterruptedException
 */
public Stat exists(String path, Watcher watcher)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.exists(path, watcher);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case OPERATIONTIMEOUT:
          LOG.warn("Possibly transient ZooKeeper exception: " + e);
          if (!retryCounter.shouldRetry()) {
            LOG.error("ZooKeeper exists failed after "
              + retryCounter.getMaxRetries() + " retries");
            throw e;
          }
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:35,代码来源:RecoverableZooKeeper.java

示例13: getChildren

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * getChildren is an idempotent operation. Retry before throw out exception
 * @param path
 * @param watcher
 * @return List of children znodes
 * @throws KeeperException
 * @throws InterruptedException
 */
public List<String> getChildren(String path, Watcher watcher)
  throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      return zk.getChildren(path, watcher);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case OPERATIONTIMEOUT:
          LOG.warn("Possibly transient ZooKeeper exception: " + e);
          if (!retryCounter.shouldRetry()) {
            LOG.error("ZooKeeper getChildren failed after "
              + retryCounter.getMaxRetries() + " retries");
            throw e;
          }
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:35,代码来源:RecoverableZooKeeper.java

示例14: getData

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
/**
 * getData is an idempotent operation. Retry before throw out exception
 * @param path
 * @param watcher
 * @param stat
 * @return Data
 * @throws KeeperException
 * @throws InterruptedException
 */
public byte[] getData(String path, Watcher watcher, Stat stat)
throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  while (true) {
    try {
      byte[] revData = zk.getData(path, watcher, stat);       
      return this.removeMetaData(revData);
    } catch (KeeperException e) {
      switch (e.code()) {
        case CONNECTIONLOSS:
        case OPERATIONTIMEOUT:
          LOG.warn("Possibly transient ZooKeeper exception: " + e);
          if (!retryCounter.shouldRetry()) {
            LOG.error("ZooKeeper getData failed after "
              + retryCounter.getMaxRetries() + " retries");
            throw e;
          }
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
  }
}
 
开发者ID:lifeng5042,项目名称:RStore,代码行数:37,代码来源:RecoverableZooKeeper.java

示例15: createNonSequential

import org.apache.hadoop.hbase.util.RetryCounter; //导入方法依赖的package包/类
private String createNonSequential(String path, byte[] data, List<ACL> acl, 
    CreateMode createMode) throws KeeperException, InterruptedException {
  RetryCounter retryCounter = retryCounterFactory.create();
  boolean isRetry = false; // False for first attempt, true for all retries.
  while (true) {
    try {
      return zk.create(path, data, acl, createMode);
    } catch (KeeperException e) {
      switch (e.code()) {
        case NODEEXISTS:
          if (isRetry) {
            // If the connection was lost, there is still a possibility that
            // we have successfully created the node at our previous attempt,
            // so we read the node and compare. 
            byte[] currentData = zk.getData(path, false, null);
            if (currentData != null &&
                Bytes.compareTo(currentData, data) == 0) { 
              // We successfully created a non-sequential node
              return path;
            }
            LOG.error("Node " + path + " already exists with " + 
                Bytes.toStringBinary(currentData) + ", could not write " +
                Bytes.toStringBinary(data));
            throw e;
          }
          LOG.info("Node " + path + " already exists and this is not a " +
              "retry");
          throw e;

        case CONNECTIONLOSS:
        case SESSIONEXPIRED:
        case OPERATIONTIMEOUT:
          retryOrThrow(retryCounter, e, "create");
          break;

        default:
          throw e;
      }
    }
    retryCounter.sleepUntilNextRetry();
    retryCounter.useRetry();
    isRetry = true;
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:45,代码来源:RecoverableZooKeeper.java


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