GridFTPClient (Java Globus API)

org.globus.ftp
Class GridFTPClient

java.lang.Object
  |
  +--org.globus.ftp.FTPClient
        |
        +--org.globus.ftp.GridFTPClient

public class GridFTPClient
extends FTPClient

This is the main user interface for GridFTP operations. Use this class for client - server or third party transfers with mode E, parallelism, markers, striping or GSI authentication. Consult the manual for general usage.


Field Summary
protected  GridFTPServerFacade gLocalServer
           
protected  GridFTPSession gSession
           
 
Fields inherited from class org.globus.ftp.FTPClient
controlChannel, dateFormat, localServer, session
 
Constructor Summary
GridFTPClient(java.lang.String host, int port)
          Constructs client and connects it to the remote server.
 
Method Summary
 void authenticate(GlobusProxy proxy)
          Performs authentication with specified user credentials.
protected  void checkGridFTPSupport()
          assure that the server supports extended transfer features; throw exception if not
 void extendedGet(java.lang.String remoteFileName, long size, DataSink sink, MarkerListener mListener)
          Retrieves file from remote server using extended block mode.
 void extendedPut(java.lang.String remoteFileName, DataSource source, MarkerListener mListener)
          Stores file at remote server using extended block mode.
 void extendedTransfer(java.lang.String remoteSrcFile, GridFTPClient destination, java.lang.String remoteDstFile, MarkerListener mListener)
          Performs a third-party transfer between two servers using extended block mode.
 void get(java.lang.String remoteFileName, DataSink sink, MarkerListener mListener)
          Behaves almost like FTPClient.get().
 Authorization getAuthorization()
          Returns authorization method for the control channel.
 DataChannelAuthentication getDataChannelAuthentication()
          Returns data channel authentication mode (DCAU).
 int getDataChannelProtection()
          Returns data channel protection level.
 java.util.Vector list()
          Performs remote directory listing, like FTPClient.list().
 void list(java.lang.String filter, java.lang.String modifier, DataSink sink)
          Use this method to list remote directory while in parallel transfer mode.
protected  void listCheck()
          check performed at the beginning of list()
 void put(java.lang.String remoteFileName, DataSource source, MarkerListener mListener)
          Behaves almost like FTPClient.put().
 void setAuthorization(Authorization authorization)
          Sets authorization method for the control channel.
 void setDataChannelAuthentication(DataChannelAuthentication type)
          Sets data channel authentication mode (DCAU)
 void setDataChannelProtection(int protection)
          Sets data channel protection level (PROT).
 void setLocalNoDataChannelAuthentication()
          Sets compatibility mode with old GSIFTP server.
 void setLocalStripedActive()
          Starts local server in striped active mode.
 HostPortList setLocalStripedPassive()
          Behaves like setLocalStripedPassive(FTPServerFacade.ANY_PORT, FTPServerFacade.DEFAULT_QUEUE)
 HostPortList setLocalStripedPassive(int port, int queue)
          Starts local server in striped passive mode.
 void setLocalTCPBufferSize(int size)
          Sets local TCP buffer size (for both receiving and sending).
 void setMode(int mode)
          Sets transfer mode.
 void setStripedActive(HostPortList hpl)
          Sets remote server to striped active server mode (SPOR).
 HostPortList setStripedPassive()
          Sets remote server to striped passive server mode (SPAS).
 void setTCPBufferSize(int size)
          Sets remote server TCP buffer size (SBUF)
 
Methods inherited from class org.globus.ftp.FTPClient
abort, actualGet, actualList, actualPut, actualSetMode, authorize, changeDir, close, deleteDir, deleteFile, exists, getCurrentDir, getFeatureList, getLastModified, getSize, goUpDir, isFeatureSupported, makeDir, rename, setActive, setActive, setClientWaitParams, setLocalActive, setLocalPassive, setLocalPassive, setOptions, setPassive, setProtectionBufferSize, setRestartMarker, setType, transfer, transferRun
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gSession

