use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.
the class HBaseAdmin method split.
@VisibleForTesting
public void split(final ServerName sn, final HRegionInfo hri, byte[] splitPoint) throws IOException {
if (hri.getStartKey() != null && splitPoint != null && Bytes.compareTo(hri.getStartKey(), splitPoint) == 0) {
throw new IOException("should not give a splitkey which equals to startkey!");
}
// TODO: There is no timeout on this controller. Set one!
HBaseRpcController controller = rpcControllerFactory.newController();
controller.setPriority(hri.getTable());
// TODO: this does not do retries, it should. Set priority and timeout in controller
AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
ProtobufUtil.split(controller, admin, hri, splitPoint);
}
use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.
the class HBaseAdmin method closeRegionWithEncodedRegionName.
@Override
public boolean closeRegionWithEncodedRegionName(final String encodedRegionName, final String serverName) throws IOException {
if (null == serverName || ("").equals(serverName.trim())) {
throw new IllegalArgumentException("The servername cannot be null or empty.");
}
ServerName sn = ServerName.valueOf(serverName);
AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
// Close the region without updating zk state.
CloseRegionRequest request = ProtobufUtil.buildCloseRegionRequest(sn, encodedRegionName);
// TODO: There is no timeout on this controller. Set one!
HBaseRpcController controller = this.rpcControllerFactory.newController();
try {
CloseRegionResponse response = admin.closeRegion(controller, request);
boolean closed = response.getClosed();
if (false == closed) {
LOG.error("Not able to close the region " + encodedRegionName + ".");
}
return closed;
} catch (Exception e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.
the class HBaseAdmin method flushRegion.
@Override
public void flushRegion(final byte[] regionName) throws IOException {
Pair<HRegionInfo, ServerName> regionServerPair = getRegion(regionName);
if (regionServerPair == null) {
throw new IllegalArgumentException("Unknown regionname: " + Bytes.toStringBinary(regionName));
}
if (regionServerPair.getSecond() == null) {
throw new NoServerForRegionException(Bytes.toStringBinary(regionName));
}
final HRegionInfo hRegionInfo = regionServerPair.getFirst();
ServerName serverName = regionServerPair.getSecond();
final AdminService.BlockingInterface admin = this.connection.getAdmin(serverName);
Callable<Void> callable = new Callable<Void>() {
@Override
public Void call() throws Exception {
// TODO: There is no timeout on this controller. Set one!
HBaseRpcController controller = rpcControllerFactory.newController();
FlushRegionRequest request = RequestConverter.buildFlushRegionRequest(hRegionInfo.getRegionName());
admin.flushRegion(controller, request);
return null;
}
};
ProtobufUtil.call(callable);
}
use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.
the class HBaseAdmin method rollWALWriterImpl.
private RollWALWriterResponse rollWALWriterImpl(final ServerName sn) throws IOException, FailedLogCloseException {
final AdminService.BlockingInterface admin = this.connection.getAdmin(sn);
RollWALWriterRequest request = RequestConverter.buildRollWALWriterRequest();
// TODO: There is no timeout on this controller. Set one!
HBaseRpcController controller = rpcControllerFactory.newController();
try {
return admin.rollWALWriter(controller, request);
} catch (ServiceException e) {
throw ProtobufUtil.handleRemoteException(e);
}
}
use of org.apache.hadoop.hbase.ipc.HBaseRpcController in project hbase by apache.
the class TestHCM method testCallableSleep.
@Test
public void testCallableSleep() throws Exception {
long pauseTime;
long baseTime = 100;
final TableName tableName = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(tableName, FAM_NAM);
ClientServiceCallable<Object> regionServerCallable = new ClientServiceCallable<Object>(TEST_UTIL.getConnection(), tableName, ROW, new RpcControllerFactory(TEST_UTIL.getConfiguration()).newController()) {
@Override
protected Object rpcCall() throws Exception {
return null;
}
};
regionServerCallable.prepare(false);
for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
pauseTime = regionServerCallable.sleep(baseTime, i);
assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
}
RegionAdminServiceCallable<Object> regionAdminServiceCallable = new RegionAdminServiceCallable<Object>((ClusterConnection) TEST_UTIL.getConnection(), new RpcControllerFactory(TEST_UTIL.getConfiguration()), tableName, ROW) {
@Override
public Object call(HBaseRpcController controller) throws Exception {
return null;
}
};
regionAdminServiceCallable.prepare(false);
for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
pauseTime = regionAdminServiceCallable.sleep(baseTime, i);
assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
}
MasterCallable<Object> masterCallable = new MasterCallable<Object>(TEST_UTIL.getConnection(), new RpcControllerFactory(TEST_UTIL.getConfiguration())) {
@Override
protected Object rpcCall() throws Exception {
return null;
}
};
try {
for (int i = 0; i < HConstants.RETRY_BACKOFF.length; i++) {
pauseTime = masterCallable.sleep(baseTime, i);
assertTrue(pauseTime >= (baseTime * HConstants.RETRY_BACKOFF[i]));
assertTrue(pauseTime <= (baseTime * HConstants.RETRY_BACKOFF[i] * 1.01f));
}
} finally {
masterCallable.close();
}
}
Aggregations