public void close(Handler<AsyncResult<Void>> completionHandler) { if (!status.compareAndSet(STATUS_STARTED, STATUS_STOPPING)) { completionHandler.handle(Future.failedFuture("Invalid state:" + status.get())); return; } vertx.executeBlocking(fut-> { try { SshServer server = this.nativeServer; this.nativeServer = null; server.close(); completionHandler.handle(Future.succeededFuture()); } catch (Exception t) { completionHandler.handle(Future.failedFuture(t)); } finally { status.set(STATUS_STOPPED); } }, completionHandler); } }
public void stop(boolean immediately) throws IOException { if (!started.getAndSet(false)) { return; } long maxWait = immediately ? this.getLongProperty(STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME) : Long.MAX_VALUE; boolean successful = close(immediately).await(maxWait); if (!successful) { throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis"); } }
public void stop(boolean immediately) throws IOException { if (!started.getAndSet(false)) { return; } try { long maxWait = immediately ? this.getLongProperty(STOP_WAIT_TIME, DEFAULT_STOP_WAIT_TIME) : Long.MAX_VALUE; boolean successful = close(immediately).await(maxWait); if (!successful) { throw new SocketTimeoutException("Failed to receive closure confirmation within " + maxWait + " millis"); } } finally { // clear the attributes since we close stop the server clearAttributes(); } }
@After public void tearDown() throws Exception { if (sshServer != null) { sshServer.stop(); sshServer.close(true); } }
@After public void tearDown() throws Exception { if (sshServer != null) { sshServer.stop(); sshServer.close(true); } }
@After public void tearDown() throws Exception { if (sshServer != null) { sshServer.stop(); sshServer.close(true); } }
@After public void after() throws Exception { if (out != null) { try { out.close(); } catch (Exception ignore) {} } if (in != null) { try { in.close(); } catch (Exception ignore) {} } if (channel != null) { try { channel.disconnect(); } catch (Exception ignore) {} } if (session != null) { try { session.disconnect(); } catch (Exception ignore) {} } if (sshd != null && !sshd.isClosed()) { try { sshd.close(); } catch (Exception ignore) { } } } }
@After public void after() throws Exception { if (out != null) { try { out.close(); } catch (Exception ignore) {} } if (in != null) { try { in.close(); } catch (Exception ignore) {} } if (channel != null) { try { channel.disconnect(); } catch (Exception ignore) {} } if (session != null) { try { session.disconnect(); } catch (Exception ignore) {} } if (sshd != null && !sshd.isClosed()) { try { sshd.close(); } catch (Exception ignore) { } } } }
@After public void after() throws Exception { if (out != null) { try { out.close(); } catch (Exception ignore) {} } if (in != null) { try { in.close(); } catch (Exception ignore) {} } if (channel != null) { try { channel.disconnect(); } catch (Exception ignore) {} } if (session != null) { try { session.disconnect(); } catch (Exception ignore) {} } if (sshd != null && !sshd.isClosed()) { try { sshd.close(); } catch (Exception ignore) { } } } }