Search in sources :

Example 11 with DRPCRequest

use of org.apache.storm.generated.DRPCRequest in project storm by apache.

the class DRPCTest method testGoodBlocking.

@Test
public void testGoodBlocking() throws Exception {
    try (DRPC server = new DRPC(null, 100)) {
        Future<String> found = exec.submit(() -> server.executeBlocking("testing", "test"));
        DRPCRequest request = getNextAvailableRequest(server, "testing");
        assertNotNull(request);
        assertEquals("test", request.get_func_args());
        assertNotNull(request.get_request_id());
        server.returnResult(request.get_request_id(), "tested");
        String result = found.get(10, TimeUnit.MILLISECONDS);
        assertEquals("tested", result);
    }
}
Also used : DRPCRequest(org.apache.storm.generated.DRPCRequest) Test(org.junit.Test)

Example 12 with DRPCRequest

use of org.apache.storm.generated.DRPCRequest in project storm by apache.

the class DRPCTest method getNextAvailableRequest.

public static DRPCRequest getNextAvailableRequest(DRPC server, String func) throws Exception {
    DRPCRequest request = null;
    long timedout = System.currentTimeMillis() + 5_000;
    while (System.currentTimeMillis() < timedout) {
        request = server.fetchRequest(func);
        if (request != null && request.get_request_id() != null && !request.get_request_id().isEmpty()) {
            return request;
        }
        Thread.sleep(1);
    }
    fail("Test timed out waiting for a request on " + func);
    return request;
}
Also used : DRPCRequest(org.apache.storm.generated.DRPCRequest)

Aggregations

DRPCRequest (org.apache.storm.generated.DRPCRequest)12 Test (org.junit.Test)7 DRPCServer (org.apache.storm.daemon.drpc.DRPCServer)4 DRPCInvocationsClient (org.apache.storm.drpc.DRPCInvocationsClient)4 DRPCExecutionException (org.apache.storm.generated.DRPCExecutionException)4 ExecutionException (java.util.concurrent.ExecutionException)3 DRPCClient (org.apache.storm.utils.DRPCClient)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 AuthorizationException (org.apache.storm.generated.AuthorizationException)1 DistributedRPCInvocations (org.apache.storm.generated.DistributedRPCInvocations)1 Values (org.apache.storm.tuple.Values)1 TException (org.apache.thrift.TException)1