|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
org.globus.ftp.vanilla
Class FTPServerFacade
java.lang.Object | +--org.globus.ftp.vanilla.FTPServerFacade
- Direct Known Subclasses:
- GridFTPServerFacade
- public class FTPServerFacade
- extends java.lang.Object
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.
| Nested Class Summary | |
protected class |
FTPServerFacade.LocalControlChannel
This inner class represents a local control channel. |
| Field Summary | |
static int |
ANY_PORT
local server socket parameter; used in setPassive() |
protected DataChannelFactory |
dataChannelFactory
|
static int |
DEFAULT_QUEUE
local server socket parameter; used in setPassive() |
protected FTPServerFacade.LocalControlChannel |
localControlChannel
|
protected java.net.ServerSocket |
server
|
protected Session |
session
|
protected SocketBox |
socketBox
|
protected TaskThread |
taskThread
|
| Constructor Summary | |
FTPServerFacade()
|
|
| Method Summary | |
void |
abort()
close data channels, but not control, nor the server |
void |
authorize()
No need for parameters; locally you are always authorized. |
static void |
cannotPropagateError(java.lang.Throwable e)
Data channels are operated in multithreaded manner and they pass information (including exceptions) to the user using the local control channel. |
void |
close()
|
protected ActiveConnectTask |
createActiveConnectTask(HostPort hp,
SocketBox box)
|
protected ActiveStartTransferTask |
createActiveStartTransferTask(DataSink sink,
SocketBox box,
TransferContext context)
|
protected ActiveStartTransferTask |
createActiveStartTransferTask(DataSource source,
SocketBox box,
TransferContext context)
|
protected PassiveConnectTask |
createPassiveConnectTask(DataSink sink,
TransferContext context)
|
protected PassiveConnectTask |
createPassiveConnectTask(DataSource source,
TransferContext context)
|
protected TransferContext |
createTransferContext()
|
protected void |
exceptionToControlChannel(java.lang.Throwable e,
java.lang.String msg)
Convert the exception to a negative 451 reply, and pipe it to the control channel. |
static void |
exceptionToControlChannel(java.lang.Throwable e,
java.lang.String msg,
BasicServerControlChannel control)
Convert the exception to a negative 451 reply, and pipe it to the provided control channel. |
void |
finalize()
|
BasicClientControlChannel |
getControlChannel()
Use this method to get the client end of the local control channel. |
protected static java.lang.String |
getLocalHostAddress()
(copied from new version of util.Util) Returns the ip address of the local machine. |
Session |
getSession()
|
void |
retrieve(DataSource source)
Asynchronous; return before completion. |
protected void |
runTask(Task task)
Use this as an interface to the local manager thread. |
void |
setActive(HostPort hp)
Asynchronous; return before completion. |
void |
setOptions(Options opts)
Do nothing; this class does not support any options |
HostPort |
setPassive()
Behave like setPassive(ANY_PORT, DEFAULT_QUEUE) |
HostPort |
setPassive(int port,
int queue)
Start the local server |
void |
setProtectionBufferSize(int size)
|
void |
setTransferMode(int mode)
|
void |
setTransferType(int type)
|
void |
store(DataSink sink)
Asynchronous; return before completion. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
ANY_PORT
public static final int ANY_PORT
- local server socket parameter; used in setPassive()
- See Also:
- Constant Field Values
DEFAULT_QUEUE
public static final int DEFAULT_QUEUE
- local server socket parameter; used in setPassive()
- See Also:
- Constant Field Values
session
protected Session session
localControlChannel
protected FTPServerFacade.LocalControlChannel localControlChannel
dataChannelFactory
protected DataChannelFactory dataChannelFactory
server
protected java.net.ServerSocket server
taskThread
protected TaskThread taskThread
socketBox
protected SocketBox socketBox
| Constructor Detail |
FTPServerFacade
public FTPServerFacade()
| Method Detail |
cannotPropagateError
public static void cannotPropagateError(java.lang.Throwable e)
- 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
public BasicClientControlChannel 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
public Session 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
public void setOptions(Options opts)
- Do nothing; this class does not support any options
setPassive
public HostPort setPassive() throws java.io.IOException
- Behave like setPassive(ANY_PORT, DEFAULT_QUEUE)
java.io.IOException
setPassive
public HostPort setPassive(int port, int queue) throws java.io.IOException
- 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
java.io.IOException
setActive
public void setActive(HostPort hp) throws java.net.UnknownHostException, java.io.IOException
- 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.
java.net.UnknownHostExceptionjava.io.IOException
exceptionToControlChannel
protected void exceptionToControlChannel(java.lang.Throwable e,
java.lang.String msg)
- Convert the exception to a negative 451 reply, and pipe
it to the control channel.
exceptionToControlChannel
public static void exceptionToControlChannel(java.lang.Throwable e,
java.lang.String msg,
BasicServerControlChannel control)
- Convert the exception to a negative 451 reply, and pipe
it to the provided control channel.
store
public void store(DataSink sink)
- 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
public void retrieve(DataSource source)
- 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
public void abort()
throws java.io.IOException
- close data channels, but not control, nor the server
java.io.IOException
close
public void close()
throws java.io.IOException
java.io.IOException
finalize
public void finalize()
- Overrides:
finalizein classjava.lang.Object
getLocalHostAddress
protected static java.lang.String getLocalHostAddress()
- (copied from new version of util.Util)
Returns the ip address of the local machine.
If the 'ip' system property is defined it is returned,
otherwise, the local ip address is lookup using the
InetAddressclass. In case the lookup fails, the address 127.0.0.1 is returned.- Returns:
- local ip address
runTask
protected void runTask(Task task)
- Use this as an interface to the local manager thread.
This submits the task to the thread queue.
The thread will perform it when it's ready with other
waiting tasks.
createActiveConnectTask
protected ActiveConnectTask createActiveConnectTask(HostPort hp, SocketBox box)
createPassiveConnectTask
protected PassiveConnectTask createPassiveConnectTask(DataSource source, TransferContext context)
createPassiveConnectTask
protected PassiveConnectTask createPassiveConnectTask(DataSink sink, TransferContext context)
createActiveStartTransferTask
protected ActiveStartTransferTask createActiveStartTransferTask(DataSource source, SocketBox box, TransferContext context)
createActiveStartTransferTask
protected ActiveStartTransferTask createActiveStartTransferTask(DataSink sink, SocketBox box, TransferContext context)
createTransferContext
protected TransferContext createTransferContext()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||