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);
}
}
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;
}
Aggregations