cgl.narada.gridapps.nbgridftp.gridftpext
Class NBGridFTPClient

java.lang.Object
  extended by org.globus.ftp.FTPClient
      extended by cgl.narada.gridapps.nbgridftp.gridftpext.NBGridFTPClient

public class NBGridFTPClient
extends org.globus.ftp.FTPClient


Field Summary
protected  org.globus.ftp.extended.GridFTPServerFacade gLocalServer
           
protected  org.globus.ftp.GridFTPSession gSession
           
 
Fields inherited from class org.globus.ftp.FTPClient
controlChannel, dateFormat, localServer, session
 
Constructor Summary
NBGridFTPClient(String host, int port)
          Constructs client and connects it to the remote server.
 
Method Summary
protected  org.globus.ftp.vanilla.TransferState actualPut(String remoteFileName, org.globus.ftp.DataSource source, org.globus.ftp.MarkerListener mListener, boolean append)
           
 void authenticate(GSSCredential credential)
          Performs authentication with specified user credentials.
protected  void checkNBGridFTPSupport()
          assure that the server supports extended transfer features; throw exception if not
 void close()
          Closes connection.
 void extendedGet(String remoteFileName, long size, org.globus.ftp.DataSink sink, org.globus.ftp.MarkerListener mListener)
          Retrieves file from remote server using extended block mode.
 void extendedPut(String remoteFileName, org.globus.ftp.DataSource source, org.globus.ftp.MarkerListener mListener)
          Stores file at remote server using extended block mode.
 void extendedTransfer(String remoteSrcFile, NBGridFTPClient destination, String remoteDstFile, org.globus.ftp.MarkerListener mListener)
          Performs a third-party transfer between two servers using extended block mode.
 void get(String remoteFileName, org.globus.ftp.DataSink sink, org.globus.ftp.MarkerListener mListener)
          Behaves almost like FTPClient.get().
 void get(String remoteFileName, File localFile)
           
 org.globus.gsi.gssapi.auth.Authorization getAuthorization()
          Returns authorization method for the control channel.
 org.globus.ftp.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, org.globus.ftp.DataSink sink)
          Use this method to list remote directory while in parallel transfer mode.
