Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Trebuchet

Trebuchet is a multi-scheme file-transfer API written in Java.

Distributions

Version 0.10.6 (post-Eclipse)

Trebuchet Libray + Client(Linux)
Trebuchet Libray + Client(MacOSX)
Trebuchet Libray + Client(Windows)

Clients

Trebuchet RC - An Eclipse RCP based client

Logging

Trebuchet provides a detailed mechanism for getting verbose output in the form of FileOperation events.

Code Block
titleEnable FileOp Logging
borderStylesolid
Configuration configuration = new Configuration();
configuration.addProperty( "fileOpLog", "/tmp/trebuchet-fileop.log" );
configuration.addBooleanProperty( "verbose", true );

You may also implement a custom FileOpListener as described here.

Examples

The primary entry point for use in Java-based programs is ncsa.tools.trebuchet.core.util.Trebuchet. This is a static utility class which provides for a some common use-cases.

For the examples, we'll use the following defintions and imports:

Code Block
titleCommon Imports
borderStylesolid
import java.net.URI;
import ncsa.tools.trebuchet.core.util.Trebuchet;
import ncsa.commons.types.Configuration;
Code Block
titleVariable Definitions
borderStylesolid
URI sourceFile = new URI( "gridftp://source.host.edu/directory/file.xml" );
URI targetDirectorySSH = new URI( "ssh://target.host.edu/directory/destination" );
URI targetDirectoryFTP = new URI( "gridftp://target.host.edu/directory/destination" );
URI sshWithUserPass = new URI( "ssh://user:password@source.host.edu/directory/file.xml" );

Copying Files/Directories

Code Block
titleCopy a Single URI to a target URI with no specific Configuration
borderStylesolid
Trebuchet.copy( sourceFile, targetDirectorySSH, new Configuration() );
Code Block
titleCopy a Single URI to a target URI tweaking GridFTP performance settings
borderStylesolid
Configuration configuration = new Configuration();
configuration.addLongProperty( "tcpBufferSize", 15384 );
configuration.addLongProperty( "localTCPBufferSize", 15384 );

Trebuchet.copy( sourceFile, targetDirectoryFTP, configuration );
Code Block
titleSet a Credential for Use with GridFTP
borderStylesolid
Configuration configuration = new Configuration();
NCSAAttribute a = new NCSAAttribute();
a.setName( "credential" );
a.setActualValue( credential );
configuration.addAttribute( a );