@Override public void prepare(final boolean reload) throws IOException { // check table state if this is a retry if (reload && tableName != null && !tableName.equals(TableName.META_TABLE_NAME) && getConnection().isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } try (RegionLocator regionLocator = connection.getRegionLocator(tableName)) { this.location = regionLocator.getRegionLocation(row); } if (this.location == null) { throw new IOException("Failed to find location, tableName=" + tableName + ", row=" + Bytes.toString(row) + ", reload=" + reload); } setStubByServiceName(this.location.getServerName()); }
@Override public FastFailInterceptorContext prepare(RetryingCallable<?> callable, int tries) { if (callable instanceof RegionServerCallable) { RegionServerCallable<?, ?> retryingCallable = (RegionServerCallable<?, ?>) callable; server = retryingCallable.getLocation().getServerName(); } this.tries = tries; return this; } }
/** * Override that changes call Exception from {@link Exception} to {@link IOException}. * Also does set up of the rpcController. */ @Override public T call(int callTimeout) throws IOException { try { // Iff non-null and an instance of a SHADED rpcController, do config! Unshaded -- i.e. // com.google.protobuf.RpcController or null -- will just skip over this config. if (getRpcController() != null) { RpcController shadedRpcController = (RpcController)getRpcController(); // Do a reset to clear previous states, such as CellScanner. shadedRpcController.reset(); if (shadedRpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController)getRpcController(); // If it is an instance of HBaseRpcController, we can set priority on the controller based // off the tableName. Set call timeout too. hrc.setPriority(tableName); hrc.setPriority(priority); hrc.setCallTimeout(callTimeout); } } return rpcCall(); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public void throwable(Throwable t, boolean retrying) { if (location != null) { getConnection().updateCachedLocations(tableName, location.getRegionInfo().getRegionName(), row, t, location.getServerName()); } }
/** * Prepare for connection to the server hosting region with row from tablename. Does lookup * to find region location and hosting server. * @param reload Set this to true if connection should re-find the region * @throws IOException e */ @Override public void prepare(final boolean reload) throws IOException { try (RegionLocator regionLocator = connection.getRegionLocator(tableName)) { this.location = regionLocator.getRegionLocation(row, reload); } if (this.location == null) { throw new IOException("Failed to find location, tableName=" + tableName + ", row=" + Bytes.toString(row) + ", reload=" + reload); } setStub(getConnection().getClient(this.location.getServerName())); }
/** * Get the RpcController CellScanner. * If the RpcController is a HBaseRpcController, which it is in all cases except * when we are processing Coprocessor Endpoint, then this method returns a reference to the * CellScanner that the HBaseRpcController is carrying. Do it up here in this Callable * so we don't have to scatter ugly instanceof tests around the codebase. Will return null * if called in a Coproccessor Endpoint context. Should never happen. */ protected CellScanner getRpcControllerCellScanner() { return (getRpcController() != null && getRpcController() instanceof HBaseRpcController)? ((HBaseRpcController)getRpcController()).cellScanner(): null; }
} catch (IOException e) { LOG.error("Encountered unrecoverable error from region server, additional details: " + svrCallable.getExceptionMessageAdditionalDetail(), e); throw e;
@Override public void throwable(Throwable t, boolean retrying) { if (location != null) { getConnection().updateCachedLocations(tableName, location.getRegionInfo().getRegionName(), row, t, location.getServerName()); } }
protected void setRpcControllerCellScanner(CellScanner cellScanner) { if (getRpcController() != null && getRpcController() instanceof HBaseRpcController) { ((HBaseRpcController)this.rpcController).setCellScanner(cellScanner); } }
@Override public void prepare(final boolean reload) throws IOException { // check table state if this is a retry if (reload && tableName != null && !tableName.equals(TableName.META_TABLE_NAME) && getConnection().isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } try (RegionLocator regionLocator = connection.getRegionLocator(tableName)) { this.location = regionLocator.getRegionLocation(row); } if (this.location == null) { throw new IOException("Failed to find location, tableName=" + tableName + ", row=" + Bytes.toString(row) + ", reload=" + reload); } setStubByServiceName(this.location.getServerName()); }
@Override public void throwable(Throwable t, boolean retrying) { if (t instanceof SocketTimeoutException || t instanceof ConnectException || t instanceof RetriesExhaustedException || (location != null && getConnection().isDeadServer(location.getServerName()))) { // if thrown these exceptions, we clear all the cache entries that // map to that slow/dead server; otherwise, let cache miss and ask // hbase:meta again to find the new location if (this.location != null) getConnection().clearCaches(location.getServerName()); } else if (t instanceof RegionMovedException) { getConnection().updateCachedLocations(tableName, row, t, location); } else if (t instanceof NotServingRegionException && !retrying) { // Purge cache entries for this specific region from hbase:meta cache // since we don't call connect(true) when number of retries is 1. getConnection().deleteCachedRegionLocation(location); } }
/** * Override that changes call Exception from {@link Exception} to {@link IOException}. * Also does set up of the rpcController. */ @Override public T call(int callTimeout) throws IOException { try { // Iff non-null and an instance of a SHADED rpcController, do config! Unshaded -- i.e. // com.google.protobuf.RpcController or null -- will just skip over this config. if (getRpcController() != null) { RpcController shadedRpcController = (RpcController)getRpcController(); // Do a reset to clear previous states, such as CellScanner. shadedRpcController.reset(); if (shadedRpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController)getRpcController(); // If it is an instance of HBaseRpcController, we can set priority on the controller based // off the tableName. Set call timeout too. hrc.setPriority(tableName); hrc.setPriority(priority); hrc.setCallTimeout(callTimeout); } } return rpcCall(); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
@Override public FastFailInterceptorContext prepare(RetryingCallable<?> callable, int tries) { if (callable instanceof RegionServerCallable) { RegionServerCallable<?, ?> retryingCallable = (RegionServerCallable<?, ?>) callable; server = retryingCallable.getLocation().getServerName(); } this.tries = tries; return this; } }
/** * Get the RpcController CellScanner. * If the RpcController is a HBaseRpcController, which it is in all cases except * when we are processing Coprocessor Endpoint, then this method returns a reference to the * CellScanner that the HBaseRpcController is carrying. Do it up here in this Callable * so we don't have to scatter ugly instanceof tests around the codebase. Will return null * if called in a Coproccessor Endpoint context. Should never happen. */ protected CellScanner getRpcControllerCellScanner() { return (getRpcController() != null && getRpcController() instanceof HBaseRpcController)? ((HBaseRpcController)getRpcController()).cellScanner(): null; }
@Override public void prepare(final boolean reload) throws IOException { // check table state if this is a retry if (reload && tableName != null && !tableName.equals(TableName.META_TABLE_NAME) && getConnection().isTableDisabled(tableName)) { throw new TableNotEnabledException(tableName.getNameAsString() + " is disabled."); } try (RegionLocator regionLocator = connection.getRegionLocator(tableName)) { this.location = regionLocator.getRegionLocation(row); } if (this.location == null) { throw new IOException("Failed to find location, tableName=" + tableName + ", row=" + Bytes.toString(row) + ", reload=" + reload); } setStubByServiceName(this.location.getServerName()); }
@Override public void throwable(Throwable t, boolean retrying) { if (location != null) { getConnection().updateCachedLocations(tableName, location.getRegionInfo().getRegionName(), row, t, location.getServerName()); } }
/** * Override that changes call Exception from {@link Exception} to {@link IOException}. * Also does set up of the rpcController. */ @Override public T call(int callTimeout) throws IOException { try { // Iff non-null and an instance of a SHADED rpcController, do config! Unshaded -- i.e. // com.google.protobuf.RpcController or null -- will just skip over this config. if (getRpcController() != null) { RpcController shadedRpcController = (RpcController)getRpcController(); // Do a reset to clear previous states, such as CellScanner. shadedRpcController.reset(); if (shadedRpcController instanceof HBaseRpcController) { HBaseRpcController hrc = (HBaseRpcController)getRpcController(); // If it is an instance of HBaseRpcController, we can set priority on the controller based // off the tableName. Set call timeout too. hrc.setPriority(tableName); hrc.setPriority(priority); hrc.setCallTimeout(callTimeout); } } return rpcCall(); } catch (Exception e) { throw ProtobufUtil.handleRemoteException(e); } }
public FastFailInterceptorContext prepare(RetryingCallable<?> callable, int tries) { if (callable instanceof RegionServerCallable) { RegionServerCallable<?> retryingCallable = (RegionServerCallable<?>) callable; server = retryingCallable.getLocation().getServerName(); } this.tries = tries; return this; } }