Class OortPrimaryLong

java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
All Implemented Interfaces:
EventListener, org.cometd.bayeux.Bayeux.BayeuxListener, org.cometd.bayeux.server.ConfigurableServerChannel.ServerChannelListener, org.cometd.bayeux.server.ServerChannel.MessageListener, org.eclipse.jetty.util.component.LifeCycle

public class OortPrimaryLong extends OortPrimaryService<Long,OortPrimaryLong.Context>

A distributed counter service to be deployed on a Oort cluster that modifies a long value hosted in a "primary" node.

Instances of this service may be used as unique ID generator, or as unique counter across the cluster, for example to aggregate values from different nodes, such as the number of users connected to each node.

Applications may call methods addAndGet(long, Callback) or getAndAdd(long, Callback) providing the amount to add (it may be negative) and a OortPrimaryLong.Callback object that will be invoked on the requesting node when the result has been computed and transmitted back by the "primary" node.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    Callback invoked when the result of the operation on the counter is available, or when the operation failed.
    protected static class 
     

    Nested classes/interfaces inherited from class org.cometd.oort.OortService

    OortService.Request, OortService.Result<U>, OortService.ServerContext

    Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopException

    Nested classes/interfaces inherited from interface org.cometd.bayeux.server.ConfigurableServerChannel.ServerChannelListener

    org.cometd.bayeux.server.ConfigurableServerChannel.ServerChannelListener.Weak

    Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle

    org.eclipse.jetty.util.component.LifeCycle.Listener
  • Field Summary

    Fields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    FAILED, STARTED, STARTING, STOPPED, STOPPING
  • Constructor Summary

    Constructors
    Constructor
    Description
    OortPrimaryLong(Oort oort, String name, boolean primary)
     
    OortPrimaryLong(Oort oort, String name, boolean primary, long initial)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addAndGet(long delta, OortPrimaryLong.Callback callback)
    Adds the given delta and then invokes the given callback with the counter value after the addition.
    boolean
    Retrieves the value from the "primary" node and then invokes the given callback with the result value.
    boolean
    getAndAdd(long delta, OortPrimaryLong.Callback callback)
    Adds the given delta and then invokes the given callback with the counter value before the addition.
    protected long
     
    Subclasses must implement this method, that runs on the owner node, to implement the action functionality.
    protected void
    Subclasses must implement this method, that runs on the requesting node, to complete the functionality after the action failed on the owner node.
    protected void
    Subclasses must implement this method, that runs on the requesting node, to complete the functionality after the action has been successfully run on the owner node.

    Methods inherited from class org.cometd.oort.OortPrimaryService

    doStart, doStop, getPrimaryOortURL, isPrimary

    Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle

    addEventListener, getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, setEventListeners, start, stop

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.cometd.bayeux.server.ServerChannel.MessageListener

    onMessage
  • Constructor Details

    • OortPrimaryLong

      public OortPrimaryLong(Oort oort, String name, boolean primary)
    • OortPrimaryLong

      public OortPrimaryLong(Oort oort, String name, boolean primary, long initial)
      Parameters:
      oort - the oort this instance is associated to
      name - the name of this service
      primary - whether this service lives on the "primary" node
      initial - the initial local value
  • Method Details