protected  void listCheck()
           
 void put(File localFile, String remoteFileName, boolean append)
           
 void put(String remoteFileName, org.globus.ftp.DataSource source, org.globus.ftp.MarkerListener mListener)
          Behaves almost like FTPClient.put().
 void setActive()
          Sets remote server active, telling it to connect to the client.
 void setActive(org.globus.ftp.HostPort hostPort)
          Sets remote server active, telling it to connect to the given address.
 void setAuthorization(org.globus.gsi.gssapi.auth.Authorization authorization)
          Sets authorization method for the control channel.
 void setDataChannelAuthentication(org.globus.ftp.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.
 org.globus.ftp.HostPortList setLocalStripedPassive()
          Behaves like setLocalStripedPassive(FTPServerFacade.ANY_PORT, FTPServerFacade.DEFAULT_QUEUE)
 org.globus.ftp.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(org.globus.ftp.HostPortList hpl)
          Sets remote server to striped active server mode (SPOR).
 org.globus.ftp.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, actualSetMode, asynchGet, asynchPut, authorize, changeDir, checkTransferParams, deleteDir, deleteFile, exists, getCurrentDir, getFeatureList, getLastModified, getSize, goUpDir, isActiveMode, isFeatureSupported, isPassiveMode, lastModified, list, makeDir, put, rename, 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 org.globus.ftp.GridFTPSession gSession

gLocalServer

protected org.globus.ftp.extended.GridFTPServerFacade gLocalServer
Constructor Detail

NBGridFTPClient

public NBGridFTPClient(String host,
                       int port)
                throws IOException,
                       org.globus.ftp.exception.ServerException
Constructs client and connects it to the remote server.

Parameters:
host - remote server host
port - remote server port
Throws:
IOException
org.globus.ftp.exception.ServerException
Method Detail

authenticate

public void authenticate(GSSCredential credential)
                  throws IOException,
                         org.globus.ftp.exception.ServerException
Performs authentication with specified user credentials.

Parameters:
credential - user credentials to use.
Throws:
IOException - on i/o error
org.globus.ftp.exception.ServerException - on server refusal or faulty server behavior

list

public Vector list()
            throws org.globus.ftp.exception.ServerException,
                   org.globus.ftp.exception.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 org.globus.ftp.FTPClient
Throws:
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException
IOException

list

public void list(String filter,
                 String modifier,
                 org.globus.ftp.DataSink sink)
          throws org.globus.ftp.exception.ServerException,
                 org.globus.ftp.exception.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 org.globus.ftp.FTPClient
Throws:
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException
IOException

listCheck

protected void listCheck()
                  throws org.globus.ftp.exception.ClientException
Overrides:
listCheck in class org.globus.ftp.FTPClient
Throws:
org.globus.ftp.exception.ClientException

setMode

public void setMode(int mode)
             throws IOException,
                    org.globus.ftp.exception.ServerException
Sets transfer mode.

Overrides:
setMode in class org.globus.ftp.FTPClient
Parameters:
mode - should be Session.MODE_STREAM, MODE_EBLOCK, or MODE_BLOCK
Throws:
IOException
org.globus.ftp.exception.ServerException

setTCPBufferSize

public void setTCPBufferSize(int size)
                      throws IOException,
                             org.globus.ftp.exception.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.

Throws:
IOException
org.globus.ftp.exception.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 org.globus.ftp.HostPortList setStripedPassive()
                                              throws IOException,
                                                     org.globus.ftp.exception.ServerException
Sets remote server to striped passive server mode (SPAS).

Throws:
IOException
org.globus.ftp.exception.ServerException

setStripedActive

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

Throws:
IOException
org.globus.ftp.exception.ServerException

setLocalStripedPassive

public org.globus.ftp.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
Throws:
IOException

setLocalStripedPassive

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

Throws:
IOException

setLocalStripedActive

public void setLocalStripedActive()
                           throws org.globus.ftp.exception.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.

Throws:
org.globus.ftp.exception.ClientException
IOException

get

public void get(String remoteFileName,
                org.globus.ftp.DataSink sink,
                org.globus.ftp.MarkerListener mListener)
         throws IOException,
                org.globus.ftp.exception.ClientException,
                org.globus.ftp.exception.ServerException
Behaves almost like FTPClient.get(). Additionally, throws ClientException if Mode E is needed.

Overrides:
get in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ClientException
org.globus.ftp.exception.ServerException

extendedGet

public void extendedGet(String remoteFileName,
                        long size,
                        org.globus.ftp.DataSink sink,
                        org.globus.ftp.MarkerListener mListener)
                 throws IOException,
                        org.globus.ftp.exception.ClientException,
                        org.globus.ftp.exception.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
Throws:
IOException
org.globus.ftp.exception.ClientException
org.globus.ftp.exception.ServerException

put

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

Overrides:
put in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

extendedPut

public void extendedPut(String remoteFileName,
                        org.globus.ftp.DataSource source,
                        org.globus.ftp.MarkerListener mListener)
                 throws IOException,
                        org.globus.ftp.exception.ServerException,
                        org.globus.ftp.exception.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
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

extendedTransfer

public void extendedTransfer(String remoteSrcFile,
                             NBGridFTPClient destination,
                             String remoteDstFile,
                             org.globus.ftp.MarkerListener mListener)
                      throws IOException,
                             org.globus.ftp.exception.ServerException,
                             org.globus.ftp.exception.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
destination - destination server
remoteDstFile - destination filename
mListener - transer progress listener. Can be set to null.
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

checkNBGridFTPSupport

protected void checkNBGridFTPSupport()
                              throws IOException,
                                     org.globus.ftp.exception.ServerException
assure that the server supports extended transfer features; throw exception if not

Throws:
IOException
org.globus.ftp.exception.ServerException

setDataChannelAuthentication

public void setDataChannelAuthentication(org.globus.ftp.DataChannelAuthentication type)
                                  throws IOException,
                                         org.globus.ftp.exception.ServerException
Sets data channel authentication mode (DCAU)

Parameters:
type - for 2-party transfer must be DataChannelAuthentication.SELF or DataChannelAuthentication.NONE
Throws:
IOException
org.globus.ftp.exception.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 org.globus.ftp.DataChannelAuthentication getDataChannelAuthentication()
Returns data channel authentication mode (DCAU).

Returns:
data channel authentication mode

setDataChannelProtection

public void setDataChannelProtection(int protection)
                              throws IOException,
                                     org.globus.ftp.exception.ServerException
Sets data channel protection level (PROT).

Throws:
IOException
org.globus.ftp.exception.ServerException

getDataChannelProtection

public int getDataChannelProtection()
Returns data channel protection level.

Returns:
data channel protection level

setAuthorization

public void setAuthorization(org.globus.gsi.gssapi.auth.Authorization authorization)
Sets authorization method for the control channel.

Parameters:
authorization - authorization method.

getAuthorization

public org.globus.gsi.gssapi.auth.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,
                org.globus.ftp.exception.ClientException,
                org.globus.ftp.exception.ServerException
Overrides:
get in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ClientException
org.globus.ftp.exception.ServerException

put

public void put(File localFile,
                String remoteFileName,
                boolean append)
         throws IOException,
                org.globus.ftp.exception.ServerException,
                org.globus.ftp.exception.ClientException
Overrides:
put in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

actualPut

protected org.globus.ftp.vanilla.TransferState actualPut(String remoteFileName,
                                                         org.globus.ftp.DataSource source,
                                                         org.globus.ftp.MarkerListener mListener,
                                                         boolean append)
                                                  throws IOException,
                                                         org.globus.ftp.exception.ServerException,
                                                         org.globus.ftp.exception.ClientException
Overrides:
actualPut in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

setActive

public void setActive(org.globus.ftp.HostPort hostPort)
               throws IOException,
                      org.globus.ftp.exception.ServerException
Sets remote server active, telling it to connect to the given address.

Overrides:
setActive in class org.globus.ftp.FTPClient
Parameters:
hostPort - the address to which the server should connect
Throws:
IOException
org.globus.ftp.exception.ServerException

setActive

public void setActive()
               throws IOException,
                      org.globus.ftp.exception.ServerException,
                      org.globus.ftp.exception.ClientException
Sets remote server active, telling it to connect to the client. setLocalPassive() must be called beforehand.

Overrides:
setActive in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ServerException
org.globus.ftp.exception.ClientException

close

public void close()
           throws IOException,
                  org.globus.ftp.exception.ServerException
Closes connection. Sends QUIT and closes connection even if the server reply was not positive. Also, closes the local server.

Overrides:
close in class org.globus.ftp.FTPClient
Throws:
IOException
org.globus.ftp.exception.ServerException


For comments and suggestions please send e-mail to The NaradaBrokering Project