handle.kill(); throw ioe;
handle.kill(); throw ioe;
handle.setChildProc(pb.start(), loggerName); } catch (IOException ioe) { handle.kill(); throw ioe;
handle.setChildProc(pb.start(), loggerName); } catch (IOException ioe) { handle.kill(); throw ioe;
@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 testLauncherServerReuse() throws Exception { ChildProcAppHandle handle1 = null; ChildProcAppHandle handle2 = null; ChildProcAppHandle handle3 = null; try { handle1 = LauncherServer.newAppHandle(); handle2 = LauncherServer.newAppHandle(); LauncherServer server1 = handle1.getServer(); assertSame(server1, handle2.getServer()); handle1.kill(); handle2.kill(); handle3 = LauncherServer.newAppHandle(); assertNotSame(server1, handle3.getServer()); handle3.kill(); assertNull(LauncherServer.getServerInstance()); } finally { kill(handle1); kill(handle2); kill(handle3); } }
@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 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(); } }
assertEquals(SparkAppHandle.State.LOST, handle.getState()); } finally { handle.kill(); close(client); client.clientThread.join();
} finally { close(client); handle.kill(); client.clientThread.join();