Package com.nt.udc.ndk.util
Class AbstractOIFtpPusher
java.lang.Object
java.lang.Thread
com.nt.udc.ndk.util.AbstractOIFtpPusher
- All Implemented Interfaces:
Runnable
- Direct Known Subclasses:
GenevaOIFtpPusher,OIFtpPusher
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanstatic final intstatic final intprotected intprotected Stringprotected Vectorprotected FtpSupportIntfprotected Stringprotected Stringprotected intprotected FilenameFilterprotected Stringprotected Stringprotected intprotected booleanprotected longprotected Stringprotected Stringprotected intprotected Stringprotected LoggerIfcprotected DCNodeprotected booleanprotected booleanstatic final StringFields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionAbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, int ftpport, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile) Construct a newAbsctractOIFtpPusherto be used within anOITransportobject.AbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, int ftpport, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile, int interruptDelay) Construct a newAbsctractOIFtpPusherto be used within anOITransportobject.AbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile) Construct a newAbsctractOIFtpPusherto be used within anOITransportobject. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidtransfer the files in this method.voidenablePassiveMode(boolean passive) Enable (or disable) passive FTP mode.intReturns the FTP transfer mode.getFiles()Return the destination directory on the remote FTP host.Returns the file extension for files that have been transferred.Return the name/IP address of the remote FTP host.Return the login name for the remote FTP user.Return the password for the remote FTP user.intlongget ftpTimeInterval and pass to the timerReturn the local directory containing the files to be transferred.booleanThis method is used to check if the pusher is fully functional.voidrun()While there are files to transfer, attempt to make the connection to the remote host and transfer all files.voidSets the FTP transfer mode to ascii.voidSets the FTP transfer mode to binary.voidAdd each file in the given list to the list of files to be transferred.voidsetFtpDirectory(String dir) Sets the destination directory on the remote FTP host.voidsetFtpExtension(String ext) Sets the file extension for files that have been transferred.voidsetFtpHost(String host) Sets the name/IP address of the remote FTP host.voidsetFtpLogin(String login) Sets the login name for the remote FTP user.voidsetFtpPassword(String passwd) Sets the password for the remote FTP user.voidsetFtpPort(int port) voidsetFtpTimeInterval(long interval) set ftpInterval when the pusher object is instantiated in a specific node, the ftpTimeInterval is read in from the config file.voidsetLocalDirectory(String dir) Sets the local directory containing the files to be transferred.voidshutdown()Perform the necessary shutdown tasks.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
-
Field Details
-
DEFAULT_FTP_PORT
public static final int DEFAULT_FTP_PORT- See Also:
-
DEFAULT_SFTP_PORT
public static final int DEFAULT_SFTP_PORT- See Also:
-
SSH_KNOWN_HOSTS_FILE
- See Also:
-
ftpRunning
protected boolean ftpRunning -
passiveMode
protected boolean passiveMode -
delay
protected int delay -
ftpFileType
protected int ftpFileType -
ftpFilter
-
ftpClient
-
logger
-
errMesg
-
ftpDirectory
-
ftpExtension
-
ftpHost
-
ftpPort
protected int ftpPort -
ftpPasswd
-
ftpUser
-
localDirectory
-
interruptDelay
protected int interruptDelay -
filesToFTP
-
ftpTimeInterval
protected long ftpTimeInterval -
bFailed
protected boolean bFailed -
oinode
-
sftpUsed
protected boolean sftpUsed -
hostsFile
-
-
Constructor Details
-
AbstractOIFtpPusher
public AbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile) throws NodeStartException Construct a newAbsctractOIFtpPusherto be used within anOITransportobject. The file transfers will occur based upon the provided configuration parameters.- Parameters:
lgr- Reference to the log methods of the nodelocaldir- Local directory containing the files to be transferredftphost- Name/IP address of the remote ftp hostftpuser- Name used to login to the remote hostftppasswd- Password used to login to the remote hostftpdir- Remote directory in which to place the filesftpext- File extension used to tag the local files as having been transferred. If this parameter is null or zero-length, the local files will be deleted rather than renamed.sftpUsed- If Sftp is usedhostsFile- If Sftp is used, need to specify the hosts file which contains the server finger prints.- Throws:
NodeStartException
-
AbstractOIFtpPusher
public AbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, int ftpport, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile) throws NodeStartException Construct a newAbsctractOIFtpPusherto be used within anOITransportobject. The file transfers will occur based upon the provided configuration parameters.- Parameters:
lgr- Reference to the log methods of the nodelocaldir- Local directory containing the files to be transferredftphost- Name/IP address of the remote ftp hostftpport- FTP port number, default is 21ftpuser- Name used to login to the remote hostftppasswd- Password used to login to the remote hostftpdir- Remote directory in which to place the filesftpext- File extension used to tag the local files as having been transferred. If this parameter is null or zero-length, the local files will be deleted rather than renamed.sftpUsed- If Sftp is usedhostsFile- If Sftp is used, need to specify the hosts file which contains the server finger prints.- Throws:
NodeStartException
-
AbstractOIFtpPusher
public AbstractOIFtpPusher(LoggerIfc lgr, String localdir, String ftphost, int ftpport, String ftpuser, String ftppasswd, String ftpdir, String ftpext, boolean sftpUsed, String hostsFile, int interruptDelay) throws NodeStartException Construct a newAbsctractOIFtpPusherto be used within anOITransportobject. The file transfers will occur based upon the provided configuration parameters.- Parameters:
lgr- Reference to the log methods of the nodelocaldir- Local directory containing the files to be transferredftphost- Name/IP address of the remote ftp hostftpport- FTP port number, default is 21ftpuser- Name used to login to the remote hostftppasswd- Password used to login to the remote hostftpdir- Remote directory in which to place the filesftpext- File extension used to tag the local files as having been transferred. If this parameter is null or zero-length, the local files will be deleted rather than renamed.sftpUsed- If Sftp is usedhostsFile- If Sftp is used, need to specify the hosts file which contains the server finger prints.interruptDelay- Timeout value for ftp connection, ftp transfer.- Throws:
NodeStartException
-
-
Method Details
-
doTransfer
transfer the files in this method. The client has already logged into the server and cd to the remote directory- Throws:
IOException
-
run
public void run()While there are files to transfer, attempt to make the connection to the remote host and transfer all files. Once the transfer has occurred, disconnect and wait for the next batch of files to transfer. -
enablePassiveMode
public void enablePassiveMode(boolean passive) Enable (or disable) passive FTP mode.- Parameters:
passive-true, if passive mode is desired.
-
setBinaryFileMode
public void setBinaryFileMode()Sets the FTP transfer mode to binary. -
setAsciiFileMode
public void setAsciiFileMode()Sets the FTP transfer mode to ascii. -
getFileMode
public int getFileMode()Returns the FTP transfer mode.- Returns:
- Returns an int indicating the transfer mode.
-
setLocalDirectory
Sets the local directory containing the files to be transferred.- Parameters:
dir- Local directory containing the files to be transferred.
-
getLocalDirectory
Return the local directory containing the files to be transferred.- Returns:
- Returns the local directory containing the files to be transferred.
-
setFtpHost
Sets the name/IP address of the remote FTP host.- Parameters:
host- The remote FTP host.
-
getFtpHost
Return the name/IP address of the remote FTP host.- Returns:
- Returns the name/IP address of the remote FTP host.
-
setFtpPort
public void setFtpPort(int port) -
getFtpPort
public int getFtpPort() -
setFtpLogin
Sets the login name for the remote FTP user.- Parameters:
login- The remote login name.
-
getFtpLogin
Return the login name for the remote FTP user.- Returns:
- Returns the login name for the remote FTP user.
-
setFtpPassword
Sets the password for the remote FTP user.- Parameters:
passwd- The password for the remote FTP user.
-
getFtpPassword
Return the password for the remote FTP user.- Returns:
- Returns the password for the remote FTP user.
-
setFtpDirectory
Sets the destination directory on the remote FTP host.- Parameters:
dir- The destination directory on the remote FTP host.
-
getFtpDirectory
Return the destination directory on the remote FTP host.- Returns:
- Returns the destination directory on the remote FTP host.
-
setFtpExtension
Sets the file extension for files that have been transferred.- Parameters:
ext- The file extension for files that have been transferred.
-
getFtpExtension
Returns the file extension for files that have been transferred.- Returns:
- Returns the extension for files that have been transferred.
-
setFiles
Add each file in the given list to the list of files to be transferred.- Parameters:
fileNames- Vector of filenames which are to be transferred.
-
shutdown
public void shutdown()Perform the necessary shutdown tasks. -
isHealthy
public boolean isHealthy()This method is used to check if the pusher is fully functional.It includes checks if the local-directory exists and is readable and if the connection to the FTP server can be established.
-
getFtpTimeInterval
public long getFtpTimeInterval()get ftpTimeInterval and pass to the timer -
setFtpTimeInterval
public void setFtpTimeInterval(long interval) set ftpInterval when the pusher object is instantiated in a specific node, the ftpTimeInterval is read in from the config file. -
getFiles
-