Package org.globus.ftp.vanilla
Class FTPServerFacade
java.lang.Object
org.globus.ftp.vanilla.FTPServerFacade
- Direct Known Subclasses:
GridFTPServerFacade
This class is not ment directly for the users.
This class represents the part of the client responsible for data
channel management. Especially when the remote server is in the passive
mode, it behaves a lot like a local server. Thus its interface looks
very much like a server interface.
Current implementation is multithreaded. One thread is used for thread management and one for each transfer (this makes sense in GridFTP parallelism).
The public methods can generally be divided into setter methods and active methods. Active methods are setActive(), setPassive(), retrieve(), and store(), and setter methods are the remaining. Setter methods do not generally throw exceptions related to ftp. Settings are not checked for correctness until the server is asked to performed some action, which is done by active methods. So you are safe to cal setXX() methods with any argument you like, until you call one of the "active" methods mentioned above.
The managing thread is not started until one of the "active" methods is called: setActive(), retrieve(), or store(). These methods are asynchronous (return before completion) and the action is undertaken by the local manager thread. From this point on, all communication back to the caller is done through unidirectional local control channel. Information is communicated back to the user in form of FTP replies (instances of LocalReply). Generally, the sequence of replies should be the same as when communicating with remote server during the transfer (1xx intermediary reply; markers; final 226). Exceptions are serialized into 451 negative reply.
Current implementation is multithreaded. One thread is used for thread management and one for each transfer (this makes sense in GridFTP parallelism).
The public methods can generally be divided into setter methods and active methods. Active methods are setActive(), setPassive(), retrieve(), and store(), and setter methods are the remaining. Setter methods do not generally throw exceptions related to ftp. Settings are not checked for correctness until the server is asked to performed some action, which is done by active methods. So you are safe to cal setXX() methods with any argument you like, until you call one of the "active" methods mentioned above.
The managing thread is not started until one of the "active" methods is called: setActive(), retrieve(), or store(). These methods are asynchronous (return before completion) and the action is undertaken by the local manager thread. From this point on, all communication back to the caller is done through unidirectional local control channel. Information is communicated back to the user in form of FTP replies (instances of LocalReply). Generally, the sequence of replies should be the same as when communicating with remote server during the transfer (1xx intermediary reply; markers; final 226). Exceptions are serialized into 451 negative reply.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
This inner class represents a local control channel. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
local server socket parameter; used in setPassive()protected DataChannelFactory
static final int
local server socket parameter; used in setPassive()protected FTPServerFacade.LocalControlChannel
protected FTPControlChannel
protected HostPort
protected ServerSocket
protected Session
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
abort()
close data channels, but not control, nor the servervoid
No need for parameters; locally you are always authorized.static void
Data channels are operated in multithreaded manner and they pass information (including exceptions) to the user using the local control channel.void
close()
protected TransferContext
protected void
exceptionToControlChannel
(Throwable e, String msg) Convert the exception to a negative 451 reply, and pipe it to the control channel.static void
exceptionToControlChannel
(Throwable e, String msg, BasicServerControlChannel control) Convert the exception to a negative 451 reply, and pipe it to the provided control channel.Use this method to get the client end of the local control channel.void
retrieve
(DataSource source) Asynchronous; return before completion.void
Asynchronous; return before completion.void
setOptions
(Options opts) Do nothing; this class does not support any optionsBehave like setPassive(ANY_PORT, DEFAULT_QUEUE)setPassive
(int port, int queue) Start the local servervoid
setProtectionBufferSize
(int size) void
setTransferMode
(int mode) void
setTransferType
(int type) protected void
void
Asynchronous; return before completion.protected void
protected void
-
Field Details
-
ANY_PORT
public static final int ANY_PORTlocal server socket parameter; used in setPassive()- See Also:
-
DEFAULT_QUEUE
public static final int DEFAULT_QUEUElocal server socket parameter; used in setPassive()- See Also:
-
session
-
localControlChannel
-
dataChannelFactory
-
serverSocket
-
remoteControlChannel
-
remoteServerAddress
-
-
Constructor Details
-
FTPServerFacade
-
-
Method Details
-
cannotPropagateError
Data channels are operated in multithreaded manner and they pass information (including exceptions) to the user using the local control channel. In the unlikely event that it fails, there is no way to communicate the exception to the user. In such circumstances this method should be called to print the exception directly to console. -
getControlChannel
Use this method to get the client end of the local control channel. It is the only way to get the information of the current transfer state. -
getSession
- Returns:
- the session object associated with this server
-
authorize
public void authorize()No need for parameters; locally you are always authorized. -
setTransferType
public void setTransferType(int type) -
setTransferMode
public void setTransferMode(int mode) -
setProtectionBufferSize
public void setProtectionBufferSize(int size) -
setOptions
Do nothing; this class does not support any options -
setPassive
Behave like setPassive(ANY_PORT, DEFAULT_QUEUE)- Throws:
IOException
-
setPassive
Start the local server- Parameters:
port
- required server port; can be set to ANY_PORTqueue
- max size of queue of awaiting new connection requests- Returns:
- the server address
- Throws:
IOException
-
setActive
Asynchronous; return before completion. Connect to the remote server. Any exception that would occure will not be thrown but returned through the local control channel. -
exceptionToControlChannel
Convert the exception to a negative 451 reply, and pipe it to the control channel. -
exceptionToControlChannel
public static void exceptionToControlChannel(Throwable e, String msg, BasicServerControlChannel control) Convert the exception to a negative 451 reply, and pipe it to the provided control channel. -
store
Asynchronous; return before completion. Start the incoming transfer and store the file to the supplied data sink. Any exception that would occure will not be thrown but returned through the local control channel. -
retrieve
Asynchronous; return before completion. Start the outgoing transfer reading the data from the supplied data source. Any exception that would occure will not be thrown but returned through the local control channel. -
abort
close data channels, but not control, nor the server- Throws:
IOException
-
transferAbort
protected void transferAbort() -
unblockServer
protected void unblockServer() -
close
- Throws:
IOException
-
stopTaskThread
protected void stopTaskThread() -
createTransferContext
-