Java 类org.apache.hadoop.hbase.client.NoServerForRegionException 实例源码
项目:opensoc-streaming
文件:PcapScannerHBaseImpl.java
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;
}
项目:opensoc-streaming
文件:PcapScannerHBaseImpl.java
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;
}