SFTPInputStream(InputStream stream, ChannelSftp channel, FileSystem.Statistics stats) { if (stream == null) { throw new IllegalArgumentException(E_NULL_INPUTSTREAM); } if (channel == null || !channel.isConnected()) { throw new IllegalArgumentException(E_CLIENT_NULL); } this.wrappedStream = stream; this.channel = channel; this.stats = stats; this.pos = 0; this.closed = false; }
public synchronized void close() throws IOException { if (closed) { return; } super.close(); closed = true; if (!channel.isConnected()) { throw new IOException(E_CLIENT_NOTCONNECTED); } try { Session session = channel.getSession(); channel.disconnect(); session.disconnect(); } catch (JSchException e) { throw new IOException(StringUtils.stringifyException(e)); } } }
void disconnect(ChannelSftp channel) throws IOException { if (channel != null) { // close connection if too many active connections boolean closeConnection = false; synchronized (this) { if (liveConnectionCount > maxConnection) { --liveConnectionCount; con2infoMap.remove(channel); closeConnection = true; } } if (closeConnection) { if (channel.isConnected()) { try { Session session = channel.getSession(); channel.disconnect(); session.disconnect(); } catch (JSchException e) { throw new IOException(StringUtils.stringifyException(e)); } } } else { returnToPool(channel); } } }
if (channel.isConnected()) { return channel; } else {
void connect() { try { if (!this.jschSession.isConnected()) { this.jschSession.connect(); } this.channel = (ChannelSftp) this.jschSession.openChannel("sftp"); if (this.channel != null && !this.channel.isConnected()) { this.channel.connect(); } } catch (JSchException e) { this.close(); throw new IllegalStateException("failed to connect", e); } }
@Override public synchronized boolean isConnected() { if (sftpClient == null) { return false; } return sftpClient.isConnected(); }
SFTPInputStream(InputStream stream, ChannelSftp channel, FileSystem.Statistics stats) { if (stream == null) { throw new IllegalArgumentException(E_NULL_INPUTSTREAM); } if (channel == null || !channel.isConnected()) { throw new IllegalArgumentException(E_CLIENT_NULL); } this.wrappedStream = stream; this.channel = channel; this.stats = stats; this.pos = 0; this.closed = false; }
SFTPInputStream(InputStream stream, ChannelSftp channel, FileSystem.Statistics stats) { if (stream == null) { throw new IllegalArgumentException(E_NULL_INPUTSTREAM); } if (channel == null || !channel.isConnected()) { throw new IllegalArgumentException(E_CLIENT_NULL); } this.wrappedStream = stream; this.channel = channel; this.stats = stats; this.pos = 0; this.closed = false; }
@Override void close() { if (ftp != null) { try { if (ftp.isConnected()) ftp.disconnect(); } finally { ftp = null; } } } }
public int getServerVersion() throws SftpException{ if(!isConnected()){ throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); } return server_version; }
/** * Disconnect the STFP session connection */ public void disconnect() { if (channel != null && channel.isConnected()) { channel.disconnect(); } if (session != null) { session.disconnect(); } }
public int getServerVersion() throws SftpException{ if(!isConnected()){ throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); } return server_version; }
public int getServerVersion() throws SftpException{ if(!isConnected()){ throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); } return server_version; }
public int getServerVersion() throws SftpException { if (!isConnected()) { throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); } return server_version; }
/** * returns the server's protocol version number. */ public int getServerVersion() throws SftpException{ if(!isConnected()){ throw new SftpException(SSH_FX_FAILURE, "The channel is not connected."); } return server_version; }
@Override public synchronized void connect() throws RemoteException { init(); assert sftpClient.isConnected(); try { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Remote server version is {0}", sftpClient.getServerVersion()); } } catch (SftpException exc) { // can be ignored LOGGER.log(Level.FINE, "Exception while getting server version", exc); } }
public synchronized void disconnect() throws GenericFileOperationFailedException { if (session != null && session.isConnected()) { session.disconnect(); } if (channel != null && channel.isConnected()) { channel.disconnect(); } }
@Override public void disconnect() throws FileTransferException { if (this.channel != null && this.channel.isConnected()) { this.channel.disconnect(); } if (this.session != null && this.session.isConnected()) { this.session.disconnect(); } }
private boolean isConnected() { if (channel.isConnected()) { try { channel.getSession().sendKeepAliveMsg(); return true; } catch (@SuppressWarnings("unused") Exception e) { // the keep alive failed - treat as not connected, and actually disconnect quietly disconnectQuietly(); } } return false; }
/** * remove channelSftp and disconnect if necessary */ public void releaseChannelSftp() { if (channelSftp != null) { if (channelSftp.isConnected()) { Message.verbose(":: SFTP :: closing sftp connection from " + host + "..."); channelSftp.disconnect(); channelSftp = null; Message.verbose(":: SFTP :: sftp connection closed from " + host); } } } }