protected GridFTPSession gSession

gLocalServer

protected GridFTPServerFacade gLocalServer
Constructor Detail

GridFTPClient

public GridFTPClient(java.lang.String host,
                     int port)
              throws java.io.IOException,
                     ServerException
Constructs client and connects it to the remote server.

Parameters:
host - remote server host
port - remote server port
Method Detail

authenticate

public void authenticate(GlobusProxy proxy)
                  throws java.io.IOException,
                         ServerException
Performs authentication with specified user credentials.

Parameters:
proxy - user credentials to use.
Throws:
java.io.IOException - on i/o error
ServerException - on server refusal or faulty server behavior

list

public java.util.Vector list()
                      throws ServerException,
                             ClientException,
                             java.io.IOException
Performs remote directory listing, like FTPClient.list(). Note: This method cannot be used in conjunction with parallelism or striping; set parallelism to 1 before calling it. Otherwise, use the parametrized list(). Unlike in vanilla FTP, here IMAGE mode is allowed. For more documentation, look at FTPClient.

Overrides:
list in class FTPClient
Returns:
Vector list of FileInfo objects, representing remote files
ServerException
ClientException
java.io.IOException

list

public void list(java.lang.String filter,
                 java.lang.String modifier,
                 DataSink sink)
          throws ServerException,
                 ClientException,
                 java.io.IOException
Use this method to list remote directory while in parallel transfer mode. The DataSink you support must be thread safe. Look at FTPClient for more documentation.

Overrides:
list in class FTPClient
Parameters:
filter - remote list command file filter, eg. "*"
modifier - remote list command modifier, eg. "-d"
sink - data destination
ServerException
ClientException
java.io.IOException

listCheck

protected void listCheck()
                  throws ClientException
Description copied from class: FTPClient
check performed at the beginning of list()

Overrides:
listCheck in class FTPClient
ClientException

setMode

public void setMode(int mode)
             throws java.io.IOException,
                    ServerException
Sets transfer mode.

Overrides:
setMode in class FTPClient
Parameters:
mode - should be Session.MODE_STREAM, MODE_EBLOCK, or MODE_BLOCK
java.io.IOException
ServerException

setTCPBufferSize

public void setTCPBufferSize(int size)
                      throws java.io.IOException,
                             ServerException
Sets remote server TCP buffer size (SBUF)

java.io.IOException
ServerException

setLocalTCPBufferSize

public void setLocalTCPBufferSize(int size)
Sets local TCP buffer size (for both receiving and sending). This method needs to be called BEFORE the local socket(s) get created. In other words, call it before calling setActive(), setPassive(), get(), put(), etc.


setStripedPassive

public HostPortList setStripedPassive()
                               throws java.io.IOException,
                                      ServerException
Sets remote server to striped passive server mode (SPAS).

java.io.IOException
ServerException

setStripedActive

public void setStripedActive(HostPortList hpl)
                      throws java.io.IOException,
                             ServerException
Sets remote server to striped active server mode (SPOR).

java.io.IOException
ServerException

setLocalStripedPassive

public HostPortList setLocalStripedPassive(int port,
                                           int queue)
                                    throws java.io.IOException
Starts local server in striped passive mode. Since the local server is not distributed, it will only listen on one socket.

Parameters:
port - required server port; can be set to FTPServerFacade.ANY_PORT
queue - max size of queue of awaiting new data channel connection requests
Returns:
the HostPortList of 1 element representing the socket where the local server is listening
java.io.IOException

setLocalStripedPassive

public HostPortList setLocalStripedPassive()
                                    throws java.io.IOException
Behaves like setLocalStripedPassive(FTPServerFacade.ANY_PORT, FTPServerFacade.DEFAULT_QUEUE)

java.io.IOException

setLocalStripedActive

public void setLocalStripedActive()
                           throws ClientException,
                                  java.io.IOException
