类org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel源码实例Demo

下面列出了怎么用org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: phoenix   文件: StatisticsWriter.java
public void commitStats(List<Mutation> mutations) throws IOException {
    if (mutations.size() > 0) {
        byte[] row = mutations.get(0).getRow();
        MutateRowsRequest.Builder mrmBuilder = MutateRowsRequest.newBuilder();
        for (Mutation m : mutations) {
            mrmBuilder.addMutationRequest(ProtobufUtil.toMutation(getMutationType(m), m));
        }
        MutateRowsRequest mrm = mrmBuilder.build();
        CoprocessorRpcChannel channel = statsWriterTable.coprocessorService(row);
        MultiRowMutationService.BlockingInterface service =
                MultiRowMutationService.newBlockingStub(channel);
        try {
          service.mutateRows(null, mrm);
        } catch (ServiceException ex) {
          ProtobufUtil.toIOException(ex);
        }
    }
}
 
源代码2 项目: hbase   文件: TestRowProcessorEndpoint.java
@Test
public void testDoubleScan() throws Throwable {
  prepareTestData();

  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.FriendsOfFriendsProcessor processor =
      new RowProcessorEndpoint.FriendsOfFriendsProcessor(ROW, A);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  ProcessResponse protoResult = service.process(null, request);
  FriendsOfFriendsProcessorResponse response =
      FriendsOfFriendsProcessorResponse.parseFrom(protoResult.getRowProcessorResult());
  Set<String> result = new HashSet<>();
  result.addAll(response.getResultList());
  Set<String> expected = new HashSet<>(Arrays.asList(new String[]{"d", "e", "f", "g"}));
  Get get = new Get(ROW);
  LOG.debug("row keyvalues:" + stringifyKvs(table.get(get).listCells()));
  assertEquals(expected, result);
}
 
源代码3 项目: hbase   文件: TestRowProcessorEndpoint.java
@Test
public void testTimeout() throws Throwable {
  prepareTestData();
  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.TimeoutProcessor processor =
      new RowProcessorEndpoint.TimeoutProcessor(ROW);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  boolean exceptionCaught = false;
  try {
    service.process(null, request);
  } catch (Exception e) {
    exceptionCaught = true;
  }
  assertTrue(exceptionCaught);
}
 
源代码4 项目: hbase   文件: TestCoprocessorEndpoint.java
@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();
  }
}
 
源代码5 项目: hbase   文件: TestGenerateDelegationToken.java
@Test
public void test() throws Exception {
  try (Connection conn = ConnectionFactory.createConnection(TEST_UTIL.getConfiguration());
      Table table = conn.getTable(TableName.META_TABLE_NAME)) {
    CoprocessorRpcChannel rpcChannel = table.coprocessorService(HConstants.EMPTY_START_ROW);
    AuthenticationProtos.AuthenticationService.BlockingInterface service =
        AuthenticationProtos.AuthenticationService.newBlockingStub(rpcChannel);
    WhoAmIResponse response = service.whoAmI(null, WhoAmIRequest.getDefaultInstance());
    assertEquals(USERNAME, response.getUsername());
    assertEquals(AuthenticationMethod.TOKEN.name(), response.getAuthMethod());
    try {
      service.getAuthenticationToken(null, GetAuthenticationTokenRequest.getDefaultInstance());
    } catch (ServiceException e) {
      IOException ioe = ProtobufUtil.getRemoteException(e);
      assertThat(ioe, instanceOf(AccessDeniedException.class));
      assertThat(ioe.getMessage(),
        containsString("Token generation only allowed for Kerberos authenticated clients"));
    }
  }
}
 
源代码6 项目: hbase   文件: ClientTokenUtil.java
/**
 * Obtain and return an authentication token for the current user.
 * @param conn The HBase cluster connection
 * @throws IOException if a remote error or serialization problem occurs.
 * @return the authentication token instance
 */
