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


Java NoServerForRegionException类代码示例

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


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

示例1: getPcaps

import org.apache.hadoop.hbase.client.NoServerForRegionException; //导入依赖的package包/类
public byte[] getPcaps(String startKey, String endKey, long maxResultSize,
    long startTime, long endTime) throws IOException {
  Assert.hasText(startKey, "startKey must no be null or empty");
  byte[] cf = Bytes.toBytes(ConfigurationUtil.getConfiguration()
      .getString("hbase.table.column.family"));
  byte[] cq = Bytes.toBytes(ConfigurationUtil.getConfiguration()
      .getString("hbase.table.column.qualifier"));
  // create scan request
  Scan scan = createScanRequest(cf, cq, startKey, endKey, maxResultSize,
      startTime, endTime);
  List<byte[]> pcaps = new ArrayList<byte[]>();
  HTable table = null;
  try {
    pcaps = scanPcaps(pcaps, table, scan, cf, cq);
  } catch (IOException e) {
    LOGGER.error(
        "Exception occurred while fetching Pcaps for the key range : startKey="
            + startKey + ", endKey=" + endKey, e);
    if (e instanceof ZooKeeperConnectionException
        || e instanceof MasterNotRunningException
        || e instanceof NoServerForRegionException) {
      int maxRetryLimit = getConnectionRetryLimit();
      for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
        try {
          HBaseConfigurationUtil.closeConnection(); // closing the existing
                                                    // connection and retry,
                                                    // it will create a new
                                                    // HConnection
          pcaps = scanPcaps(pcaps, table, scan, cf, cq);
          break;
        } catch (IOException ie) {
          if (attempt == maxRetryLimit) {
            System.out.println("Throwing the exception after retrying "
                + maxRetryLimit + " times.");
            throw e;
          }
        }
      }
    } else {
      throw e;
    }
  } finally {
    if (table != null) {
      table.close();
    }
  }
  if (pcaps.size() == 1) {
    return pcaps.get(0);
  }
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  PcapMerger.merge(baos, pcaps);
  byte[] response = baos.toByteArray();
  return response;
}
 
开发者ID:OpenSOC,项目名称:opensoc-streaming,代码行数:55,代码来源:PcapScannerHBaseImpl.java


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