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 |
---|
title | Enable FileOp Logging |
---|
borderStyle | solid |
---|
|
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 |
---|
title | Common Imports |
---|
borderStyle | solid |
---|
|
import java.net.URI;
import ncsa.tools.trebuchet.core.util.Trebuchet;
import ncsa.commons.types.Configuration;
|
Code Block |
---|
title | Variable Definitions |
---|
borderStyle | solid |
---|
|
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 |
---|
title | Copy a Single URI to a target URI with no specific Configuration |
---|
borderStyle | solid |
---|
|
Trebuchet.copy( sourceFile, targetDirectorySSH, new Configuration() );
|
Code Block |
---|
title | Copy a Single URI to a target URI tweaking GridFTP performance settings |
---|
borderStyle | solid |
---|
|
Configuration configuration = new Configuration();
configuration.addLongProperty( "tcpBufferSize", 15384 );
configuration.addLongProperty( "localTCPBufferSize", 15384 );
Trebuchet.copy( sourceFile, targetDirectoryFTP, configuration );
|
Code Block |
---|
title | Set a Credential for Use with GridFTP |
---|
borderStyle | solid |
---|
|
Configuration configuration = new Configuration();
NCSAAttribute a = new NCSAAttribute();
a.setName( "credential" );
a.setActualValue( credential );
configuration.addAttribute( a );
|