Class OortService<R,​C>

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.cometd.oort.OortService<R,​C>
Type Parameters:
R - the result type
C - the opaque context type
All Implemented Interfaces:
EventListener, Bayeux.BayeuxListener, ConfigurableServerChannel.ServerChannelListener, ServerChannel.MessageListener, org.eclipse.jetty.util.component.LifeCycle
Direct Known Subclasses:
OortMasterService

public abstract class OortService<R,​C>
extends org.eclipse.jetty.util.component.AbstractLifeCycle
implements ServerChannel.MessageListener

An OortService allows applications to forward actions to Oort nodes that own the entity onto which the action should be applied.

An OortService builds on the concept introduced by OortObject that the ownership of a particular entity belongs only to one node. Any node can read the entity, but only the owner can create/modify/delete it.

In order to perform actions that modify the entity, a node has to know what is the node that owns the entity, and then forward the action to the owner node.

OortService provides the facilities to forward the action to the owner node and return the result of the action, or its failure.

OortServices are usually created at application startup, but may be created and destroyed on-the-fly. In both cases, they must be started to make them functional and stopped when they are no longer needed.

Usage of OortService follows these steps:

  1. The application running in the requesting node identifies the owner node and calls forward(String, Object, Object), passing the Oort URL of the owner node, the action data, and an opaque context
  2. The application implements onForward(Request), which is executed in the owner node. In this method the action data is used to perform the action that modifies the entity, and the result is returned (or an exception thrown in case of failure).
  3. The application implements onForwardSucceeded(Object, Object) (which is executed in the requesting node) which provides as parameters the result of the action from the second step and the opaque context from the first step.
  4. The application implements onForwardFailed(Object, Object) (which is executed in the requesting node) which provides as parameters the failure from the second step and the opaque context from the first step. The failure object is the message string of a generic exception, or the failure returned by OortService.Result.failure(Object).

The steps above do not change if the requesting node and the owner node are the same.

  • Field Details

    • logger

      protected final org.slf4j.Logger logger
  • Constructor Details

    • OortService

      protected OortService​(Oort oort, String name)
      Creates an OortService with the given name.
      Parameters:
      oort - the Oort where this service lives
      name - the unique name across the cluster of this service
  • Method Details