Difference between revisions of "Longhorn"

From Okapi Framework
Jump to navigation Jump to search
m (1 revision imported)
Line 10: Line 10:
* '''Stable release: http://bintray.com/okapi/Distribution/Longhorn
* '''Stable release: http://bintray.com/okapi/Distribution/Longhorn
* <del>Development release (snapshot): http://okapi.opentag.com/snapshots</del>  Development snapshots are not currently available.
* <del>Development release (snapshot): http://okapiframework.org/snapshots</del>  Development snapshots are not currently available.
To install Longhorn:
To install Longhorn:

Revision as of 09:50, 5 June 2016


Longhorn is a server application that allows you to execute Batch Configurations remotely on any set of input files. Batch Configurations which include pre-defined pipelines and filter configurations, can be exported from Rainbow.

The distribution also includes a client library to access the Longhorn Web services.

Download and Installation

To install Longhorn:

  • Unzip the distribution file on your server.
  • Follow the instructions provided with the readme file of the distribution.
  • Starting with m24, Longhorn requires Java 1.7.


To process files with Longhorn these steps are required:

  1. Create a temporary project
  2. Upload a Batch Configuration file into that project
  3. Upload the input files into that project
  4. Execute the project
  5. Download the output files
  6. Delete the project


There are three ways to access Longhorns functionality. There is

  • a REST interface,
  • a Java API and
  • an HTML client.

They can be used as described below.


Longhorn can be accessed directly via HTTP methods:

POST http://{host}/okapi-longhorn/projects/new 
Creates a new temporary project and returns its URI (e.g. http://localhost/okapi-longhorn/projects/1)
POST http://{host}/okapi-longhorn/projects/1/batchConfiguration 
Uploads a Batch Configuration file
POST http://{host}/okapi-longhorn/projects/1/inputFiles.zip 
Adds input files as a zip archive (the zip will be extracted and the included files will be used as input files)
PUT http://{host}/okapi-longhorn/projects/1/inputFiles/help.html 
Uploads a file that will have the name 'help.html'
GET http://{host}/okapi-longhorn/projects/1/inputFiles/help.html
Retrieve an input file that was previously added with PUT or POST
POST http://{host}/okapi-longhorn/projects/1/tasks/execute 
Executes the Batch Configuration on the uploaded input files
POST http://{host}/okapi-longhorn/projects/1/tasks/execute/en-US/de-DE 
Executes the Batch Configuration on the uploaded input files with the source language set to 'en-US' and the target language set to 'de-DE'
POST http://{host}/okapi-longhorn/projects/1/tasks/execute/en-US?targets=de-DE&targets=fr-FR 
Executes the Batch Configuration on the uploaded input files with the source language set to 'en-US' and multiple target languages, 'de-DE' and 'fr-FR'
GET http://{host}/okapi-longhorn/projects/1/outputFiles 
Returns a list of the output files generated
GET http://{host}/okapi-longhorn/projects/1/outputFiles/help.out.html 
Accesses the output file 'help.out.html' directly
GET http://{host}/okapi-longhorn/projects/1/outputFiles.zip 
Returns all output files in a zip archive
DEL http://{host}/okapi-longhorn/projects/1 
Deletes the project
GET http://{host}/okapi-longhorn/projects 
Returns a list of all projects on the server

Java API

The API is distributed as a .jar file in the Longhorn distribution package. You can also build it from the Okapi source code via Maven from the project lib-longhorn-api.


The API is available as a maven dependency. Add this repository to your pom.xml:

       <name>Okapi Longhorn Release</name>

Along with this dependency, substituting in a valid version number (e.g, 0.27):


Sample Code

LonghornService ws = new RESTService(new URI("http://localhost:9095/okapi-longhorn"));

// Create project
LonghornProject proj = ws.createProject();

// Post batch configuration
File bconfFile = new File("C:\\setup.bconf");

// Send input files

// First by single upload...
File file1 = new File("C:\\help.html");
// * in the root directory
proj.addInputFile(file1, file1.getName());
// * and in a sub-directory
proj.addInputFile(file1, "samefile/" + file1.getName());

// ...then by package upload
File inputPackage = new File("C:\\more_files.zip");

// Execute pipeline
// Languages don't matter
// Languages matter
proj.executePipeline("en-US", "de-DE");

// Get output files
ArrayList<LonghornFile> outputFiles = proj.getOutputFiles();

// Does the fetching of files work?
for (LonghornFile of : outputFiles) {
	InputStream is = of.openStream();
	//TODO save InputStream to local file

// Delete project


You can create projects and upload/download files via an integrated HTML client, too. Uploading input files (and downloading output files) as a zip archive is currently not implemented for the HTML client.

Longhorn html client.png


Since Okapi M22 Okapi Longhorn can be build to run multiple instances on one server. You can adjust the build so that it is possible to run multiple Longhorn instances in one JBoss application server. Therefore, the build must be called with an additional parameter:

mvn clean verify -DuseUniqueContextRoot

Configure working directory path

Longhorn has 2 options to configure the working directory of longhorn (sort by priority):

  1. system parameter "LONGHORN_WORKDIR"
  2. configuration file in user.home "/okapi-longhorn-configuration.xml"

If nothing is defined, the working-directory is in user.home in folder "Okapi-Longhorn-Files". Longhorn configuration file example:


Configuration Options

option description data type
working-directory path of the working directory string
use-unique-working-directory if set to true the version of longhorn will be added to working directory name

e.g path/to/working/directory_M0.21

boolean(True or False)