GATE REFERENCE

This document describes the "gate" service, a NodeJS service managed by PM2.

Theory of Operation

Overview

The gate service is NodeJS service that uses the gated service to provide a single client access to GATE (running in a JVM).

NOTE: The gate service supports one client making calls to gated. The gate service does not support multiple simultaneous clients and does not support parallel operations for any one client. The "GATE Developer" and "GATE Cloud" products from the University of Sheffield are more appropriate for team and parallel use.

Architecture and Components

The gate service is a NodeJS service built using the express framework. All gate code is written in Javascript (ES6). The gate service is designed for use by browser code that interacts with the user.

The gate service answers a JSON-formated literal object for each 200 request. This response always contains an "isSuccessful" binding with a value of "true" or "false". Successful responses contain bindings for client use. Unsuccessful responses contain information about the failure.

The gate service is partitioned into "model" and "controller" behavior. It provides no "view" behavior (other than rendering HTML error pages). Where possible, gate relies on conventional ES6 classes and methods.

All gate classes and methods (including test classes) share common abstract classes (documented elsewhere) that provide shared behavior. This shared behavior includes detecting and reporting exceptional conditions, invoking methods selected at runtime, loading and reference classes as needed, and so on.

NOTE: This document and the code it describes uses the identifier "clazz" to describe an entity in the shared framework that acts as an ES6 class. This entity is called a "clazz" in part because "class" is a keyword in ES6 and also because there are scenarios that require more than one "class" to provide the behavior of a single "clazz". Whew!

Each endpoint provided by gate is comprised of:

The gate service provides seven (7) endpoints, as follows:

  1. cleanup
  2. corpus
  3. document
  4. pipeline
  5. plugin
  6. pr
  7. resetSharedState

These are each GET endpoints. The resetSharedState endpoint is used during cleanup to discard the contents of shared state within the gate service. The remaining six endpoints correspond to their counterparts in gated.

It is partitioned into several components, as follows:

Lifecycle of a typical gate session

A client interaction with gate has three distinct phases:

  1. Setup
  2. Use
  3. Cleanup

These occur in a single "session".

During the "Setup" phase, a client loads one or more plugin instances.

During the "Use" phase, the client creates or loads needed resources and then performs operations on those resources.

During the "Cleanup" phase, the client invokes housekeeping endpoints that free resources in the backend and that reset the state of the gate service to discard any cached entities.

Each endpoint used during "Setup" and "Cleanup" is idempotent. It is therefore good practice to call the "Cleanup" endpoints during "Setup" to handle the unlikely event that any of gate, gated, or GATE were not properly cleaned up at the end of a prior session.

Using gate from the command line

The endpoints provided by the gate service can be accessed from the command line using an SSH shell.

Many endpoints of gate throw exceptions or fail in unexpected ways if a plugin is not loaded. The current implementation and all examples in this document assume the use of the ANNIE plugin.

The gated daemon is a long-running service managed by systemd (systemctl on Rocky Linux). It is therefore good practice to invoke the cleanup endpoint at the conclusion of a manual session where other endpoints are exercised.

For convenience, the following wget command lines should be executed before and after exercising other gate endpoints:

UNDER CONSTRUCTION

Load the ANNIE plugin:

ANNIE

https://hoyo.zeetix.com:7403/gate/v0/plugin/mavenPlugin?group=uk.ac.gate.plugins&artifact=annie&version=9.1

Cleanup GATE:

https://hoyo.zeetix.com:7899/v0/cleanup

The cleanup endpoint is idempotent, so it never hurts to run it before starting a new manual session. This will cleanup if some earlier session was improperly terminated.

The following example endpoint is used to run a pipeline that has already been created and configured:

https://hoyo.zeetix.com:7899/v0/pipeline/runPipeline?pipelineName=testpipeline

The following table uses the above example to illustrate the several parts of a GateDaemon endpoint, using the above example.

Part Example Description
base https://hoyo.zeetix.com The https URL of the target system
port 7899 The designated port of the gated service
version v0 Version specifier for the endpoint
path pipeline A version designator followed by the name of the resource to be used
operation runPipeline The operation to perform on the designated resource
query pipelineName=testpipeline A sequence of one or more key-value pairs

Table 1: GateDaemon Endpoint Anatomy

For convenience, every endpoint in the gate project is a GET endpoint. Each successful response is a JSON-encoded object containing the response from the GATE instance.

This means that any endpoint can be exercised using the "wget" command. Here is a command line string that invokes the example endpoint:

wget "https://hoyo.zeetix.com:7899/v0/pipeline/runPipeline?pipelineName=testpipeline"

NOTE: The URL is enclosed in a double-quote pair (") because many endpoints contain reserved characters interpreted by the command line shell (such as bash).

Here is a command line that loads the ANNIE plugin, together with its response:

Command line:

wget "https://hoyo.zeetix.com:7899/v0/plugin/loadMavenPlugin?group=uk.ac.gate.plugins&artifact=annie&version=9.1"

Response (pretty printed and reordered for clarity):

{ "isSuccessful":"true", "operation":"loadMavenPlugin", "pluginGroup":"uk.ac.gate.plugins" "pluginArtifact":"annie", "pluginVersion":"9.1", }
Path Operations Parameters (*=optional)
plugin
loadMavenPlugin group, artifact, version
cleanup
n.a. n.a.
document
loadFromURL documentURL
loadFromPath documentPath
getDocumentContent documentName
getAnnotationSetNames documentName
getAnnotationsForName documentName, annotationSetName*
cleanupDocument documentName
corpus
createCorpus corpusName
clearCorpus corpusName
addDocument corpusName, documentName
pr
loadPR prName, resourcePath
reinitPR prName
unloadPR prName
pipeline`
createPipeline pipelineName
addPR pipelineName, prName
setCorpus pipelineName, corpusName
getParameterValue pipelineName, prName, parameterName
setParameterValue pipelineName, prName, parameterName, parameterValue*, parameterType
runPipeline pipelineName
storePipelineToFile pipelineName, pipelinePath
loadPipelineFromFile pipelineName, pipelinePath

Table 2: GateDaemon Endpoints

NOTE: The parameterValue is optional for the v0/pipeline endpoint so that a parameter value can be set to null. This is accomplished by providing values for the pipelineName, prName, parameterName, and parameterType.