/** * Synchronously sends an opaque message to the RpcHandler on the server-side, waiting for up to * a specified timeout for a response. */ public ByteBuffer sendRpcSync(ByteBuffer message, long timeoutMs) { final SettableFuture<ByteBuffer> result = SettableFuture.create(); sendRpc(message, new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) { ByteBuffer copy = ByteBuffer.allocate(response.remaining()); copy.put(response); // flip "copy" to make it readable copy.flip(); result.set(copy); } @Override public void onFailure(Throwable e) { result.setException(e); } }); try { return result.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) {
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) {
client.sendRpc(openMessage.toByteBuffer(), new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) {
/** * Synchronously sends an opaque message to the RpcHandler on the server-side, waiting for up to * a specified timeout for a response. */ public ByteBuffer sendRpcSync(ByteBuffer message, long timeoutMs) { final SettableFuture<ByteBuffer> result = SettableFuture.create(); sendRpc(message, new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) { ByteBuffer copy = ByteBuffer.allocate(response.remaining()); copy.put(response); // flip "copy" to make it readable copy.flip(); result.set(copy); } @Override public void onFailure(Throwable e) { result.setException(e); } }); try { return result.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Synchronously sends an opaque message to the RpcHandler on the server-side, waiting for up to * a specified timeout for a response. */ public ByteBuffer sendRpcSync(ByteBuffer message, long timeoutMs) { final SettableFuture<ByteBuffer> result = SettableFuture.create(); sendRpc(message, new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) { ByteBuffer copy = ByteBuffer.allocate(response.remaining()); copy.put(response); // flip "copy" to make it readable copy.flip(); result.set(copy); } @Override public void onFailure(Throwable e) { result.setException(e); } }); try { return result.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }
/** * Synchronously sends an opaque message to the RpcHandler on the server-side, waiting for up to * a specified timeout for a response. */ public ByteBuffer sendRpcSync(ByteBuffer message, long timeoutMs) { final SettableFuture<ByteBuffer> result = SettableFuture.create(); sendRpc(message, new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer response) { ByteBuffer copy = ByteBuffer.allocate(response.remaining()); copy.put(response); // flip "copy" to make it readable copy.flip(); result.set(copy); } @Override public void onFailure(Throwable e) { result.setException(e); } }); try { return result.get(timeoutMs, TimeUnit.MILLISECONDS); } catch (ExecutionException e) { throw Throwables.propagate(e.getCause()); } catch (Exception e) { throw Throwables.propagate(e); } }
public void registerDriverWithShuffleService( String host, int port, long heartbeatTimeoutMs, long heartbeatIntervalMs) throws IOException, InterruptedException { checkInit(); ByteBuffer registerDriver = new RegisterDriver(appId, heartbeatTimeoutMs).toByteBuffer(); TransportClient client = clientFactory.createClient(host, port); client.sendRpc(registerDriver, new RegisterDriverCallback(client, heartbeatIntervalMs)); }
public void registerDriverWithShuffleService( String host, int port, long heartbeatTimeoutMs, long heartbeatIntervalMs) throws IOException, InterruptedException { checkInit(); ByteBuffer registerDriver = new RegisterDriver(appId, heartbeatTimeoutMs).toByteBuffer(); TransportClient client = clientFactory.createClient(host, port); client.sendRpc(registerDriver, new RegisterDriverCallback(client, heartbeatIntervalMs)); }
public void registerDriverWithShuffleService( String host, int port, long heartbeatTimeoutMs, long heartbeatIntervalMs) throws IOException, InterruptedException { checkInit(); ByteBuffer registerDriver = new RegisterDriver(appId, heartbeatTimeoutMs).toByteBuffer(); TransportClient client = clientFactory.createClient(host, port); client.sendRpc(registerDriver, new RegisterDriverCallback(client, heartbeatIntervalMs)); }
private RpcResult sendRPC(String ... commands) throws Exception { TransportClient client = clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); final Semaphore sem = new Semaphore(0); final RpcResult res = new RpcResult(); res.successMessages = Collections.synchronizedSet(new HashSet<String>()); res.errorMessages = Collections.synchronizedSet(new HashSet<String>()); RpcResponseCallback callback = new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer message) { String response = JavaUtils.bytesToString(message); res.successMessages.add(response); sem.release(); } @Override public void onFailure(Throwable e) { res.errorMessages.add(e.getMessage()); sem.release(); } }; for (String command : commands) { client.sendRpc(JavaUtils.stringToBytes(command), callback); } if (!sem.tryAcquire(commands.length, 5, TimeUnit.SECONDS)) { fail("Timeout getting response from the server"); } client.close(); return res; }
private RpcResult sendRPC(String ... commands) throws Exception { TransportClient client = clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); final Semaphore sem = new Semaphore(0); final RpcResult res = new RpcResult(); res.successMessages = Collections.synchronizedSet(new HashSet<String>()); res.errorMessages = Collections.synchronizedSet(new HashSet<String>()); RpcResponseCallback callback = new RpcResponseCallback() { @Override public void onSuccess(ByteBuffer message) { String response = JavaUtils.bytesToString(message); res.successMessages.add(response); sem.release(); } @Override public void onFailure(Throwable e) { res.errorMessages.add(e.getMessage()); sem.release(); } }; for (String command : commands) { client.sendRpc(JavaUtils.stringToBytes(command), callback); } if (!sem.tryAcquire(commands.length, 5, TimeUnit.SECONDS)) { fail("Timeout getting response from the server"); } client.close(); return res; }
assertEquals(new OpenBlocks("app-id", "exec-id", blockIds), message); return null; }).when(client).sendRpc(any(ByteBuffer.class), any(RpcResponseCallback.class));
assertEquals(new OpenBlocks("app-id", "exec-id", blockIds), message); return null; }).when(client).sendRpc(any(ByteBuffer.class), any(RpcResponseCallback.class));
assertEquals(new OpenBlocks("app-id", "exec-id", blockIds), message); return null; }).when(client).sendRpc(any(ByteBuffer.class), any(RpcResponseCallback.class));
clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); TestCallback callback0 = new TestCallback(); client0.sendRpc(ByteBuffer.allocate(0), callback0); callback0.latch.await(); assertTrue(callback0.failure instanceof IOException); clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); TestCallback callback1 = new TestCallback(); client1.sendRpc(ByteBuffer.allocate(0), callback1); callback1.latch.await(); assertEquals(responseSize, callback1.successLength);
clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); TestCallback callback0 = new TestCallback(); client0.sendRpc(ByteBuffer.allocate(0), callback0); callback0.latch.await(); assertTrue(callback0.failure instanceof IOException); clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); TestCallback callback1 = new TestCallback(); client1.sendRpc(ByteBuffer.allocate(0), callback1); callback1.latch.await(); assertEquals(responseSize, callback1.successLength);