@Override public void stateChanged(SparkAppHandle sparkAppHandle) { LOG.info("Spark app transitioned to state = " + sparkAppHandle.getState()); if (sparkAppHandle.getState().isFinal() || sparkAppHandle.getState().equals( SparkAppHandle.State.RUNNING)) { this.shutdownLatch.countDown(); sparkAppHandle.disconnect(); LOG.info("Successfully disconnected from Spark app handle"); } if (FAILED_SPARK_STATES.contains(sparkAppHandle.getState())) { this.rpcServer.cancelClient(this.clientId, "Spark app launcher failed," + " transitioned to state " + sparkAppHandle.getState()); } }
State currState = getState(); if (!currState.isFinal() || currState == State.FINISHED) { setState(State.FAILED, true);
State currState = getState(); if (!currState.isFinal() || currState == State.FINISHED) { setState(State.FAILED, true);
void setState(State s, boolean force) { if (force) { state.set(s); fireEvent(false); return; } State current = state.get(); while (!current.isFinal()) { if (state.compareAndSet(current, s)) { fireEvent(false); return; } current = state.get(); } if (s != State.LOST) { LOG.log(Level.WARNING, "Backend requested transition from final state {0} to {1}.", new Object[] { current, s }); } }
void setState(State s, boolean force) { if (force) { state.set(s); fireEvent(false); return; } State current = state.get(); while (!current.isFinal()) { if (state.compareAndSet(current, s)) { fireEvent(false); return; } current = state.get(); } if (s != State.LOST) { LOG.log(Level.WARNING, "Backend requested transition from final state {0} to {1}.", new Object[] { current, s }); } }
protected void waitFor(final SparkAppHandle handle) throws Exception { try { eventually(Duration.ofSeconds(10), Duration.ofMillis(10), () -> { assertTrue("Handle is not in final state.", handle.getState().isFinal()); }); } finally { if (!handle.getState().isFinal()) { handle.kill(); } } // Wait until the handle has been marked as disposed, to make sure all cleanup tasks // have been performed. AbstractAppHandle ahandle = (AbstractAppHandle) handle; eventually(Duration.ofSeconds(10), Duration.ofMillis(10), () -> { assertTrue("Handle is still not marked as disposed.", ahandle.isDisposed()); }); }
@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(); } }
void setState(State s) { if (!state.isFinal()) { state = s; fireEvent(false); } else { LOG.log(Level.WARNING, "Backend requested transition from final state {0} to {1}.", new Object[] { state, s }); } }
void setState(State s) { if (!state.isFinal()) { state = s; fireEvent(false); } else { LOG.log(Level.WARNING, "Backend requested transition from final state {0} to {1}.", new Object[] { state, s }); } }