Package unlimited.fc.client.engine
Class FCClientControlSocket
- java.lang.Object
-
- unlimited.fc.client.engine.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.FCSiteIfcSupports client-side FileCatalyst operations The protocol used by FC (FileCatalyst client) is similar with FTP protocol
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFCClientControlSocket.FCSiteDO
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Supplier<java.lang.Boolean>USE_STICKY_SESSIONS
-
Constructor Summary
Constructors Constructor Description FCClientControlSocket(java.net.Socket controlSocket, boolean sslSocket, unlimited.core.util.common.logs.LogUtils fileLog, int timeout)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddLostReply(java.lang.String reply)voidaddLostReply(unlimited.core.transfers.io.FCReply lostReply)unlimited.core.util.common.FCSiteIfccheckIfConnectedToLoadBalancer()voidclose()voidconnectToHost(java.lang.String remoteHost, int controlPort)voidconnectToServer(java.lang.String remoteHost, int controlPort)java.net.SocketcreateDataSocket()java.net.SocketcreateDataSocket(boolean nio)java.net.SocketcreateDataSocketActive()java.net.SocketcreateDataSocketActiveSendCommand(java.lang.String command)java.net.SocketcreateDataSocketPassive()java.net.SocketcreateDataSocketPassive(boolean nio)Request a data socket be created on the server, connect to it and return our connected socket.java.net.Socket[]createDataSocketPassive(int num)java.net.Socket[]createDataSocketPassive(int num, boolean nio)Request several data sockets be created on the server, connect and return our connected sockets.java.net.Socket[]createDataSockets(int num)javax.net.ssl.SSLSocketcreateSSLSocket(java.lang.String host, int port)javax.net.ssl.SSLSocketcreateSSLSocket(java.lang.String host, int port, boolean needHandshake)voiddebugResponses(boolean on)Switch debug of responses on or offjava.net.InetAddressgetAddress()intgetAvgRTT()intgetControlPort()static FCClientControlSocketgetControlSocket(FCClientControlSocketRequestData requestData)intgetCurrentRTT()java.lang.StringgetHost()java.util.function.Supplier<java.lang.Boolean>getIsFCServerSupplier()java.lang.StringgetLocalHost()Get the name of the remote hostunlimited.core.util.common.logs.LogUtilsgetLog()unlimited.core.transfers.io.FCReplygetLostReplies(java.lang.String... replyCodes)unlimited.core.transfers.io.FCReplygetLostReply(java.lang.String replyCode)intgetLowRTT()intgetPort()java.lang.StringgetRemoteHostName()Get the name of the remote hostintgetRemotePort()unlimited.core.util.common.FCSiteIfcgetResolvedSiteDO()java.lang.StringgetSysKey()java.lang.StringgetWelcomeMessage()booleanisIPv6()booleanisSsl()booleanisSSL()longlastActivity()voidlogout()Quit this FileCatalyst session and clean up.java.util.List<java.lang.String>parseHosts(java.lang.String remoteHost)static intparsePort(int parseFirst, int parseSecond)java.lang.StringreadReply()java.lang.StringreadReply(boolean log)Read the FileCatalyst server's reply to a previously issued command.voidreconnect()voidregisterLookUp(unlimited.core.util.common.FCSiteIfc lookup)java.lang.StringsendCommand(java.lang.String command)Send a command to the FileCatalyst server and return the server's replyjava.lang.StringsendCommand(java.lang.StringBuffer command)Send a command to the FileCatalyst server and return the server's replyvoidsendCommandNoReply(java.lang.String command)Send a command to the FileCatalyst server and return the server's replyvoidsetConnectTimeout()voidsetIPTOSIfRequired()voidsetIsFCServerSupplier(java.util.function.Supplier<java.lang.Boolean> isFCServerSupplier)voidsetLogStream(unlimited.core.util.common.logs.LogUtils fileLog)Set the logging stream, replacing stdoutvoidsetTimeout(int millis)Set the TCP timeout on the underlying control socket.voidsetWelcomeMessage(java.lang.String welcomeMessage)
-
-
-
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.IOExceptionunlimited.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.IOExceptionunlimited.core.util.common.exception.FCException
-
connectToHost
public void connectToHost(java.lang.String remoteHost, int controlPort) throws java.io.IOException- Specified by:
connectToHostin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOException
-
parseHosts
public java.util.List<java.lang.String> parseHosts(java.lang.String remoteHost)
- Specified by:
parseHostsin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
checkIfConnectedToLoadBalancer
public unlimited.core.util.common.FCSiteIfc checkIfConnectedToLoadBalancer() throws java.io.IOException- Specified by:
checkIfConnectedToLoadBalancerin interfaceunlimited.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:
connectToServerin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionjava.net.SocketException
-
createSSLSocket
public javax.net.ssl.SSLSocket createSSLSocket(java.lang.String host, int port) throws java.io.IOException- Specified by:
createSSLSocketin interfaceunlimited.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:
createSSLSocketin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOException
-
getRemoteHostName
public java.lang.String getRemoteHostName()
Get the name of the remote host- Specified by:
getRemoteHostNamein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Returns:
- remote host name
-
isSSL
public boolean isSSL()
- Specified by:
isSSLin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getLog
public unlimited.core.util.common.logs.LogUtils getLog()
- Specified by:
getLogin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getAddress
public java.net.InetAddress getAddress()
- Specified by:
getAddressin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getRemotePort
public int getRemotePort()
- Specified by:
getRemotePortin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
isIPv6
public boolean isIPv6()
- Specified by:
isIPv6in interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
reconnect
public void reconnect() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Specified by:
reconnectin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
getLocalHost
public java.lang.String getLocalHost()
Get the name of the remote host- Specified by:
getLocalHostin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Returns:
- remote host name
-
setTimeout
public void setTimeout(int millis) throws java.net.SocketExceptionSet 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:
setTimeoutin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Parameters:
millis- The length of the timeout, in milliseconds- Throws:
java.io.IOException- if the timeout can not be setjava.net.SocketException
-
setConnectTimeout
public void setConnectTimeout() throws java.net.SocketException- Specified by:
setConnectTimeoutin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.net.SocketException
-
close
public void close() throws java.lang.Exception- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.lang.Exception
-
logout
public void logout() throws java.io.IOExceptionQuit this FileCatalyst session and clean up.- Specified by:
logoutin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOException- if an IOException is caught
-
sendCommandNoReply
public void sendCommandNoReply(java.lang.String command) throws java.io.IOExceptionSend a command to the FileCatalyst server and return the server's reply- Specified by:
sendCommandNoReplyin interfaceunlimited.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.IOExceptionSend a command to the FileCatalyst server and return the server's reply- Specified by:
sendCommandin interfaceunlimited.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:
lastActivityin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
sendCommand
public java.lang.String sendCommand(java.lang.StringBuffer command) throws java.io.IOExceptionSend a command to the FileCatalyst server and return the server's reply- Specified by:
sendCommandin interfaceunlimited.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:
getAvgRTTin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getLowRTT
public int getLowRTT()
- Specified by:
getLowRTTin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getCurrentRTT
public int getCurrentRTT()
- Specified by:
getCurrentRTTin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
readReply
public java.lang.String readReply() throws java.io.IOException- Specified by:
readReplyin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOException
-
readReply
public java.lang.String readReply(boolean log) throws java.io.IOExceptionRead 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:
readReplyin interfaceunlimited.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:
debugResponsesin interfaceunlimited.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:
setLogStreamin interfaceunlimited.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:
createDataSocketPassivein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
createDataSocketPassive
public java.net.Socket[] createDataSocketPassive(int num, boolean nio) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionRequest several data sockets be created on the server, connect and return our connected sockets.- Specified by:
createDataSocketPassivein interfaceunlimited.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 createdunlimited.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:
createDataSocketPassivein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
createDataSocketPassive
public java.net.Socket createDataSocketPassive(boolean nio) throws java.io.IOException, unlimited.core.util.common.exception.FCExceptionRequest a data socket be created on the server, connect to it and return our connected socket.- Specified by:
createDataSocketPassivein interfaceunlimited.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 createdunlimited.core.util.common.exception.FCException
-
createDataSocketActive
public java.net.Socket createDataSocketActive() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Specified by:
createDataSocketActivein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.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:
createDataSocketActiveSendCommandin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
createDataSocket
public java.net.Socket createDataSocket() throws java.io.IOException, unlimited.core.util.common.exception.FCException- Specified by:
createDataSocketin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.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:
createDataSocketin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.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:
createDataSocketsin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOExceptionunlimited.core.util.common.exception.FCException
-
setWelcomeMessage
public void setWelcomeMessage(java.lang.String welcomeMessage)
- Specified by:
setWelcomeMessagein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getWelcomeMessage
public java.lang.String getWelcomeMessage()
- Specified by:
getWelcomeMessagein interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
addLostReply
public final void addLostReply(java.lang.String reply)
- Specified by:
addLostReplyin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
addLostReply
public final void addLostReply(unlimited.core.transfers.io.FCReply lostReply)
- Specified by:
addLostReplyin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getLostReplies
public final unlimited.core.transfers.io.FCReply getLostReplies(java.lang.String... replyCodes)
- Specified by:
getLostRepliesin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getLostReply
public final unlimited.core.transfers.io.FCReply getLostReply(java.lang.String replyCode)
- Specified by:
getLostReplyin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
setIPTOSIfRequired
public void setIPTOSIfRequired() throws java.io.IOException- Specified by:
setIPTOSIfRequiredin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge- Throws:
java.io.IOException
-
getSysKey
public java.lang.String getSysKey()
- Specified by:
getSysKeyin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getControlPort
public int getControlPort()
- Specified by:
getControlPortin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
isSsl
public boolean isSsl()
- Specified by:
isSslin interfaceunlimited.core.util.common.FCSiteIfc
-
getHost
public java.lang.String getHost()
- Specified by:
getHostin interfaceunlimited.core.util.common.FCSiteIfc
-
getPort
public int getPort()
- Specified by:
getPortin interfaceunlimited.core.util.common.FCSiteIfc
-
getResolvedSiteDO
public unlimited.core.util.common.FCSiteIfc getResolvedSiteDO()
-
registerLookUp
public void registerLookUp(unlimited.core.util.common.FCSiteIfc lookup)
- Specified by:
registerLookUpin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
getIsFCServerSupplier
public java.util.function.Supplier<java.lang.Boolean> getIsFCServerSupplier()
- Specified by:
getIsFCServerSupplierin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
setIsFCServerSupplier
public void setIsFCServerSupplier(java.util.function.Supplier<java.lang.Boolean> isFCServerSupplier)
- Specified by:
setIsFCServerSupplierin interfaceunlimited.core.transfers.io.FCClientControlSocketBridge
-
-