Starts local server in striped active mode. setStripedPassive() must be called before that. This method takes no parameters. HostPortList of the remote server, known from the last call of setStripedPassive(), is stored internally and the local server will connect to this address.

ClientException
java.io.IOException

get

public void get(java.lang.String remoteFileName,
                DataSink sink,
                MarkerListener mListener)
         throws java.io.IOException,
                ClientException,
                ServerException
Behaves almost like FTPClient.get(). Additionally, throws ClientException if Mode E is needed.

Overrides:
get in class FTPClient
Parameters:
remoteFileName - remote file name
sink - sink to which the data will be written
mListener - restart marker listener (currently not used)
java.io.IOException
ClientException
ServerException

extendedGet

public void extendedGet(java.lang.String remoteFileName,
                        long size,
                        DataSink sink,
                        MarkerListener mListener)
                 throws java.io.IOException,
                        ClientException,
                        ServerException
Retrieves file from remote server using extended block mode.

Parameters:
remoteFileName - file to retrieve
size - number of bytes of remote file to transmit
sink - data sink to store the file
mListener - marker listener
java.io.IOException
ClientException
ServerException

put

public void put(java.lang.String remoteFileName,
                DataSource source,
                MarkerListener mListener)
         throws java.io.IOException,
                ServerException,
                ClientException
Behaves almost like FTPClient.put(). Additionally, throws exception if Mode E is needed.

Overrides:
put in class FTPClient
Parameters:
remoteFileName - remote file name
source - data will be read from here
mListener - restart marker listener (currently not used)
java.io.IOException
ServerException
ClientException

extendedPut

public void extendedPut(java.lang.String remoteFileName,
                        DataSource source,
                        MarkerListener mListener)
                 throws java.io.IOException,
                        ServerException,
                        ClientException
Stores file at remote server using extended block mode.

Parameters:
remoteFileName - file name to store
source - source for the data to transfer
mListener - marker listener
java.io.IOException
ServerException
ClientException

extendedTransfer

public void extendedTransfer(java.lang.String remoteSrcFile,
                             GridFTPClient destination,
                             java.lang.String remoteDstFile,
                             MarkerListener mListener)
                      throws java.io.IOException,
                             ServerException,
                             ClientException
Performs a third-party transfer between two servers using extended block mode. If server modes are unset, source will be set to active and destination to passive.

Parameters:
remoteSrcFile - source filename
remoteDstFile - destination filename
java.io.IOException
ServerException
ClientException

checkGridFTPSupport

protected void checkGridFTPSupport()
                            throws java.io.IOException,
                                   ServerException
assure that the server supports extended transfer features; throw exception if not

java.io.IOException
ServerException

setDataChannelAuthentication

public void setDataChannelAuthentication(DataChannelAuthentication type)
                                  throws java.io.IOException,
                                         ServerException
Sets data channel authentication mode (DCAU)

java.io.IOException
ServerException

setLocalNoDataChannelAuthentication

public void setLocalNoDataChannelAuthentication()
Sets compatibility mode with old GSIFTP server. Locally sets data channel authentication to NONE but does not send the command to the remote server (the server wouldn't understand it)


getDataChannelAuthentication

public DataChannelAuthentication getDataChannelAuthentication()
Returns data channel authentication mode (DCAU).

Returns:
data channel authentication mode

setDataChannelProtection

public void setDataChannelProtection(int protection)
                              throws java.io.IOException,
                                     ServerException
Sets data channel protection level (PROT).

java.io.IOException
ServerException

getDataChannelProtection

public int getDataChannelProtection()
Returns data channel protection level.

Returns:
data channel protection level

setAuthorization

public void setAuthorization(Authorization authorization)
Sets authorization method for the control channel.

Parameters:
authorization - authorization method.

getAuthorization

public Authorization getAuthorization()
Returns authorization method for the control channel.

Returns:
authorization method performed on the control channel.