Java Globus API: Class GridFTPClient

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(String host, int port)
          Constructs client and connects it to the remote server.
 
Method Summary
 void authenticate(GSSCredential credential)
          Performs authentication with specified user credentials.
protected  void checkGridFTPSupport()
          assure that the server supports extended transfer features; throw exception if not
 void extendedGet(String remoteFileName, long size, DataSink sink, MarkerListener mListener)
          Retrieves file from remote server using extended block mode.
 void extendedPut(String remoteFileName, DataSource source, MarkerListener mListener)
          Stores file at remote server using extended block mode.
 void extendedTransfer(String remoteSrcFile, GridFTPClient destination, String remoteDstFile, MarkerListener mListener)
          Performs a third-party transfer between two servers using extended block mode.
 void get(String remoteFileName, DataSink sink, MarkerListener mListener)
          Behaves almost like FTPClient.get().
 void get(String remoteFileName, File localFile)
           
 Authorization getAuthorization()
          Returns authorization method for the control channel.
 DataChannelAuthentication getDataChannelAuthentication()
          Returns data channel authentication mode (DCAU).
 int getDataChannelProtection()
          Returns data channel protection level.
 Vector list()
          Performs remote directory listing, like FTPClient.list().
 void list(String filter, 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(File localFile, String remoteFileName, boolean append)
           
 void put(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, in the following way: First see if server supports "SBUF" and if so, use it.
 
Methods inherited from class org.globus.ftp.FTPClient
abort, actualGet, actualList, actualPut, actualSetMode, asynchGet, asynchPut, authorize, changeDir, checkTransferParams, close, deleteDir, deleteFile, exists, getCurrentDir, getFeatureList, getLastModified, getSize, goUpDir, isActiveMode, isFeatureSupported, isPassiveMode, lastModified, list, makeDir, put, rename, setActive, setActive, setClientWaitParams, setLocalActive, setLocalPassive, setLocalPassive, setOptions, setPassive, setPassiveMode, setProtectionBufferSize, setRestartMarker, setType, size, transfer, transferBegin, transferRun, transferStart, transferWait
 
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(String host,
                     int port)
              throws 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(GSSCredential credential)
                  throws IOException,
                         ServerException
Performs authentication with specified user credentials.
Parameters:
credential - user credentials to use.
Throws:
IOException - on i/o error
ServerException - on server refusal or faulty server behavior

list

public Vector list()
            throws ServerException,
                   ClientException,
                   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

list

public void list(String filter,
                 String modifier,
                 DataSink sink)
          throws ServerException,
                 ClientException,
                 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
Following copied from class: org.globus.ftp.FTPClient
Parameters:
filter - remote list command file filter, eg. "*"
modifier - remote list command modifier, eg. "-d"
sink - data destination

listCheck

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

setMode

public void setMode(int mode)
             throws IOException,
                    ServerException
Sets transfer mode.
Overrides:
setMode in class FTPClient
Parameters:
mode - should be Session.MODE_STREAM, MODE_EBLOCK, or MODE_BLOCK

setTCPBufferSize

public void setTCPBufferSize(int size)
                      throws IOException,
                             ServerException
Sets remote server TCP buffer size, in the following way: First see if server supports "SBUF" and if so, use it. If not, try the following commands until success: "SITE RETRBUFSIZE", "SITE RBUFSZ", "SITE RBUFSIZ", "SITE STORBUFIZE", "SITE SBUFSZ", "SITE SBUFSIZ", "SITE BUFSIZE". Returns normally if the server confirms successfull setting of the remote buffer size, both for sending and for receiving data. Otherwise, throws 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 IOException,
                                      ServerException
Sets remote server to striped passive server mode (SPAS).

setStripedActive

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

setLocalStripedPassive

public HostPortList setLocalStripedPassive(int port,
                                           int queue)
                                    throws 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

setLocalStripedPassive

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

setLocalStripedActive

public void setLocalStripedActive()
                           throws ClientException,
                                  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.

get

public void get(String remoteFileName,
                DataSink sink,
                MarkerListener mListener)
         throws IOException,
                ClientException,
                ServerException
Behaves almost like FTPClient.get(). Additionally, throws ClientException if Mode E is needed.
Overrides:
get in class FTPClient
Following copied from class: org.globus.ftp.FTPClient
Parameters:
remoteFileName - remote file name
sink - sink to which the data will be written
mListener - restart marker listener (currently not used)

extendedGet

public void extendedGet(String remoteFileName,
                        long size,
                        DataSink sink,
                        MarkerListener mListener)
                 throws 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

put

public void put(String remoteFileName,
                DataSource source,
                MarkerListener mListener)
         throws IOException,
                ServerException,
                ClientException
Behaves almost like FTPClient.put(). Additionally, throws exception if Mode E is needed.
Overrides:
put in class FTPClient
Following copied from class: org.globus.ftp.FTPClient
Parameters:
remoteFileName - remote file name
source - data will be read from here
mListener - restart marker listener (currently not used)

extendedPut

public void extendedPut(String remoteFileName,
                        DataSource source,
                        MarkerListener mListener)
                 throws 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

extendedTransfer

public void extendedTransfer(String remoteSrcFile,
                             GridFTPClient destination,
                             String remoteDstFile,
                             MarkerListener mListener)
                      throws 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
dstServer - destination server
remoteDstFile - destination filename
append - enables append mode, if true file will be appened.
listener - transer progress listener. Can be set to null.

checkGridFTPSupport

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

setDataChannelAuthentication

public void setDataChannelAuthentication(DataChannelAuthentication type)
                                  throws IOException,
                                         ServerException
Sets data channel authentication mode (DCAU)
Parameters:
type; - for 2-party transfer must be DataChannelAuthentication.SELF or DataChannelAuthentication.NONE

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 IOException,
                                     ServerException
Sets data channel protection level (PROT).

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.

get

public void get(String remoteFileName,
                File localFile)
         throws IOException,
                ClientException,
                ServerException
Overrides:
get in class FTPClient

put

public void put(File localFile,
                String remoteFileName,
                boolean append)
         throws IOException,
                ServerException,
                ClientException
Overrides:
put in class FTPClient