Class OortPrimaryService<R,C>
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.cometd.oort.OortService<R,C>
-
- org.cometd.oort.OortPrimaryService<R,C>
-
- Type Parameters:
R
- the result typeC
- the opaque context type
- All Implemented Interfaces:
java.util.EventListener
,Bayeux.BayeuxListener
,ConfigurableServerChannel.ServerChannelListener
,ServerChannel.MessageListener
,org.eclipse.jetty.util.component.LifeCycle
- Direct Known Subclasses:
OortPrimaryLong
public abstract class OortPrimaryService<R,C> extends OortService<R,C>
OortPrimaryService
extendsOortService
to allow applications to perform actions on entities that always live in a "primary" node.Applications may have entities that are naturally owned by any node. For example, in a chat application a chat room may be created by a user in any node, and be owned by the node the user that created it is connected to.
There are cases, however, where entities cannot be owned by any node, but instead must be owned by one node only, usually referred to as the "primary" node.
A typical example of such an entity is a unique (across the cluster) ID generator that produces IDs in the form of
long
- the primitive Java type - values, or a service that accesses a storage (such as a file system) that is only available on a particular node, etc.OortPrimaryService
makes easier to write services that perform actions on entities that must be owned by a single node only. There is one instance ofOortPrimaryService
with the same name for each node, but only one of them is the "primary". Then, applications may callgetPrimaryOortURL()
to get the Oort URL of the "primary" node, and pass that Oort URL toOortService.forward(String, Object, Object)
as described inOortService
.
-
-
Nested Class Summary
-
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
ConfigurableServerChannel.ServerChannelListener.Weak
-
-
Constructor Summary
Constructors Constructor Description OortPrimaryService(Oort oort, java.lang.String name, boolean primary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
doStart()
protected void
doStop()
java.lang.String
getPrimaryOortURL()
boolean
isPrimary()
-
Methods inherited from class org.cometd.oort.OortService
forward, getLocalSession, getName, getOort, getTimeout, onForward, onForwardFailed, onForwardMessage, onForwardSucceeded, onMessage, onResultMessage, setTimeout, toString
-
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 Detail
-
OortPrimaryService
public OortPrimaryService(Oort oort, java.lang.String name, boolean primary)
- Parameters:
oort
- the oort this instance is associated toname
- the name of this serviceprimary
- whether this service lives on the "primary" node
-
-
Method Detail
-
isPrimary
public boolean isPrimary()
- Returns:
- whether this node is the "primary" node
-
getPrimaryOortURL
public java.lang.String getPrimaryOortURL()
- Returns:
- the "primary" Oort URL, or null if the "primary" node is down.
-
doStart
protected void doStart() throws java.lang.Exception
- Overrides:
doStart
in classOortService<R,C>
- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception
- Overrides:
doStop
in classOortService<R,C>
- Throws:
java.lang.Exception
-
-