Search in sources :

Example 1 with ProcessRequest

use of org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest in project hbase by apache.

the class TestRowProcessorEndpoint method testTimeout.

@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);
}
Also used : RowProcessorService(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) ProcessRequest(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest) IOException(java.io.IOException) Test(org.junit.Test)

Example 2 with ProcessRequest

use of org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest in project hbase by apache.

the class TestRowProcessorEndpoint method swapRows.

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);
}
Also used : RowProcessorService(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) ProcessRequest(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest)

Example 3 with ProcessRequest

use of org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest in project hbase by apache.

the class TestRowProcessorEndpoint method incrementCounter.

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;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RowProcessorService(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService) CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) ProcessRequest(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest) IncCounterProcessorResponse(org.apache.hadoop.hbase.coprocessor.protobuf.generated.IncrementCounterProcessorTestProtos.IncCounterProcessorResponse) ProcessResponse(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessResponse)

Example 4 with ProcessRequest

use of org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest in project hbase by apache.

the class TestRowProcessorEndpoint method testDoubleScan.

@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);
}
Also used : CoprocessorRpcChannel(org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel) ProcessRequest(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest) FriendsOfFriendsProcessorResponse(org.apache.hadoop.hbase.coprocessor.protobuf.generated.IncrementCounterProcessorTestProtos.FriendsOfFriendsProcessorResponse) ProcessResponse(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessResponse) RowProcessorService(org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService) Get(org.apache.hadoop.hbase.client.Get) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

CoprocessorRpcChannel (org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel)4 ProcessRequest (org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessRequest)4 RowProcessorService (org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.RowProcessorService)4 ProcessResponse (org.apache.hadoop.hbase.protobuf.generated.RowProcessorProtos.ProcessResponse)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Get (org.apache.hadoop.hbase.client.Get)1 FriendsOfFriendsProcessorResponse (org.apache.hadoop.hbase.coprocessor.protobuf.generated.IncrementCounterProcessorTestProtos.FriendsOfFriendsProcessorResponse)1 IncCounterProcessorResponse (org.apache.hadoop.hbase.coprocessor.protobuf.generated.IncrementCounterProcessorTestProtos.IncCounterProcessorResponse)1