Class Oort
- java.lang.Object
-
- org.eclipse.jetty.util.component.AbstractLifeCycle
-
- org.eclipse.jetty.util.component.ContainerLifeCycle
-
- org.cometd.oort.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.ContainerLifeCycleOort 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
OortMulticastConfigServletorOortStaticConfigServlet.This class maintains a collection of
OortCometinstances to each CometD server, created by calls toobserveComet(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.protected classOort.JoinListenerprotected classOort.OortExtensionExtension that detects incoming handshakes from other Oort servers.-
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 java.lang.StringEXT_COMET_URL_FIELDstatic java.lang.StringEXT_OORT_ALIAS_URL_FIELDstatic java.lang.StringEXT_OORT_FIELDstatic java.lang.StringEXT_OORT_ID_FIELDstatic java.lang.StringEXT_OORT_SECRET_FIELDstatic java.lang.StringEXT_OORT_URL_FIELDstatic java.lang.StringOORT_ATTRIBUTEstatic java.lang.StringOORT_CLOUD_CHANNELstatic java.lang.StringOORT_SERVICE_CHANNEL
-
Constructor Summary
Constructors Constructor Description Oort(org.cometd.bayeux.server.BayeuxServer bayeux, java.lang.String url)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods 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, java.util.Map<java.lang.String,java.lang.Object> fields)voiddeobserveChannel(java.lang.String channelId)OortCometdeobserveComet(java.lang.String cometURL)protected voiddoStart()protected voiddoStop()voiddump(java.lang.Appendable out, java.lang.String indent)protected java.lang.StringencodeSecret(java.lang.String secret)protected OortCometfindComet(java.lang.String cometURL)org.cometd.bayeux.server.BayeuxServergetBayeuxServer()java.util.List<org.cometd.client.transport.ClientTransport.Factory>getClientTransportFactories()OortCometgetComet(java.lang.String cometURL)java.lang.StringgetId()org.cometd.common.JSONContext.ClientgetJSONContextClient()java.util.Set<java.lang.String>getKnownComets()java.util.Set<java.lang.String>getObservedChannels()org.cometd.bayeux.server.LocalSessiongetOortSession()java.lang.StringgetSecret()java.lang.StringgetURL()protected booleanincomingCometHandshake(java.util.Map<java.lang.String,java.lang.Object> oortExt, org.cometd.bayeux.server.ServerSession session)Called to register the details of a successful handshake from another Oort comet.booleanisAckExtensionEnabled()booleanisBinaryExtensionEnabled()protected booleanisCometConnected(java.lang.String oortURL)booleanisOort(org.cometd.bayeux.server.ServerSession session)booleanisOortHandshake(org.cometd.bayeux.Message handshake)protected voidjoinComets(org.cometd.bayeux.Message message)protected OortCometnewOortComet(java.lang.String cometURL)protected java.util.Map<java.lang.String,java.lang.Object>newOortHandshakeFields(java.lang.String cometURL, java.lang.String oortAliasURL)voidobserveChannel(java.lang.String channelName)Observes the given channel, registering to receive messages from the Oort comets connected to this Oort instance.OortCometobserveComet(java.lang.String cometURL)Connects (if not already connected) and observes another Oort instance (identified by the given URL) via aOortCometinstance.protected OortCometobserveComet(java.lang.String cometURL, java.lang.String oortAliasURL)voidremoveCometListener(Oort.CometListener listener)Deregisters the given listener from being notified of comet events.voidremoveCometListeners()Deregisters all comet listeners.protected static java.lang.StringreplacePunctuation(java.lang.String source, char replacement)voidsetAckExtensionEnabled(boolean value)voidsetBinaryExtensionEnabled(boolean value)voidsetClientTransportFactories(java.util.List<org.cometd.client.transport.ClientTransport.Factory> factories)voidsetJSONContextClient(org.cometd.common.JSONContext.Client jsonContext)voidsetSecret(java.lang.String secret)java.lang.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 Detail
-
OORT_ATTRIBUTE
public static final java.lang.String OORT_ATTRIBUTE
-
EXT_OORT_FIELD
public static final java.lang.String EXT_OORT_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_URL_FIELD
public static final java.lang.String EXT_OORT_URL_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_ID_FIELD
public static final java.lang.String EXT_OORT_ID_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_SECRET_FIELD
public static final java.lang.String EXT_OORT_SECRET_FIELD
- See Also:
- Constant Field Values
-
EXT_COMET_URL_FIELD
public static final java.lang.String EXT_COMET_URL_FIELD
- See Also:
- Constant Field Values
-
EXT_OORT_ALIAS_URL_FIELD
public static final java.lang.String EXT_OORT_ALIAS_URL_FIELD
- See Also:
- Constant Field Values
-
OORT_CLOUD_CHANNEL
public static final java.lang.String OORT_CLOUD_CHANNEL
- See Also:
- Constant Field Values
-
OORT_SERVICE_CHANNEL
public static final java.lang.String OORT_SERVICE_CHANNEL
- See Also:
- Constant Field Values
-
-
Method Detail
-
doStart
protected void doStart() throws java.lang.Exception- Overrides:
doStartin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
java.lang.Exception
-
doStop
protected void doStop() throws java.lang.Exception- Overrides:
doStopin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
java.lang.Exception
-
getBayeuxServer
@ManagedAttribute(value="The BayeuxServer of this Oort", readonly=true) public org.cometd.bayeux.server.BayeuxServer getBayeuxServer()
-
getURL
@ManagedAttribute(value="The URL of this Oort", readonly=true) public java.lang.String getURL()- Returns:
- the public absolute URL of the Oort CometD server
-
getId
@ManagedAttribute(value="The unique ID of this Oort", readonly=true) public java.lang.String getId()
-
getSecret
@ManagedAttribute("The secret of this Oort") public java.lang.String getSecret()
-
setSecret
public void setSecret(java.lang.String secret)
-
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
public org.cometd.common.JSONContext.Client getJSONContextClient()
-
setJSONContextClient
public void setJSONContextClient(org.cometd.common.JSONContext.Client jsonContext)
-
getClientTransportFactories
public java.util.List<org.cometd.client.transport.ClientTransport.Factory> getClientTransportFactories()
-
setClientTransportFactories
public void setClientTransportFactories(java.util.List<org.cometd.client.transport.ClientTransport.Factory> factories)
-
observeComet
public OortComet observeComet(java.lang.String cometURL)
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
-
observeComet
protected OortComet observeComet(java.lang.String cometURL, java.lang.String oortAliasURL)
-
newOortComet
protected OortComet newOortComet(java.lang.String cometURL)
-
configureOortComet
protected void configureOortComet(OortComet oortComet)
-
encodeSecret
protected java.lang.String encodeSecret(java.lang.String secret)
-
connectComet
protected void connectComet(OortComet comet, java.util.Map<java.lang.String,java.lang.Object> fields)
-
deobserveComet
public OortComet deobserveComet(java.lang.String cometURL)
-
getKnownComets
@ManagedAttribute(value="URLs of known Oorts in the cluster", readonly=true) public java.util.Set<java.lang.String> getKnownComets()- Returns:
- the set of known Oort comet servers URLs.
-
getComet
public OortComet getComet(java.lang.String cometURL)
- Parameters:
cometURL- the URL of a Oort comet- Returns:
- the OortComet instance connected with the Oort comet with the given URL
-
findComet
protected OortComet findComet(java.lang.String cometURL)
- 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") java.lang.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") java.lang.String channelId)
-
isOort
public boolean isOort(org.cometd.bayeux.server.ServerSession session)
- 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
public boolean isOortHandshake(org.cometd.bayeux.Message handshake)
- 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
protected java.util.Map<java.lang.String,java.lang.Object> newOortHandshakeFields(java.lang.String cometURL, java.lang.String oortAliasURL)
-
isCometConnected
protected boolean isCometConnected(java.lang.String oortURL)
- Parameters:
oortURL- the comet URL to check for connection- Returns:
- whether the given comet is connected to this comet
-
incomingCometHandshake
protected boolean incomingCometHandshake(java.util.Map<java.lang.String,java.lang.Object> oortExt, org.cometd.bayeux.server.ServerSession session)Called to register the details of a successful handshake from another Oort comet.
- Parameters:
oortExt- the remote Oort informationsession- the server session that represent the connection with the remote Oort comet- Returns:
- false if a connection from a remote Oort has already been established, true otherwise
-
addCometListener
public void addCometListener(Oort.CometListener listener)
Registers the given listener to be notified of comet events.- Parameters:
listener- the listener to add- See Also:
removeCometListener(CometListener)
-
removeCometListener
public void removeCometListener(Oort.CometListener listener)
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
protected void joinComets(org.cometd.bayeux.Message message)
-
getObservedChannels
public java.util.Set<java.lang.String> getObservedChannels()
-
getOortSession
public org.cometd.bayeux.server.LocalSession getOortSession()
- Returns:
- the oortSession
-
replacePunctuation
protected static java.lang.String replacePunctuation(java.lang.String source, char replacement)
-
dump
public void dump(java.lang.Appendable out, java.lang.String indent) throws java.io.IOException- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Overrides:
dumpin classorg.eclipse.jetty.util.component.ContainerLifeCycle- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-