Class Oort
- All Implemented Interfaces:
org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.LifeCycle
@ManagedObject("CometD cloud node")
public class Oort
extends org.eclipse.jetty.util.component.ContainerLifeCycle
Oort is the cluster manager that links one CometD server to a set of other CometD servers.
The Oort instance is created and configured by either OortMulticastConfigServlet or
OortStaticConfigServlet.
This class maintains a collection of OortComet instances to each
CometD server, created by calls to observeComet(String).
The key configuration parameter is the Oort URL, which is
full public URL of the CometD servlet to which the Oort instance is bound,
for example: http://myserver:8080/context/cometd.
Oort instances can be configured with a shared secret, which allows
the Oort instance to distinguish handshakes coming from remote clients from handshakes coming from
other Oort comets: the firsts may be subject to a stricter authentication policy than the seconds.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classOort.CloudListenerThis listener handles messages sent to/oort/cloudthat contains the list of comets connected to the Oort that just joined the cloud.static interfaceOort.CometListenerListener interface that gets notified of comet events, that is when a new comet joins the cloud or when a comet leaves the cloud.Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener -
Field Summary
Fields Modifier and Type Field Description static StringEXT_COMET_URL_FIELDstatic StringEXT_OORT_ALIAS_URL_FIELDstatic StringEXT_OORT_FIELDstatic StringEXT_OORT_ID_FIELDstatic StringEXT_OORT_SECRET_FIELDstatic StringEXT_OORT_URL_FIELDstatic StringOORT_ATTRIBUTEstatic StringOORT_CLOUD_CHANNELstatic StringOORT_SERVICE_CHANNEL -
Constructor Summary
Constructors Constructor Description Oort(BayeuxServer bayeux, String url) -
Method Summary
Modifier and Type Method Description voidaddCometListener(Oort.CometListener listener)Registers the given listener to be notified of comet events.protected voidconfigureOortComet(OortComet oortComet)protected voidconnectComet(OortComet comet, Map<String,Object> fields)voiddeobserveChannel(String channelId)OortCometdeobserveComet(String cometURL)protected voiddoStart()protected voiddoStop()voiddump(Appendable out, String indent)protected StringencodeSecret(String secret)protected OortCometfindComet(String cometURL)BayeuxServergetBayeuxServer()List<ClientTransport.Factory>getClientTransportFactories()OortCometgetComet(String cometURL)StringgetId()JSONContext.ClientgetJSONContextClient()Set<String>getKnownComets()Set<String>getObservedChannels()LocalSessiongetOortSession()protected ScheduledExecutorServicegetScheduler()StringgetSecret()StringgetURL()booleanisAckExtensionEnabled()booleanisBinaryExtensionEnabled()protected booleanisCometConnected(String oortURL)booleanisOort(ServerSession session)booleanisOortHandshake(Message handshake)protected voidjoinComets(Message message)protected OortCometnewOortComet(String cometURL)protected OortCometnewOortComet(String cometURL, ClientTransport transport, ClientTransport[] otherTransports)protected Map<String,Object>newOortHandshakeFields(String cometURL, String oortAliasURL)voidobserveChannel(String channelName)Observes the given channel, registering to receive messages from the Oort comets connected to this Oort instance.OortCometobserveComet(String cometURL)Connects (if not already connected) and observes another Oort instance (identified by the given URL) via aOortCometinstance.voidremoveCometListener(Oort.CometListener listener)Deregisters the given listener from being notified of comet events.voidremoveCometListeners()Deregisters all comet listeners.protected static StringreplacePunctuation(String source, char replacement)voidsetAckExtensionEnabled(boolean value)voidsetBinaryExtensionEnabled(boolean value)voidsetClientTransportFactories(List<ClientTransport.Factory> factories)voidsetJSONContextClient(JSONContext.Client jsonContext)voidsetSecret(String secret)StringtoString()Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBeans
-
Field Details
-
OORT_ATTRIBUTE
-
EXT_OORT_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_URL_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_ID_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_SECRET_FIELD
- See Also:
- Constant Field Values
-
EXT_COMET_URL_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_ALIAS_URL_FIELD
- See Also:
- Constant Field Values
-
OORT_CLOUD_CHANNEL
- See Also:
- Constant Field Values
-
OORT_SERVICE_CHANNEL
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Method Details
-
doStart
- Overrides:
doStartin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
Exception
-
getScheduler
-
getBayeuxServer
@ManagedAttribute(value="The BayeuxServer of this Oort", readonly=true) public BayeuxServer getBayeuxServer() -
getURL
- Returns:
- the public absolute URL of the Oort CometD server
-
getId
-
getSecret
-
setSecret
-
isAckExtensionEnabled
@ManagedAttribute("Whether the acknowledgement extension is enabled") public boolean isAckExtensionEnabled() -
setAckExtensionEnabled
public void setAckExtensionEnabled(boolean value) -
isBinaryExtensionEnabled
@ManagedAttribute("Whether the binary extension is enabled") public boolean isBinaryExtensionEnabled() -
setBinaryExtensionEnabled
public void setBinaryExtensionEnabled(boolean value) -
getJSONContextClient
-
setJSONContextClient
-
getClientTransportFactories
-
setClientTransportFactories
-
observeComet
Connects (if not already connected) and observes another Oort instance (identified by the given URL) via a
OortCometinstance.- Parameters:
cometURL- the Oort URL to observe- Returns:
- The
OortCometinstance associated to the Oort instance identified by the URL or null if the given Oort URL represent this Oort instance
-
newOortComet
-
newOortComet
protected OortComet newOortComet(String cometURL, ClientTransport transport, ClientTransport[] otherTransports) -
configureOortComet
-
encodeSecret
-
connectComet
-
deobserveComet
-
getKnownComets
@ManagedAttribute(value="URLs of known Oorts in the cluster", readonly=true) public Set<String> getKnownComets()- Returns:
- the set of known Oort comet servers URLs.
-
getComet
- Parameters:
cometURL- the URL of a Oort comet- Returns:
- the OortComet instance connected with the Oort comet with the given URL
-
findComet
- Parameters:
cometURL- the URL of a Oort comet- Returns:
- the OortComet instance connecting or connected with the Oort comet with the given URL
-
observeChannel
@ManagedOperation(value="Observes the given channel", impact="ACTION") public void observeChannel(@Name(value="channel",description="The channel to observe") String channelName)Observes the given channel, registering to receive messages from the Oort comets connected to this Oort instance.
Once observed, all
OortCometinstances subscribe to the channel and will repeat any messages published to the local channel (with loop prevention), so that the messages are distributed to all Oort comet servers.- Parameters:
channelName- the channel to observe
-
deobserveChannel
@ManagedOperation(value="Deobserves the given channel", impact="ACTION") public void deobserveChannel(@Name(value="channel",description="The channel to deobserve") String channelId) -
isOort
- Parameters:
session- the server session to test- Returns:
- whether the given server session is one of those created by the Oort internal working
- See Also:
isOortHandshake(Message)
-
isOortHandshake
- Parameters:
handshake- the handshake message to test- Returns:
- whether the given handshake message is coming from another Oort comet
that has been configured with the same
secret - See Also:
isOort(ServerSession)
-
newOortHandshakeFields
-
isCometConnected
- Parameters:
oortURL- the comet URL to check for connection- Returns:
- whether the given comet is connected to this comet
-
addCometListener
Registers the given listener to be notified of comet events.- Parameters:
listener- the listener to add- See Also:
removeCometListener(CometListener)
-
removeCometListener
Deregisters the given listener from being notified of comet events.- Parameters:
listener- the listener to remove- See Also:
addCometListener(CometListener)
-
removeCometListeners
public void removeCometListeners()Deregisters all comet listeners. -
joinComets
-
getObservedChannels
-
getOortSession
- Returns:
- the oortSession
-
replacePunctuation
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Overrides:
dumpin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
IOException
-
toString
-