@InterfaceAudience.Private
static Token<AuthenticationTokenIdentifier> obtainToken(
    Connection conn) throws IOException {
  Table meta = null;
  try {
    injectFault();

    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) {
    throw ProtobufUtil.handleRemoteException(se);
  } finally {
    if (meta != null) {
      meta.close();
    }
  }
}
 
源代码7 项目: phoenix   文件: StatisticsWriter.java
public void commitStats(final List<Mutation> mutations, final StatisticsCollector statsCollector)
        throws IOException {
    User.runAsLoginUser(new PrivilegedExceptionAction<Void>() {
        @Override
        public Void run() throws Exception {
            commitLastStatsUpdatedTime(statsCollector);
            if (mutations.size() > 0) {
                byte[] row = mutations.get(0).getRow();
                MutateRowsRequest.Builder mrmBuilder = MutateRowsRequest.newBuilder();
                for (Mutation m : mutations) {
                    mrmBuilder.addMutationRequest(ProtobufUtil.toMutation(getMutationType(m), m));
                }
                MutateRowsRequest mrm = mrmBuilder.build();
                CoprocessorRpcChannel channel = statsWriterTable.coprocessorService(row);
                MultiRowMutationService.BlockingInterface service = MultiRowMutationService
                        .newBlockingStub(channel);
                try {
                    service.mutateRows(null, mrm);
                } catch (ServiceException ex) {
                    ProtobufUtil.toIOException(ex);
                }
            }
            return null;
        }
    });
}
 
源代码8 项目: spliceengine   文件: GetWALPositionsTask.java
@Override
public Void call() throws Exception{
    SConfiguration configuration = HConfiguration.getConfiguration();
    Connection conn = HBaseConnectionFactory.getInstance(configuration).getConnection();
    Admin admin = conn.getAdmin();
    CoprocessorRpcChannel channel = admin.coprocessorService(serverName);
    SpliceRSRpcServices.BlockingInterface service = SpliceRSRpcServices.newBlockingStub(channel);
    SpliceMessage.GetWALPositionsRequest.Builder builder = SpliceMessage.GetWALPositionsRequest.newBuilder();

    SpliceMessage.GetWALPositionsResponse response = service.getWALPositions(null, builder.build());
    List<SpliceMessage.GetWALPositionsResponse.Result> resultList = response.getResultList();
    SortedMap<String, Long> serverSnapshot = new TreeMap<>();
    for (SpliceMessage.GetWALPositionsResponse.Result result : resultList) {
        serverSnapshot.put(result.getWALName(), result.getPosition());
    }
    map.put(serverName.getServerName(), serverSnapshot);
    return null;
}
 
源代码9 项目: hbase   文件: TestRowProcessorEndpoint.java
private int incrementCounter(Table table) throws Throwable {
  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.IncrementCounterProcessor processor =
      new RowProcessorEndpoint.IncrementCounterProcessor(ROW);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  ProcessResponse protoResult = service.process(null, request);
  IncCounterProcessorResponse response = IncCounterProcessorResponse
      .parseFrom(protoResult.getRowProcessorResult());
  Integer result = response.getResponse();
  return result;
}
 
源代码10 项目: hbase   文件: TestRowProcessorEndpoint.java
private void swapRows(Table table) throws Throwable {
  CoprocessorRpcChannel channel = table.coprocessorService(ROW);
  RowProcessorEndpoint.RowSwapProcessor processor =
      new RowProcessorEndpoint.RowSwapProcessor(ROW, ROW2);
  RowProcessorService.BlockingInterface service =
      RowProcessorService.newBlockingStub(channel);
  ProcessRequest request = RowProcessorClient.getRowProcessorPB(processor);
  service.process(null, request);
}
 
