GNDMS 0.6.0
RESTful verison of GNDMS
|
Public Member Functions | |
Integer | getBufferSize () |
void | setBufferSize (Integer bufferSize) |
void | setFiles (Map< String, String > fm) |
Prepares the transfer of a list of files. | |
void | setFiles (String sfn, String tfn) |
This method is provided for convenience and behaves like the above method. | |
Map< String, String > | getFiles () |
void | prepareTransfer () throws ServerException, IOException, ClientException |
This method can be called before the actual transfer is performed. | |
Pattern | makeFileFilter () |
long | estimateTransferSize () throws IOException, ServerException, ClientException |
Estimates the size of a prepared download or transfer. | |
void | performTransfer (MarkerListener list) |
Performs the prepared transfer. | |
void | performPersistentTransfer (@NotNull PersistentMarkerListener markerListener) throws ServerException, IOException, ClientException |
Performs the prepared transfer using a persistent marker listener. | |
void | setClients (GridFTPClient sclnt, GridFTPClient tclnt) |
Sets the source and target clients for a third party transfer. | |
GridFTPClient | getSourceClient () |
void | setSourceClient (GridFTPClient sourceClient) |
GridFTPClient | getTargetClient () |
void | setDestinationClient (GridFTPClient destinationClient) |
String | getSourcePath () |
void | setSourcePath (String sourcePath) |
String | getDestinationPath () |
void | setDestinationPath (String destinationPath) |
Static Public Attributes | |
static final String | ELLIPSE = Pattern.quote( "..." ) |
Protected Member Functions | |
void | setupClient (GridFTPClient cnt) throws ServerException, IOException |
Protected Attributes | |
final Logger | logger = LoggerFactory.getLogger( this.getClass() ) |
final Pattern | ellipse = Pattern.compile( "(.*)"+ ELLIPSE + "$" ) |
Private Member Functions | |
boolean | hasEllipse (Map< String, String > files) |
void | resumeSource (FTPTransferState stat) throws ServerException, IOException |
This loads the ftp byte range args from a FTPTransferState object into a GridFTPClient. | |
Map< String, String > | fetchFileListing (Pattern pattern) throws ClientException, ServerException, IOException |
String | enrichExceptionMsg (String msg) |
String | enrichExceptionMsg (String msg, String fn) |
Static Private Member Functions | |
static String | printWithNull (String o) |
static String | printWithNull (GridFTPClient o) |
Private Attributes | |
GridFTPClient | sourceClient |
GridFTPClient | destinationClient |
Map< String, String > | files |
String | sourcePath |
String | destinationPath |
Integer | bufferSize |
User: mjorra, Date: 30.09.2008, Time: 13:02:37
long de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.estimateTransferSize | ( | ) | throws IOException, ServerException, ClientException |
Estimates the size of a prepared download or transfer.
{ String lastFileName = null; // required for nice exceptions names try { prepareTransfer( ); sourceClient.setType( Session.TYPE_ASCII ); Set<String> src = files.keySet(); long size = 0; for ( String aSrc : src ) { // todo evaluate usage of msld command lastFileName = aSrc; size += sourceClient.getSize( lastFileName ); } return size; } catch ( ServerException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage(), lastFileName ) ); throw ex; } catch ( ClientException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage(), lastFileName ) ); throw ex; } catch ( IOException ex ) { IOException ioe = new IOException( enrichExceptionMsg( ex.getMessage(), lastFileName ) ); ioe.setStackTrace( ex.getStackTrace() ); throw ioe; } }
void de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.performPersistentTransfer | ( | @NotNull PersistentMarkerListener | markerListener | ) | throws ServerException, IOException, ClientException |
Performs the prepared transfer using a persistent marker listener.
If the listener has a state, i.e. a currentFile and a range, then the transfer will uses this state to continue the transfer.
{ String currentFile = null; try { prepareTransfer( ); if( destinationClient == null || files == null ) throw new IllegalStateException( ); setupClient ( sourceClient ); setupClient ( destinationClient ); destinationClient.changeDir( destinationPath ); sourceClient.setActive( destinationClient.setPassive() ); boolean resume = markerListener.hasCurrentFile(); String resumeFile = markerListener.getCurrentFile(); for( String fn : files.keySet() ) { currentFile = fn; // if transfer is resumed skip files til last transferred file is found. if( resume && currentFile.equals( resumeFile ) ) { resume = false; resumeSource( markerListener.getTransferState() ); } if( !resume ) { markerListener.setCurrentFile( currentFile ); String destinationFile = files.get( currentFile ); sourceClient.extendedTransfer( currentFile, destinationClient, ( destinationFile == null ? currentFile : destinationFile ), markerListener ); } } } catch ( ServerException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage(), currentFile ) ); throw ex; } catch ( ClientException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage(), currentFile ) ); throw ex; } catch ( IOException ex ) { IOException ioe = new IOException( enrichExceptionMsg( ex.getMessage(), currentFile ) ); ioe.setStackTrace( ex.getStackTrace() ); throw ioe; } }
void de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.performTransfer | ( | MarkerListener | list | ) |
Performs the prepared transfer.
NOTE: not implemented yet.
{ }
void de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.prepareTransfer | ( | ) | throws ServerException, IOException, ClientException |
This method can be called before the actual transfer is performed.
It ensures that the file set isn't empty. If it is empty the file listing will be requested from the source client.
This is useful if one would like to see the file listing befor the transfer starts.
{ if( sourceClient == null ) throw new IllegalStateException( enrichExceptionMsg( "no source client provided" ) ); try { if( sourcePath != null ) sourceClient.changeDir( sourcePath ); if( files == null || files.size( ) == 0 ) files = fetchFileListing( null ); else if( hasEllipse( files ) ) { logger.debug( "Ellipse detected, using awesome new feature." ); files = fetchFileListing( makeFileFilter() ); } } catch ( ServerException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage() ) ); throw ex; } catch ( ClientException ex ) { ex.setCustomMessage( enrichExceptionMsg( ex.getMessage() ) ); throw ex; } catch ( IOException ex ) { IOException ioe = new IOException( enrichExceptionMsg( ex.getMessage() ) ); ioe.setStackTrace( ex.getStackTrace() ); throw ioe; } }
void de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.setClients | ( | GridFTPClient | sclnt, |
GridFTPClient | tclnt | ||
) |
Sets the source and target clients for a third party transfer.
The clients will be configured according to their desired roles, before any ftp action takes place. So don't change them after calling this method.
sclnt | the source client. |
tclnt | the target client. |
{ setSourceClient( sclnt ); setDestinationClient( tclnt ); }
void de.zib.gndms.taskflows.filetransfer.server.network.GNDMSFileTransfer.setFiles | ( | Map< String, String > | fm | ) |
Prepares the transfer of a list of files.
fm | The given map consists of pairs of source and target file names. The target file name may be null, if it should be identical to the source files name. |
This resets any previously prepared download stats.
{ files = fm; }