public void disconnect() throws IOException { try { if (channel != null) channel.disconnect(); } catch (RuntimeException e) { e.printStackTrace();} try { if (session != null) session.disconnect(); } catch (RuntimeException e) { e.printStackTrace();} }
private void shutdownSession(LocalCloudMachines machine) { shellCommandStreamForMachine(machine).close(); shellChannelForMachine(machine).disconnect(); sessionForMachine(machine).disconnect(); shellPrintStreams.remove(shellChannels.get(sessions.get(machine))); shellChannels.remove(sessions.get(machine)); sessions.remove(machine); } }
channelShell.disconnect();
channelShell.disconnect();
/** * Executes command using {@code shell} channel. * * @param ses SSH session. * @param cmd Command. * @throws JSchException In case of SSH error. * @throws IOException If IO error occurs. * @throws GridInterruptedException If thread was interrupted while waiting. */ private void shell(Session ses, String cmd) throws JSchException, IOException, GridInterruptedException { ChannelShell ch = null; try { ch = (ChannelShell)ses.openChannel("shell"); ch.connect(); try (PrintStream out = new PrintStream(ch.getOutputStream(), true)) { out.println(cmd); U.sleep(1000); } } finally { if (ch != null && ch.isConnected()) ch.disconnect(); } }
/** * Executes command using {@code shell} channel. * * @param ses SSH session. * @param cmd Command. * @throws JSchException In case of SSH error. * @throws IOException If IO error occurs. * @throws IgniteInterruptedCheckedException If thread was interrupted while waiting. */ private void shell(Session ses, String cmd) throws JSchException, IOException, IgniteInterruptedCheckedException { ChannelShell ch = null; try { ch = (ChannelShell)ses.openChannel("shell"); ch.connect(); try (PrintStream out = new PrintStream(ch.getOutputStream(), true)) { out.println(cmd); U.sleep(EXECUTE_WAIT_TIME); } } finally { if (ch != null && ch.isConnected()) ch.disconnect(); } }
@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) { } } } }
try { channel.disconnect(); } catch (Exception ignore) {}
try { channel.disconnect(); } catch (Exception ignore) {}
try { channel.disconnect(); } catch (Exception ignore) {}
try { channel.disconnect(); } catch (Exception ignore) {}
try { channel.disconnect(); } catch (Exception ignore) {}
try { channel.disconnect(); } catch (Exception ignore) {}
} finally { if (shell != null && shell.isConnected()) { shell.disconnect();
@Test public void testResizeHandler(TestContext context) throws Exception { Async async = context.async(); termHandler = term -> { term.resizehandler(v -> { context.assertEquals(20, term.width()); context.assertEquals(10, term.height()); async.complete(); }); }; startShell(); Session session = createSession("paulo", "secret", false); session.connect(); ChannelShell channel = (ChannelShell) session.openChannel("shell"); channel.connect(); OutputStream out = channel.getOutputStream(); channel.setPtySize(20, 10, 20 * 8, 10 * 8); out.flush(); channel.disconnect(); session.disconnect(); }