@Override public void activateObject(PooledObject<FTPClient> p) throws Exception { p.getObject().sendNoOp(); }
@Override public boolean validateObject(PooledObject<FTPClient> p) { try { p.getObject().sendNoOp(); } catch (IOException e) { logger.warn("validateObject ftp error!", e); return false; } return p.getObject().isConnected() && p.getObject().isAvailable(); }
public boolean validateObject(Object object) { FTPClient client = (FTPClient) object; try { return client.sendNoOp(); } catch (IOException e) { throw new RuntimeException("Failed to validate client: " + e, e); } }
@Override public void keepAlive() { // Send a NOOP command to the server to keep the connection alive. // Note: not all FTP servers support the NOOP command. if(ftpClient!=null) { try { ftpClient.sendNoOp(); } catch(IOException e) { // Checks if the IOException corresponds to a socket error and in that case, closes the connection checkSocketException(e); } } } }
public boolean sendNoop() throws GenericFileOperationFailedException { log.trace("sendNoOp"); try { return client.sendNoOp(); } catch (IOException e) { throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e); } }
return false; ftp.sendNoOp();//used so server timeout exception will not rise int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply))
/***********************************************************************/ public static void ftpUpload(FTPConfig config, String directory, File file, String remoteFileName) throws IOException { FTPClient server = new FTPClient(); server.connect(config.host, config.port); assertValidReplyCode(server.getReplyCode(), server); server.login(config.userName, config.password); assertValidReplyCode(server.getReplyCode(), server); assertValidReplyCode(server.cwd(directory), server); server.setFileTransferMode(FTP.IMAGE_FILE_TYPE); server.setFileType(FTP.IMAGE_FILE_TYPE); server.storeFile(remoteFileName, new FileInputStream(file)); assertValidReplyCode(server.getReplyCode(), server); server.sendNoOp(); server.disconnect(); } /***********************************************************************/