Search in sources :

Example 16 with CoprocessorRpcChannel

use of org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel in project hbase by apache.

the class SecureBulkLoadEndpointClient method cleanupBulkLoad.

public void cleanupBulkLoad(final String bulkToken) throws IOException {
    try {
        CoprocessorRpcChannel channel = table.coprocessorService(HConstants.EMPTY_START_ROW);
        SecureBulkLoadProtos.SecureBulkLoadService instance = ProtobufUtil.newServiceStub(SecureBulkLoadProtos.SecureBulkLoadService.class, channel);
        ServerRpcController controller = new ServerRpcController();
        CoprocessorRpcUtils.BlockingRpcCallback<CleanupBulkLoadResponse> rpcCallback = new CoprocessorRpcUtils.BlockingRpcCallback<>();
        CleanupBulkLoadRequest request = CleanupBulkLoadRequest.newBuilder().setBulkToken(bulkToken).build();
        instance.cleanupBulkLoad(controller, request, rpcCallback);
        if (controller.failedOnException()) {
            throw controller.getFailedOn();
        }
    } catch (Throwable throwable) {
        throw new IOException(throwable);
    }
}
Also used : CoprocessorRpcUtils(org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils) CleanupBulkLoadRequest(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CleanupBulkLoadRequest) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) IOException(java.io.IOException) ServerRpcController(org.apache.hadoop.hbase.ipc.ServerRpcController) CleanupBulkLoadResponse(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.CleanupBulkLoadResponse) SecureBulkLoadProtos(org.apache.hadoop.hbase.protobuf.generated.SecureBulkLoadProtos)

Example 17 with CoprocessorRpcChannel

use of org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel in project hbase by apache.

the class TestCoprocessorEndpoint method testCoprocessorError.

@Test
public void testCoprocessorError() throws Exception {
    Configuration configuration = new Configuration(util.getConfiguration());
    // Make it not retry forever
    configuration.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 1);
    Table table = util.getConnection().getTable(TEST_TABLE);
    try {
        CoprocessorRpcChannel protocol = table.coprocessorService(ROWS[0]);
        TestRpcServiceProtos.TestProtobufRpcProto.BlockingInterface service = TestRpcServiceProtos.TestProtobufRpcProto.newBlockingStub(protocol);
        service.error(null, TestProtos.EmptyRequestProto.getDefaultInstance());
        fail("Should have thrown an exception");
    } catch (ServiceException e) {
    } finally {
        table.close();
    }
}
Also used : Table(org.apache.hadoop.hbase.client.Table) Configuration(org.apache.hadoop.conf.Configuration) ServiceException(com.google.protobuf.ServiceException) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) Test(org.junit.Test)

Example 18 with CoprocessorRpcChannel

use of org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel in project hbase by apache.

the class TokenUtil method obtainToken.

/**
   * Obtain and return an authentication token for the current user.
   * @param conn The HBase cluster connection
   * @return the authentication token instance
   */
public static Token<AuthenticationTokenIdentifier> obtainToken(Connection conn) throws IOException {
    Table meta = null;
    try {
        meta = conn.getTable(TableName.META_TABLE_NAME);
        CoprocessorRpcChannel rpcChannel = meta.coprocessorService(HConstants.EMPTY_START_ROW);
        AuthenticationProtos.AuthenticationService.BlockingInterface service = AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel);
        AuthenticationProtos.GetAuthenticationTokenResponse response = service.getAuthenticationToken(null, AuthenticationProtos.GetAuthenticationTokenRequest.getDefaultInstance());
        return toToken(response.getToken());
    } catch (ServiceException se) {
        ProtobufUtil.handleRemoteException(se);
    } finally {
        if (meta != null) {
            meta.close();
        }
    }
    // dummy return for ServiceException block
    return null;
}
Also used : Table(org.apache.hadoop.hbase.client.Table) ServiceException(com.google.protobuf.ServiceException) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) AuthenticationProtos(org.apache.hadoop.hbase.protobuf.generated.AuthenticationProtos)

Aggregations

CoprocessorRpcChannel (org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel)18 ServiceException (com.google.protobuf.ServiceException)5 Table (org.apache.hadoop.hbase.client.Table)5 Test (org.junit.Test)5 IOException (java.io.IOException)4 Mutation (org.apache.hadoop.hbase.client.Mutation)4 MutateRowsRequest (org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest)4 ProcessRequest (org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest)4 RowProcessorService (org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService)4 Put (org.apache.hadoop.hbase.client.Put)3 CoprocessorRpcUtils (org.apache.hadoop.hbase.ipc.CoprocessorRpcUtils)3 ServerRpcController (org.apache.hadoop.hbase.ipc.ServerRpcController)3 MultiRowMutationService (org.apache.hadoop.hbase.protobuf.generated.MultiRowMutationProtos.MultiRowMutationService)3 SecureBulkLoadProtos (org.apache.hadoop.hbase.protobuf.generated.SecureBulkLoadProtos)3 ArrayList (java.util.ArrayList)2 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)2 TableName (org.apache.hadoop.hbase.TableName)2 Admin (org.apache.hadoop.hbase.client.Admin)2 Connection (org.apache.hadoop.hbase.client.Connection)2 Delete (org.apache.hadoop.hbase.client.Delete)2