Class AbstractOIFtpPusher

java.lang.Object
java.lang.Thread
com.nt.udc.ndk.util.AbstractOIFtpPusher
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
GenevaOIFtpPusher, OIFtpPusher

public abstract class AbstractOIFtpPusher extends Thread
  • 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

      public static final String SSH_KNOWN_HOSTS_FILE
      See Also:
    • ftpRunning

      protected boolean ftpRunning
    • passiveMode

      protected boolean passiveMode
    • delay

      protected int delay
    • ftpFileType

      protected int ftpFileType
    • ftpFilter

      protected FilenameFilter ftpFilter
    • ftpClient

      protected FtpSupportIntf ftpClient
    • logger

      protected LoggerIfc logger
    • errMesg

      protected String errMesg
    • ftpDirectory

      protected String ftpDirectory
    • ftpExtension

      protected String ftpExtension
    • ftpHost

      protected String ftpHost
    • ftpPort

      protected int ftpPort
    • ftpPasswd

      protected String ftpPasswd
    • ftpUser

      protected String ftpUser
    • localDirectory

      protected String localDirectory
    • interruptDelay

      protected int interruptDelay
    • filesToFTP

      protected Vector filesToFTP
    • ftpTimeInterval

      protected long ftpTimeInterval
    • bFailed

      protected boolean bFailed
    • oinode

      protected DCNode oinode
    • sftpUsed

      protected boolean sftpUsed
    • hostsFile

      protected String 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 new AbsctractOIFtpPusher to be used within an OITransport object. The file transfers will occur based upon the provided configuration parameters.
      Parameters:
      lgr - Reference to the log methods of the node
      localdir - Local directory containing the files to be transferred
      ftphost - Name/IP address of the remote ftp host
      ftpuser - Name used to login to the remote host
      ftppasswd - Password used to login to the remote host
      ftpdir - Remote directory in which to place the files
      ftpext - 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 used
      hostsFile - 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 new AbsctractOIFtpPusher to be used within an OITransport object. The file transfers will occur based upon the provided configuration parameters.
      Parameters:
      lgr - Reference to the log methods of the node
      localdir - Local directory containing the files to be transferred
      ftphost - Name/IP address of the remote ftp host
      ftpport - FTP port number, default is 21
      ftpuser - Name used to login to the remote host
      ftppasswd - Password used to login to the remote host
      ftpdir - Remote directory in which to place the files
      ftpext - 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 used
      hostsFile - 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 new AbsctractOIFtpPusher to be used within an OITransport object. The file transfers will occur based upon the provided configuration parameters.
      Parameters:
      lgr - Reference to the log methods of the node
      localdir - Local directory containing the files to be transferred
      ftphost - Name/IP address of the remote ftp host
      ftpport - FTP port number, default is 21
      ftpuser - Name used to login to the remote host
      ftppasswd - Password used to login to the remote host
      ftpdir - Remote directory in which to place the files
      ftpext - 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 used
      hostsFile - 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

      protected abstract void doTransfer() throws IOException
      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.
      Specified by:
      run in interface Runnable
      Overrides:
      run in class Thread
    • 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

      public void setLocalDirectory(String dir)
      Sets the local directory containing the files to be transferred.
      Parameters:
      dir - Local directory containing the files to be transferred.
    • getLocalDirectory

      public String getLocalDirectory()
      Return the local directory containing the files to be transferred.
      Returns:
      Returns the local directory containing the files to be transferred.
    • setFtpHost

      public void setFtpHost(String host)
      Sets the name/IP address of the remote FTP host.
      Parameters:
      host - The remote FTP host.
    • getFtpHost

      public String 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

      public void setFtpLogin(String login)
      Sets the login name for the remote FTP user.
      Parameters:
      login - The remote login name.
    • getFtpLogin

      public String getFtpLogin()
      Return the login name for the remote FTP user.
      Returns:
      Returns the login name for the remote FTP user.
    • setFtpPassword

      public void setFtpPassword(String passwd)
      Sets the password for the remote FTP user.
      Parameters:
      passwd - The password for the remote FTP user.
    • getFtpPassword

      public String getFtpPassword()
      Return the password for the remote FTP user.
      Returns:
      Returns the password for the remote FTP user.
    • setFtpDirectory

      public void setFtpDirectory(String dir)
      Sets the destination directory on the remote FTP host.
      Parameters:
      dir - The destination directory on the remote FTP host.
    • getFtpDirectory

      public String getFtpDirectory()
      Return the destination directory on the remote FTP host.
      Returns:
      Returns the destination directory on the remote FTP host.
    • setFtpExtension

      public void setFtpExtension(String ext)
      Sets the file extension for files that have been transferred.
      Parameters:
      ext - The file extension for files that have been transferred.
    • getFtpExtension

      public String getFtpExtension()
      Returns the file extension for files that have been transferred.
      Returns:
      Returns the extension for files that have been transferred.
    • setFiles

      public void setFiles(List fileNames)
      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

      public List getFiles()