源代码11 项目: hbase   文件: TestFromClientSide5.java
@Test
public void testMultiRowMutation() throws Exception {
  LOG.info("Starting testMultiRowMutation");
  final TableName tableName = name.getTableName();
  final byte [] ROW1 = Bytes.toBytes("testRow1");

  try (Table t = TEST_UTIL.createTable(tableName, FAMILY)) {
    Put p = new Put(ROW);
    p.addColumn(FAMILY, QUALIFIER, VALUE);
    MutationProto m1 = ProtobufUtil.toMutation(MutationType.PUT, p);

    p = new Put(ROW1);
    p.addColumn(FAMILY, QUALIFIER, VALUE);
    MutationProto m2 = ProtobufUtil.toMutation(MutationType.PUT, p);

    MutateRowsRequest.Builder mrmBuilder = MutateRowsRequest.newBuilder();
    mrmBuilder.addMutationRequest(m1);
    mrmBuilder.addMutationRequest(m2);
    MutateRowsRequest mrm = mrmBuilder.build();
    CoprocessorRpcChannel channel = t.coprocessorService(ROW);
    MultiRowMutationService.BlockingInterface service =
            MultiRowMutationService.newBlockingStub(channel);
    service.mutateRows(null, mrm);
    Get g = new Get(ROW);
    Result r = t.get(g);
    assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIER)));
    g = new Get(ROW1);
    r = t.get(g);
    assertEquals(0, Bytes.compareTo(VALUE, r.getValue(FAMILY, QUALIFIER)));
  }
}
 
源代码12 项目: hbase   文件: AccessControlClient.java
private static BlockingInterface getAccessControlServiceStub(Table ht)
    throws IOException {
  CoprocessorRpcChannel service = ht.coprocessorService(HConstants.EMPTY_START_ROW);
  BlockingInterface protocol =
      AccessControlProtos.AccessControlService.newBlockingStub(service);
  return protocol;
}
 
源代码13 项目: spliceengine   文件: HBaseTxnNetworkLayer.java
@Override
protected TxnMessage.TxnLifecycleService getLifecycleService(byte[] rowKey) throws IOException{
    TxnMessage.TxnLifecycleService service;
    CoprocessorRpcChannel coprocessorRpcChannel = channelFactory.newRetryableChannel(table.getName(), rowKey);
    try{
        service=ProtobufUtil.newServiceStub(TxnMessage.TxnLifecycleService.class,coprocessorRpcChannel);
    }catch(Exception e){
        throw new IOException(e);
    }
    return service;
}
 
@Override
public Long call() throws Exception{
    SConfiguration configuration = HConfiguration.getConfiguration();
    Connection conn = HBaseConnectionFactory.getInstance(configuration).getConnection();
    Admin admin = conn.getAdmin();
    CoprocessorRpcChannel channel = admin.coprocessorService(serverName);
    SpliceRSRpcServices.BlockingInterface service = SpliceRSRpcServices.newBlockingStub(channel);
    SpliceMessage.SpliceOldestActiveTransactionRequest request = SpliceMessage.SpliceOldestActiveTransactionRequest.getDefaultInstance();
    SpliceMessage.SpliceOldestActiveTransactionResponse response = service.getOldestActiveTransaction(null, request);
    return response.getOldestActiveTransaction();
}
 
源代码15 项目: spliceengine   文件: BulkWriteChannelInvoker.java
public BulkWritesResult invoke(BulkWrites write) throws IOException {
    TableName tableName=tableInfoFactory.getTableInfo(this.tableName);
    CoprocessorRpcChannel channel = channelFactory.newChannel(tableName,write.getRegionKey());

    boolean cacheCheck = false;
    try {
        SpliceMessage.SpliceIndexService service = ProtobufUtil.newServiceStub(SpliceMessage.SpliceIndexService.class, channel);
        SpliceMessage.BulkWriteRequest.Builder builder = SpliceMessage.BulkWriteRequest.newBuilder();
        byte[] requestBytes = compressor.compress(write);
        builder.setBytes(ZeroCopyLiteralByteString.wrap(requestBytes));
        SpliceMessage.BulkWriteRequest bwr = builder.build();

        BlockingRpcCallback<SpliceMessage.BulkWriteResponse> doneCallback =new BlockingRpcCallback<>();
        ServerRpcController controller = new ServerRpcController();
        service.bulkWrite(controller, bwr, doneCallback);
        if (controller.failed()){
            IOException error=controller.getFailedOn();
            clearCacheIfNeeded(error);
            cacheCheck=true;
            if(error!=null)
                throw pef.processRemoteException(error);
            else
                throw pef.fromErrorString(controller.errorText());
        }
        SpliceMessage.BulkWriteResponse bulkWriteResponse = doneCallback.get();
        byte[] bytes = bulkWriteResponse.getBytes().toByteArray();
        if(bytes==null || bytes.length<=0){
            Logger logger=Logger.getLogger(BulkWriteChannelInvoker.class);
            logger.error("zero-length bytes returned with a null error for encodedString: "+write.getBulkWrites().iterator().next().getEncodedStringName());
        }

        return compressor.decompress(bytes,BulkWritesResult.class);
    } catch (Exception e) {
    	if (!cacheCheck) clearCacheIfNeeded(e);
        throw pef.processRemoteException(e);
    }
}
 
