Class FCClientControlSocket

  • All Implemented Interfaces:
    java.lang.AutoCloseable, unlimited.core.transfers.io.FCClientControlSocketBridge, unlimited.core.util.common.FCSiteIfc

    public final class FCClientControlSocket
    extends java.lang.Object
    implements unlimited.core.transfers.io.FCClientControlSocketBridge, unlimited.core.util.common.FCSiteIfc
    Supports client-side FileCatalyst operations The protocol used by FC (FileCatalyst client) is similar with FTP protocol
    • Field Detail

      • USE_STICKY_SESSIONS

        public static final java.util.function.Supplier<java.lang.Boolean> USE_STICKY_SESSIONS
    • Constructor Detail

      • FCClientControlSocket

        public FCClientControlSocket​(java.net.Socket controlSocket,
                                     boolean sslSocket,
                                     unlimited.core.util.common.logs.LogUtils fileLog,
                                     int timeout)
                              throws java.io.IOException,
                                     unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
    • Method Detail

      • getControlSocket

        public static FCClientControlSocket getControlSocket​(FCClientControlSocketRequestData requestData)
                                                      throws java.io.IOException,
                                                             unlimited.core.util.common.exception.FCException
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • connectToHost

        public void connectToHost​(java.lang.String remoteHost,
                                  int controlPort)
                           throws java.io.IOException
        Specified by:
        connectToHost in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • parseHosts

        public java.util.List<java.lang.String> parseHosts​(java.lang.String remoteHost)
        Specified by:
        parseHosts in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • checkIfConnectedToLoadBalancer

        public unlimited.core.util.common.FCSiteIfc checkIfConnectedToLoadBalancer()
                                                                            throws java.io.IOException
        Specified by:
        checkIfConnectedToLoadBalancer in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • connectToServer

        public void connectToServer​(java.lang.String remoteHost,
                                    int controlPort)
                             throws java.io.IOException,
                                    java.net.SocketException
        Specified by:
        connectToServer in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        java.net.SocketException
      • createSSLSocket

        public javax.net.ssl.SSLSocket createSSLSocket​(java.lang.String host,
                                                       int port)
                                                throws java.io.IOException
        Specified by:
        createSSLSocket in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • createSSLSocket

        public javax.net.ssl.SSLSocket createSSLSocket​(java.lang.String host,
                                                       int port,
                                                       boolean needHandshake)
                                                throws java.io.IOException
        Specified by:
        createSSLSocket in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • getRemoteHostName

        public java.lang.String getRemoteHostName()
        Get the name of the remote host
        Specified by:
        getRemoteHostName in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Returns:
        remote host name
      • isSSL

        public boolean isSSL()
        Specified by:
        isSSL in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getLog

        public unlimited.core.util.common.logs.LogUtils getLog()
        Specified by:
        getLog in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getAddress

        public java.net.InetAddress getAddress()
        Specified by:
        getAddress in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getRemotePort

        public int getRemotePort()
        Specified by:
        getRemotePort in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • isIPv6

        public boolean isIPv6()
        Specified by:
        isIPv6 in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • reconnect

        public void reconnect()
                       throws java.io.IOException,
                              unlimited.core.util.common.exception.FCException
        Specified by:
        reconnect in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • getLocalHost

        public java.lang.String getLocalHost()
        Get the name of the remote host
        Specified by:
        getLocalHost in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Returns:
        remote host name
      • setTimeout

        public void setTimeout​(int millis)
                        throws java.net.SocketException
        Set the TCP timeout on the underlying control socket. If a timeout is set, then any operation which takes longer than the timeout value will be killed with a java.io.InterruptedException.
        Specified by:
        setTimeout in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        millis - The length of the timeout, in milliseconds
        Throws:
        java.io.IOException - if the timeout can not be set
        java.net.SocketException
      • setConnectTimeout

        public void setConnectTimeout()
                               throws java.net.SocketException
        Specified by:
        setConnectTimeout in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.net.SocketException
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.lang.Exception
      • logout

        public void logout()
                    throws java.io.IOException
        Quit this FileCatalyst session and clean up.
        Specified by:
        logout in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException - if an IOException is caught
      • sendCommandNoReply

        public void sendCommandNoReply​(java.lang.String command)
                                throws java.io.IOException
        Send a command to the FileCatalyst server and return the server's reply
        Specified by:
        sendCommandNoReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        command - the command to be send to FTP server
        Throws:
        java.io.IOException - if the send is failing
      • sendCommand

        public java.lang.String sendCommand​(java.lang.String command)
                                     throws java.io.IOException
        Send a command to the FileCatalyst server and return the server's reply
        Specified by:
        sendCommand in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        command - the command to be send to FTP server
        Returns:
        reply to the supplied command
        Throws:
        java.io.IOException - if the send is failing
      • lastActivity

        public long lastActivity()
        Specified by:
        lastActivity in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • sendCommand

        public java.lang.String sendCommand​(java.lang.StringBuffer command)
                                     throws java.io.IOException
        Send a command to the FileCatalyst server and return the server's reply
        Specified by:
        sendCommand in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        command - the command to be send to FTP server
        Returns:
        reply to the supplied command
        Throws:
        java.io.IOException - if the send is failing
      • getAvgRTT

        public int getAvgRTT()
        Specified by:
        getAvgRTT in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getLowRTT

        public int getLowRTT()
        Specified by:
        getLowRTT in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getCurrentRTT

        public int getCurrentRTT()
        Specified by:
        getCurrentRTT in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • readReply

        public java.lang.String readReply()
                                   throws java.io.IOException
        Specified by:
        readReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • readReply

        public java.lang.String readReply​(boolean log)
                                   throws java.io.IOException
        Read the FileCatalyst server's reply to a previously issued command. RFC 959 states that a reply consists of the 3 digit code followed by text. The 3 digit code is followed by a hyphen if it is a multiline response, and the last line starts with the same 3 digit code.
        Specified by:
        readReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Returns:
        reply string
        Throws:
        java.io.IOException - if an IOException is caught.
      • debugResponses

        public void debugResponses​(boolean on)
        Switch debug of responses on or off
        Specified by:
        debugResponses in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        on - true if you wish to have responses to stdout, false otherwise
      • setLogStream

        public void setLogStream​(unlimited.core.util.common.logs.LogUtils fileLog)
        Set the logging stream, replacing stdout
        Specified by:
        setLogStream in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Parameters:
        logFile - the new logging stream
      • createDataSocketPassive

        public java.net.Socket[] createDataSocketPassive​(int num)
                                                  throws java.io.IOException,
                                                         unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocketPassive in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSocketPassive

        public java.net.Socket[] createDataSocketPassive​(int num,
                                                         boolean nio)
                                                  throws java.io.IOException,
                                                         unlimited.core.util.common.exception.FCException
        Request several data sockets be created on the server, connect and return our connected sockets.
        Specified by:
        createDataSocketPassive in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Returns:
        connected data sockets
        Throws:
        java.io.IOException - if an IOException is caught.
        FtpException - if the server socket can not be created
        unlimited.core.util.common.exception.FCException
      • parsePort

        public static int parsePort​(int parseFirst,
                                    int parseSecond)
      • createDataSocketPassive

        public java.net.Socket createDataSocketPassive()
                                                throws java.io.IOException,
                                                       unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocketPassive in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSocketPassive

        public java.net.Socket createDataSocketPassive​(boolean nio)
                                                throws java.io.IOException,
                                                       unlimited.core.util.common.exception.FCException
        Request a data socket be created on the server, connect to it and return our connected socket.
        Specified by:
        createDataSocketPassive in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Returns:
        connected data socket
        Throws:
        java.io.IOException - if an IOException is caught.
        FtpException - if the server socket can not be created
        unlimited.core.util.common.exception.FCException
      • createDataSocketActive

        public java.net.Socket createDataSocketActive()
                                               throws java.io.IOException,
                                                      unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocketActive in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSocketActiveSendCommand

        public java.net.Socket createDataSocketActiveSendCommand​(java.lang.String command)
                                                          throws java.io.IOException,
                                                                 unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocketActiveSendCommand in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSocket

        public java.net.Socket createDataSocket()
                                         throws java.io.IOException,
                                                unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocket in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSocket

        public java.net.Socket createDataSocket​(boolean nio)
                                         throws java.io.IOException,
                                                unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSocket in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • createDataSockets

        public java.net.Socket[] createDataSockets​(int num)
                                            throws java.io.IOException,
                                                   unlimited.core.util.common.exception.FCException
        Specified by:
        createDataSockets in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
        unlimited.core.util.common.exception.FCException
      • setWelcomeMessage

        public void setWelcomeMessage​(java.lang.String welcomeMessage)
        Specified by:
        setWelcomeMessage in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getWelcomeMessage

        public java.lang.String getWelcomeMessage()
        Specified by:
        getWelcomeMessage in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • addLostReply

        public final void addLostReply​(java.lang.String reply)
        Specified by:
        addLostReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • addLostReply

        public final void addLostReply​(unlimited.core.transfers.io.FCReply lostReply)
        Specified by:
        addLostReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getLostReplies

        public final unlimited.core.transfers.io.FCReply getLostReplies​(java.lang.String... replyCodes)
        Specified by:
        getLostReplies in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getLostReply

        public final unlimited.core.transfers.io.FCReply getLostReply​(java.lang.String replyCode)
        Specified by:
        getLostReply in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • setIPTOSIfRequired

        public void setIPTOSIfRequired()
                                throws java.io.IOException
        Specified by:
        setIPTOSIfRequired in interface unlimited.core.transfers.io.FCClientControlSocketBridge
        Throws:
        java.io.IOException
      • getSysKey

        public java.lang.String getSysKey()
        Specified by:
        getSysKey in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getControlPort

        public int getControlPort()
        Specified by:
        getControlPort in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • isSsl

        public boolean isSsl()
        Specified by:
        isSsl in interface unlimited.core.util.common.FCSiteIfc
      • getHost

        public java.lang.String getHost()
        Specified by:
        getHost in interface unlimited.core.util.common.FCSiteIfc
      • getPort

        public int getPort()
        Specified by:
        getPort in interface unlimited.core.util.common.FCSiteIfc
      • getResolvedSiteDO

        public unlimited.core.util.common.FCSiteIfc getResolvedSiteDO()
      • registerLookUp

        public void registerLookUp​(unlimited.core.util.common.FCSiteIfc lookup)
        Specified by:
        registerLookUp in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • getIsFCServerSupplier

        public java.util.function.Supplier<java.lang.Boolean> getIsFCServerSupplier()
        Specified by:
        getIsFCServerSupplier in interface unlimited.core.transfers.io.FCClientControlSocketBridge
      • setIsFCServerSupplier

        public void setIsFCServerSupplier​(java.util.function.Supplier<java.lang.Boolean> isFCServerSupplier)
        Specified by:
        setIsFCServerSupplier in interface unlimited.core.transfers.io.FCClientControlSocketBridge