Java源码示例:org.apache.hadoop.hbase.client.NoServerForRegionException
示例1
@Override
public boolean canInfinitelyRetry(Throwable t){
t=Throwables.getRootCause(t);
t=processPipelineException(t);
if(t instanceof NotServingPartitionException
|| t instanceof NoServerForRegionException
|| t instanceof WrongPartitionException
|| t instanceof PipelineTooBusy
|| t instanceof RegionBusyException
|| t instanceof NoRouteToHostException
|| t instanceof org.apache.hadoop.hbase.ipc.FailedServerException
|| t instanceof FailedServerException
|| t instanceof ServerNotRunningYetException
|| t instanceof ConnectTimeoutException
|| t instanceof IndexNotSetUpException) return true;
return false;
}
示例2
private boolean clearCacheIfNeeded(Throwable e) throws IOException{
if (e==null ||
e instanceof WrongPartitionException ||
e instanceof NotServingRegionException ||
e instanceof NotServingPartitionException ||
e instanceof ConnectException ||
e instanceof ConnectionClosingException ||
e instanceof NoServerForRegionException ||
isFailedServerException(e)) {
/*
* We sent it to the wrong place, so we need to resubmit it. But since we
* pulled it from the cache, we first invalidate that cache
*/
partitionInfoCache.invalidate(this.tableName);
partitionInfoCache.invalidateAdapter(this.tableName);
return true;
}
return false;
}
示例3
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;
}
示例4
/**
* Process key.
*
* @param pcapsResponse
* the pcaps response
* @param key
* the key
* @param startTime
* the start time
* @param endTime
* the end time
* @param isPartialResponse
* the is partial response
* @param includeDuplicateLastRow
* the include duplicate last row
* @param maxResultSize
* the max result size
* @return the pcaps response
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@VisibleForTesting
PcapsResponse processKey(PcapsResponse pcapsResponse, String key,
long startTime, long endTime, boolean isPartialResponse,
boolean includeDuplicateLastRow, long maxResultSize) throws IOException {
HTable table = null;
Scan scan = null;
List<Cell> scannedCells = null;
try {
// 1. Create start and stop row for the key;
Map<String, String> keysMap = createStartAndStopRowKeys(key,
isPartialResponse, includeDuplicateLastRow);
// 2. if the input key contains all fragments (7) and it is not part
// of previous partial response (isPartialResponse),
// 'keysMap' will be null; do a Get; currently not doing any
// response size related checks for Get;
// by default all cells from a specific row are sorted by timestamp
if (keysMap == null) {
Get get = createGetRequest(key, startTime, endTime);
List<Cell> cells = executeGetRequest(table, get);
for (Cell cell : cells) {
pcapsResponse.addPcaps(CellUtil.cloneValue(cell));
}
return pcapsResponse;
}
// 3. Create and execute Scan request
scan = createScanRequest(pcapsResponse, keysMap, startTime, endTime,
maxResultSize);
scannedCells = executeScanRequest(table, scan);
LOGGER.info("scannedCells size :" + scannedCells.size());
addToResponse(pcapsResponse, scannedCells, maxResultSize);
} catch (IOException e) {
LOGGER.error("Exception occurred while fetching Pcaps for the keys :"
+ key, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = ConfigurationUtil.getConnectionRetryLimit();
System.out.println("maxRetryLimit =" + maxRetryLimit);
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
System.out.println("attempting =" + attempt);
try {
HBaseConfigurationUtil.closeConnection(); // closing the
// existing
// connection
// and retry,
// it will
// create a new
// HConnection
scannedCells = executeScanRequest(table, scan);
addToResponse(pcapsResponse, scannedCells, maxResultSize);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
LOGGER.error("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
}
} finally {
if (table != null) {
table.close();
}
}
return pcapsResponse;
}
示例5
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;
}
示例6
/**
* Process key.
*
* @param pcapsResponse
* the pcaps response
* @param key
* the key
* @param startTime
* the start time
* @param endTime
* the end time
* @param isPartialResponse
* the is partial response
* @param includeDuplicateLastRow
* the include duplicate last row
* @param maxResultSize
* the max result size
* @return the pcaps response
* @throws IOException
* Signals that an I/O exception has occurred.
*/
@VisibleForTesting
PcapsResponse processKey(PcapsResponse pcapsResponse, String key,
long startTime, long endTime, boolean isPartialResponse,
boolean includeDuplicateLastRow, long maxResultSize) throws IOException {
HTable table = null;
Scan scan = null;
List<Cell> scannedCells = null;
try {
// 1. Create start and stop row for the key;
Map<String, String> keysMap = createStartAndStopRowKeys(key,
isPartialResponse, includeDuplicateLastRow);
// 2. if the input key contains all fragments (7) and it is not part
// of previous partial response (isPartialResponse),
// 'keysMap' will be null; do a Get; currently not doing any
// response size related checks for Get;
// by default all cells from a specific row are sorted by timestamp
if (keysMap == null) {
Get get = createGetRequest(key, startTime, endTime);
List<Cell> cells = executeGetRequest(table, get);
for (Cell cell : cells) {
pcapsResponse.addPcaps(CellUtil.cloneValue(cell));
}
return pcapsResponse;
}
// 3. Create and execute Scan request
scan = createScanRequest(pcapsResponse, keysMap, startTime, endTime,
maxResultSize);
scannedCells = executeScanRequest(table, scan);
LOGGER.info("scannedCells size :" + scannedCells.size());
addToResponse(pcapsResponse, scannedCells, maxResultSize);
} catch (IOException e) {
LOGGER.error("Exception occurred while fetching Pcaps for the keys :"
+ key, e);
if (e instanceof ZooKeeperConnectionException
|| e instanceof MasterNotRunningException
|| e instanceof NoServerForRegionException) {
int maxRetryLimit = ConfigurationUtil.getConnectionRetryLimit();
System.out.println("maxRetryLimit =" + maxRetryLimit);
for (int attempt = 1; attempt <= maxRetryLimit; attempt++) {
System.out.println("attempting =" + attempt);
try {
HBaseConfigurationUtil.closeConnection(); // closing the
// existing
// connection
// and retry,
// it will
// create a new
// HConnection
scannedCells = executeScanRequest(table, scan);
addToResponse(pcapsResponse, scannedCells, maxResultSize);
break;
} catch (IOException ie) {
if (attempt == maxRetryLimit) {
LOGGER.error("Throwing the exception after retrying "
+ maxRetryLimit + " times.");
throw e;
}
}
}
}
} finally {
if (table != null) {
table.close();
}
}
return pcapsResponse;
}