/** * Creates a new app handle. The handle will wait for an incoming connection for a configurable * amount of time, and if one doesn't arrive, it will transition to an error state. */ ChildProcAppHandle newAppHandle(String secret) { ChildProcAppHandle handle = new ChildProcAppHandle(secret, this); ChildProcAppHandle existing = pending.putIfAbsent(secret, handle); CommandBuilderUtils.checkState(existing == null, "Multiple handles with the same secret."); return handle; }
/** * Creates a new app handle. The handle will wait for an incoming connection for a configurable * amount of time, and if one doesn't arrive, it will transition to an error state. */ ChildProcAppHandle newAppHandle(String secret) { ChildProcAppHandle handle = new ChildProcAppHandle(secret, this); ChildProcAppHandle existing = pending.putIfAbsent(secret, handle); CommandBuilderUtils.checkState(existing == null, "Multiple handles with the same secret."); return handle; }
public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) throws IOException { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); for (SparkAppHandle.Listener l : listeners) { handle.addListener(l);
public SparkAppHandle startApplication(SparkAppHandle.Listener... listeners) throws IOException { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); for (SparkAppHandle.Listener l : listeners) { handle.addListener(l);
@Test public void testTimeout() throws Exception { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); String secret = server.registerHandle(handle); TestClient client = null; try { // LauncherServer will immediately close the server-side socket when the timeout is set // to 0. SparkLauncher.setConfig(SparkLauncher.CHILD_CONNECTION_TIMEOUT, "0"); Socket s = new Socket(InetAddress.getLoopbackAddress(), server.getPort()); client = new TestClient(s); waitForError(client, secret); } finally { SparkLauncher.launcherConfig.remove(SparkLauncher.CHILD_CONNECTION_TIMEOUT); handle.kill(); close(client); } }
@Test public void testLauncherServerReuse() throws Exception { LauncherServer server1 = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server1); handle.kill(); LauncherServer server2 = LauncherServer.getOrCreateServer(); try { assertNotSame(server1, server2); } finally { server2.unref(); } }
@Test public void testAppHandleDisconnect() throws Exception { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); String secret = server.registerHandle(handle); TestClient client = null; try { Socket s = new Socket(InetAddress.getLoopbackAddress(), server.getPort()); client = new TestClient(s); client.send(new Hello(secret, "1.4.0")); client.send(new SetAppId("someId")); // Wait until we know the server has received the messages and matched the handle to the // connection before disconnecting. eventually(Duration.ofSeconds(1), Duration.ofMillis(10), () -> { assertEquals("someId", handle.getAppId()); }); handle.disconnect(); waitForError(client, secret); } finally { handle.kill(); close(client); client.clientThread.join(); } }
@Test public void testStreamFiltering() throws Exception { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); String secret = server.registerHandle(handle); TestClient client = null; try { Socket s = new Socket(InetAddress.getLoopbackAddress(), server.getPort()); client = new TestClient(s); try { client.send(new EvilPayload()); } catch (SocketException se) { // SPARK-21522: this can happen if the server closes the socket before the full message has // been written, so it's expected. It may cause false positives though (socket errors // happening for other reasons). } waitForError(client, secret); assertEquals(0, EvilPayload.EVIL_BIT); } finally { handle.kill(); close(client); client.clientThread.join(); } }
@Test public void testSparkSubmitVmShutsDown() throws Exception { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); String secret = server.registerHandle(handle);
@Test public void testCommunication() throws Exception { LauncherServer server = LauncherServer.getOrCreateServer(); ChildProcAppHandle handle = new ChildProcAppHandle(server); String secret = server.registerHandle(handle);