@Override public void close() throws IOException { synchronized (clients) { clients.remove(this); } super.close(); if (handle != null) { if (!handle.getState().isFinal()) { LOG.log(Level.WARNING, "Lost connection to spark application."); handle.setState(SparkAppHandle.State.LOST); } handle.disconnect(); } }
@Override public void close() throws IOException { synchronized (clients) { clients.remove(this); } super.close(); if (handle != null) { if (!handle.getState().isFinal()) { LOG.log(Level.WARNING, "Lost connection to spark application."); handle.setState(SparkAppHandle.State.LOST); } handle.disconnect(); } }
State currState = getState();
State currState = getState();
@Test public void testSparkSubmitVmShutsDown() throws Exception { ChildProcAppHandle handle = LauncherServer.newAppHandle(); TestClient client = null; final Semaphore semaphore = new Semaphore(0); try { Socket s = new Socket(InetAddress.getLoopbackAddress(), LauncherServer.getServerInstance().getPort()); handle.addListener(new SparkAppHandle.Listener() { public void stateChanged(SparkAppHandle handle) { semaphore.release(); } public void infoChanged(SparkAppHandle handle) { semaphore.release(); } }); client = new TestClient(s); client.send(new Hello(handle.getSecret(), "1.4.0")); assertTrue(semaphore.tryAcquire(30, TimeUnit.SECONDS)); // Make sure the server matched the client to the handle. assertNotNull(handle.getConnection()); close(client); assertTrue(semaphore.tryAcquire(30, TimeUnit.SECONDS)); assertEquals(SparkAppHandle.State.LOST, handle.getState()); } finally { kill(handle); close(client); client.clientThread.join(); } }
handle.dispose(); assertTrue(semaphore.tryAcquire(30, TimeUnit.SECONDS)); assertEquals(SparkAppHandle.State.LOST, handle.getState()); } finally { handle.kill();
assertEquals(SparkAppHandle.State.RUNNING, handle.getState());
assertEquals(SparkAppHandle.State.RUNNING, handle.getState());