源代码16 项目: spliceengine   文件: HBaseTestUtils.java
private static boolean setBlock(final boolean onOff, CallType type) throws Throwable {
    org.apache.hadoop.hbase.client.Connection hbaseConnection = HBaseConnectionFactory.getInstance(HConfiguration.getConfiguration()).getConnection();
    Admin admin = hbaseConnection.getAdmin();
    ServerRpcController controller = new ServerRpcController();
    SpliceMessage.BlockingProbeRequest message = SpliceMessage.BlockingProbeRequest.newBuilder().setDoBlock(onOff).build();
    final AtomicBoolean success = new AtomicBoolean(true);
    Collection<ServerName> servers = admin.getClusterStatus().getServers();
    final CountDownLatch latch = new CountDownLatch(servers.size());
    for (ServerName server : servers) {
        CoprocessorRpcChannel channel = admin.coprocessorService(server);
        SpliceMessage.BlockingProbeEndpoint.Stub service = SpliceMessage.BlockingProbeEndpoint.newStub(channel);
        RpcCallback<SpliceMessage.BlockingProbeResponse> callback = new RpcCallback<SpliceMessage.BlockingProbeResponse>() {
            @Override
            public void run(SpliceMessage.BlockingProbeResponse response) {
                if (response.getDidBlock() != onOff) {
                    success.set(false);
                }
                latch.countDown();
            }
        };
        switch (type) {
            case POST_COMPACT: service.blockPostCompact(controller, message, callback); break;
            case PRE_COMPACT: service.blockPreCompact(controller, message, callback); break;
            case POST_FLUSH: service.blockPostFlush(controller, message, callback); break;
            case PRE_FLUSH: service.blockPreFlush(controller, message, callback); break;
            case POST_SPLIT: service.blockPostSplit(controller, message, callback); break;
            case PRE_SPLIT: service.blockPreSplit(controller, message, callback); break;
        }
    }
    if (!latch.await(10000, TimeUnit.SECONDS)){
        return false;
    }
    return success.get();
}
 
源代码17 项目: kylin-on-parquet-v2   文件: MockHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
    throw new NotImplementedException();

}
 
源代码18 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码19 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码20 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码21 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码22 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码23 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码24 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码25 项目: phoenix-tephra   文件: TransactionAwareHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  return hTable.coprocessorService(row);
}
 
源代码26 项目: hgraphdb   文件: MockHTable.java
/**
 * {@inheritDoc}
 */
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
    throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
 
源代码27 项目: simplified-lambda   文件: MockHTable.java
/**
 * {@inheritDoc}
 */
@Override
public CoprocessorRpcChannel coprocessorService(byte[] var1) {
    throw new RuntimeException(this.getClass() + " does NOT implement this method.");
}
 
源代码28 项目: metron   文件: MockHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] bytes) {
  throw new UnsupportedOperationException();
}
 
源代码29 项目: kylin   文件: MockHTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
    throw new NotImplementedException();

}
 
源代码30 项目: hbase   文件: ThriftTable.java
@Override
public CoprocessorRpcChannel coprocessorService(byte[] row) {
  throw new NotImplementedException("coprocessorService not supported in ThriftTable");
}
 
 类所在包
 同包方法