/** * Register an application with its secret specified as a byte buffer. */ public void registerApp(String appId, ByteBuffer shuffleSecret) { registerApp(appId, JavaUtils.bytesToString(shuffleSecret)); }
/** * Register an application with its secret specified as a byte buffer. */ public void registerApp(String appId, ByteBuffer shuffleSecret) { registerApp(appId, JavaUtils.bytesToString(shuffleSecret)); }
@Override public StreamCallbackWithID receiveStream( TransportClient client, ByteBuffer messageHeader, RpcResponseCallback callback) { return receiveStreamHelper(JavaUtils.bytesToString(messageHeader)); }
/** * Register an application with its secret specified as a byte buffer. */ public void registerApp(String appId, ByteBuffer shuffleSecret) { registerApp(appId, JavaUtils.bytesToString(shuffleSecret)); }
@Override public void receive(TransportClient client, ByteBuffer message) { oneWayMsgs.add(JavaUtils.bytesToString(message)); }
@Override public void onSuccess(ByteBuffer message) { String response = JavaUtils.bytesToString(message); res.successMessages.add(response); sem.release(); }
@Override public void onSuccess(ByteBuffer message) { String response = JavaUtils.bytesToString(message); res.successMessages.add(response); sem.release(); }
@Override public void receive( TransportClient client, ByteBuffer message, RpcResponseCallback callback) { String msg = JavaUtils.bytesToString(message); String[] parts = msg.split("/"); if (parts[0].equals("hello")) { callback.onSuccess(JavaUtils.stringToBytes("Hello, " + parts[1] + "!")); } else if (parts[0].equals("return error")) { callback.onFailure(new RuntimeException("Returned: " + parts[1])); } else if (parts[0].equals("throw error")) { throw new RuntimeException("Thrown: " + parts[1]); } }
@Override public void receive( TransportClient client, ByteBuffer message, RpcResponseCallback callback) { String msg = JavaUtils.bytesToString(message); String[] parts = msg.split("/"); if (parts[0].equals("hello")) { callback.onSuccess(JavaUtils.stringToBytes("Hello, " + parts[1] + "!")); } else if (parts[0].equals("return error")) { callback.onFailure(new RuntimeException("Returned: " + parts[1])); } else if (parts[0].equals("throw error")) { throw new RuntimeException("Thrown: " + parts[1]); } }
@Override public void receive( TransportClient client, ByteBuffer message, RpcResponseCallback callback) { assertEquals("Ping", JavaUtils.bytesToString(message)); callback.onSuccess(JavaUtils.stringToBytes("Pong")); }
@Override public void receive( TransportClient client, ByteBuffer message, RpcResponseCallback callback) { assertEquals("Ping", JavaUtils.bytesToString(message)); callback.onSuccess(JavaUtils.stringToBytes("Pong")); }
@Test public void testGoodClient() throws IOException, InterruptedException { clientFactory = context.createClientFactory( Arrays.asList(new SaslClientBootstrap(conf, "app-1", secretKeyHolder))); TransportClient client = clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); String msg = "Hello, World!"; ByteBuffer resp = client.sendRpcSync(JavaUtils.stringToBytes(msg), TIMEOUT_MS); assertEquals(msg, JavaUtils.bytesToString(resp)); }
@Test public void testGoodClient() throws IOException, InterruptedException { clientFactory = context.createClientFactory( Arrays.asList(new SaslClientBootstrap(conf, "app-1", secretKeyHolder))); TransportClient client = clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); String msg = "Hello, World!"; ByteBuffer resp = client.sendRpcSync(JavaUtils.stringToBytes(msg), TIMEOUT_MS); assertEquals(msg, JavaUtils.bytesToString(resp)); }
@Test public void testGoodClient() throws IOException, InterruptedException { clientFactory = context.createClientFactory( Arrays.asList(new SaslClientBootstrap(conf, "app-1", secretKeyHolder))); TransportClient client = clientFactory.createClient(TestUtils.getLocalHost(), server.getPort()); String msg = "Hello, World!"; ByteBuffer resp = client.sendRpcSync(JavaUtils.stringToBytes(msg), TIMEOUT_MS); assertEquals(msg, JavaUtils.bytesToString(resp)); }
@Test public void testSaslServerFallback() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret", true); ctx.createClient("secret", false); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); }
@Test public void testSaslClientFallback() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret", false); ctx.createClient("secret", true); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); }
@Test public void testSaslServerFallback() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret", true); ctx.createClient("secret", false); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); }
@Test public void testSaslClientFallback() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret", false); ctx.createClient("secret", true); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); }
@Test public void testNewAuth() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret"); ctx.createClient("secret"); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); assertTrue(ctx.authRpcHandler.doDelegate); assertFalse(ctx.authRpcHandler.delegate instanceof SaslRpcHandler); }
@Test public void testNewAuth() throws Exception { ctx = new AuthTestCtx(); ctx.createServer("secret"); ctx.createClient("secret"); ByteBuffer reply = ctx.client.sendRpcSync(JavaUtils.stringToBytes("Ping"), 5000); assertEquals("Pong", JavaUtils.bytesToString(reply)); assertTrue(ctx.authRpcHandler.doDelegate); assertFalse(ctx.authRpcHandler.delegate instanceof SaslRpcHandler); }