use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class SecureBulkLoadClient method prepareBulkLoad.
public String prepareBulkLoad(final Connection conn) throws IOException {
try {
ClientServiceCallable<String> callable = new ClientServiceCallable<String>(conn, table.getName(), HConstants.EMPTY_START_ROW, this.rpcControllerFactory.newController()) {
@Override
protected String rpcCall() throws Exception {
byte[] regionName = getLocation().getRegionInfo().getRegionName();
RegionSpecifier region = RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
PrepareBulkLoadRequest request = PrepareBulkLoadRequest.newBuilder().setTableName(ProtobufUtil.toProtoTableName(table.getName())).setRegion(region).build();
PrepareBulkLoadResponse response = getStub().prepareBulkLoad(null, request);
return response.getBulkToken();
}
};
return RpcRetryingCallerFactory.instantiate(conn.getConfiguration(), null).<String>newCaller().callWithRetries(callable, Integer.MAX_VALUE);
} catch (Throwable throwable) {
throw new IOException(throwable);
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class SecureBulkLoadClient method cleanupBulkLoad.
public void cleanupBulkLoad(final Connection conn, final String bulkToken) throws IOException {
try {
ClientServiceCallable<Void> callable = new ClientServiceCallable<Void>(conn, table.getName(), HConstants.EMPTY_START_ROW, this.rpcControllerFactory.newController()) {
@Override
protected Void rpcCall() throws Exception {
byte[] regionName = getLocation().getRegionInfo().getRegionName();
RegionSpecifier region = RequestConverter.buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
CleanupBulkLoadRequest request = CleanupBulkLoadRequest.newBuilder().setRegion(region).setBulkToken(bulkToken).build();
getStub().cleanupBulkLoad(null, request);
return null;
}
};
RpcRetryingCallerFactory.instantiate(conn.getConfiguration(), null).<Void>newCaller().callWithRetries(callable, Integer.MAX_VALUE);
} catch (Throwable throwable) {
throw new IOException(throwable);
}
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class TestMetricsConnection method testStaticMetrics.
@Test
public void testStaticMetrics() throws IOException {
final byte[] foo = Bytes.toBytes("foo");
final RegionSpecifier region = RegionSpecifier.newBuilder().setValue(ByteString.EMPTY).setType(RegionSpecifierType.REGION_NAME).build();
final int loop = 5;
for (int i = 0; i < loop; i++) {
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Get"), GetRequest.getDefaultInstance(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Scan"), ScanRequest.getDefaultInstance(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Multi"), MultiRequest.getDefaultInstance(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), MutateRequest.newBuilder().setMutation(ProtobufUtil.toMutation(MutationType.APPEND, new Append(foo))).setRegion(region).build(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), MutateRequest.newBuilder().setMutation(ProtobufUtil.toMutation(MutationType.DELETE, new Delete(foo))).setRegion(region).build(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), MutateRequest.newBuilder().setMutation(ProtobufUtil.toMutation(MutationType.INCREMENT, new Increment(foo))).setRegion(region).build(), MetricsConnection.newCallStats());
METRICS.updateRpc(ClientService.getDescriptor().findMethodByName("Mutate"), MutateRequest.newBuilder().setMutation(ProtobufUtil.toMutation(MutationType.PUT, new Put(foo))).setRegion(region).build(), MetricsConnection.newCallStats());
}
for (MetricsConnection.CallTracker t : new MetricsConnection.CallTracker[] { METRICS.getTracker, METRICS.scanTracker, METRICS.multiTracker, METRICS.appendTracker, METRICS.deleteTracker, METRICS.incrementTracker, METRICS.putTracker }) {
assertEquals("Failed to invoke callTimer on " + t, loop, t.callTimer.getCount());
assertEquals("Failed to invoke reqHist on " + t, loop, t.reqHist.getCount());
assertEquals("Failed to invoke respHist on " + t, loop, t.respHist.getCount());
}
RatioGauge executorMetrics = (RatioGauge) METRICS.getMetricRegistry().getMetrics().get(METRICS.getExecutorPoolName());
RatioGauge metaMetrics = (RatioGauge) METRICS.getMetricRegistry().getMetrics().get(METRICS.getMetaPoolName());
assertEquals(Ratio.of(0, 3).getValue(), executorMetrics.getValue(), 0);
assertEquals(Double.NaN, metaMetrics.getValue(), 0);
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class RequestConverter method buildMutateRequest.
/**
* Create a protocol buffer MutateRequest for a delete
*
* @param regionName
* @param delete
* @return a mutate request
* @throws IOException
*/
public static MutateRequest buildMutateRequest(final byte[] regionName, final Delete delete) throws IOException {
MutateRequest.Builder builder = MutateRequest.newBuilder();
RegionSpecifier region = buildRegionSpecifier(RegionSpecifierType.REGION_NAME, regionName);
builder.setRegion(region);
builder.setMutation(ProtobufUtil.toMutation(MutationType.DELETE, delete, MutationProto.newBuilder()));
return builder.build();
}
use of org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier in project hbase by apache.
the class TestPriorityRpc method testQosFunctionForMeta.
@Test
public void testQosFunctionForMeta() throws IOException {
priority = regionServer.rpcServices.getPriority();
RequestHeader.Builder headerBuilder = RequestHeader.newBuilder();
//create a rpc request that has references to hbase:meta region and also
//uses one of the known argument classes (known argument classes are
//listed in HRegionServer.QosFunctionImpl.knownArgumentClasses)
headerBuilder.setMethodName("foo");
GetRequest.Builder getRequestBuilder = GetRequest.newBuilder();
RegionSpecifier.Builder regionSpecifierBuilder = RegionSpecifier.newBuilder();
regionSpecifierBuilder.setType(RegionSpecifierType.REGION_NAME);
ByteString name = UnsafeByteOperations.unsafeWrap(HRegionInfo.FIRST_META_REGIONINFO.getRegionName());
regionSpecifierBuilder.setValue(name);
RegionSpecifier regionSpecifier = regionSpecifierBuilder.build();
getRequestBuilder.setRegion(regionSpecifier);
Get.Builder getBuilder = Get.newBuilder();
getBuilder.setRow(UnsafeByteOperations.unsafeWrap("somerow".getBytes()));
getRequestBuilder.setGet(getBuilder.build());
GetRequest getRequest = getRequestBuilder.build();
RequestHeader header = headerBuilder.build();
HRegion mockRegion = Mockito.mock(HRegion.class);
HRegionServer mockRS = Mockito.mock(HRegionServer.class);
RSRpcServices mockRpc = Mockito.mock(RSRpcServices.class);
Mockito.when(mockRS.getRSRpcServices()).thenReturn(mockRpc);
HRegionInfo mockRegionInfo = Mockito.mock(HRegionInfo.class);
Mockito.when(mockRpc.getRegion((RegionSpecifier) Mockito.any())).thenReturn(mockRegion);
Mockito.when(mockRegion.getRegionInfo()).thenReturn(mockRegionInfo);
Mockito.when(mockRegionInfo.isSystemTable()).thenReturn(true);
// Presume type.
((AnnotationReadingPriorityFunction) priority).setRegionServer(mockRS);
assertEquals(HConstants.SYSTEMTABLE_QOS, priority.getPriority(header, getRequest, User.createUserForTesting(regionServer.conf, "someuser", new String[] { "somegroup" })));
}
Aggregations