public class InternalComponentManager extends BasicModule implements ClusterEventListener, org.xmpp.component.ComponentManager, RoutableChannelHandler
Components
,
as well as offering a facade around basic server functionality such as sending and receiving of packets.
This component manager will be an internal service whose JID will be component.[domain]. So the
component manager will be able to send packets to other internal or external components and also
receive packets from other components or even from trusted clients (e.g. ad-hoc commands).Modifier and Type | Field and Description |
---|---|
static String |
COMPONENT_CACHE_NAME |
Constructor and Description |
---|
InternalComponentManager() |
Modifier and Type | Method and Description |
---|---|
void |
addComponent(String subdomain,
org.xmpp.component.Component component) |
void |
addListener(ComponentEventListener listener)
Adds a new listener that will be notified of component events.
|
void |
addPresenceRequest(org.xmpp.packet.JID prober,
org.xmpp.packet.JID probee)
Registers Probers who have not yet been serviced.
|
void |
destroy()
Destroys the module.
|
org.xmpp.packet.JID |
getAddress()
Returns the XMPP address.
|
String |
getHomeDirectory() |
static InternalComponentManager |
getInstance() |
String |
getProperty(String name) |
String |
getServerName() |
boolean |
hasComponent(org.xmpp.packet.JID componentJID)
Returns true if a component is associated to the specified address.
|
void |
initialize(XMPPServer server)
Initializes the basic module.
|
boolean |
isExternalMode() |
void |
joinedCluster()
Notification event indicating that this JVM is now part of a cluster.
|
void |
joinedCluster(byte[] nodeID)
Notification event indicating that another JVM is now part of a cluster.
|
void |
leftCluster()
Notification event indicating that this JVM is no longer part of the cluster.
|
void |
leftCluster(byte[] nodeID)
Notification event indicating that another JVM is no longer part of the cluster.
|
void |
markedAsSeniorClusterMember()
Notification event indicating that this JVM is now the senior cluster member.
|
void |
process(org.xmpp.packet.Packet packet)
Processes packets that were sent to this service.
|
void |
query(org.xmpp.component.Component component,
org.xmpp.packet.IQ packet,
org.xmpp.component.IQResultListener listener) |
org.xmpp.packet.IQ |
query(org.xmpp.component.Component component,
org.xmpp.packet.IQ packet,
long timeout) |
void |
removeComponent(String subdomain)
Removes a component.
|
void |
removeComponent(String subdomain,
org.xmpp.component.Component component)
Removes a given component.
|
void |
removeListener(ComponentEventListener listener)
Removes the specified listener from the listeners being notified of component
events.
|
void |
sendPacket(org.xmpp.component.Component component,
org.xmpp.packet.Packet packet) |
void |
setProperty(String name,
String value) |
void |
start()
Starts the basic module.
|
void |
stop()
Stops the basic module.
|
getName
public static final String COMPONENT_CACHE_NAME
public static InternalComponentManager getInstance()
public void initialize(XMPPServer server)
BasicModule
Initializes the basic module.
Inheriting classes that choose to override this method MUST call this initialize() method before accessing BasicModule resources.
initialize
in interface Module
initialize
in class BasicModule
server
- the server hosting this module.public void start()
BasicModule
Starts the basic module.
Inheriting classes that choose to override this method MUST call this start() method before accessing BasicModule resources.
start
in interface Module
start
in class BasicModule
public void stop()
BasicModule
Stops the basic module.
Inheriting classes that choose to override this method MUST call this stop() method before accessing BasicModule resources.
stop
in interface Module
stop
in class BasicModule
public void destroy()
BasicModule
Destroys the module.
Does nothing in the basic module.
destroy
in interface Module
destroy
in class BasicModule
public void addComponent(String subdomain, org.xmpp.component.Component component) throws org.xmpp.component.ComponentException
addComponent
in interface org.xmpp.component.ComponentManager
org.xmpp.component.ComponentException
public void removeComponent(String subdomain)
Component.shutdown()
method will be called on the
component. Note that if the component was an external component that was connected
several times then all its connections will be terminated.removeComponent
in interface org.xmpp.component.ComponentManager
subdomain
- the subdomain of the component's address.public void removeComponent(String subdomain, org.xmpp.component.Component component)
removeComponent(String)
this method will just
remove a single component instead of all components associated to the subdomain. External
components may connect several times and register for the same subdomain. This method
just removes a singled connection not all of them.subdomain
- the subdomain of the component's address.component
- specific component to remove.public void sendPacket(org.xmpp.component.Component component, org.xmpp.packet.Packet packet)
sendPacket
in interface org.xmpp.component.ComponentManager
public org.xmpp.packet.IQ query(org.xmpp.component.Component component, org.xmpp.packet.IQ packet, long timeout) throws org.xmpp.component.ComponentException
query
in interface org.xmpp.component.ComponentManager
org.xmpp.component.ComponentException
public void query(org.xmpp.component.Component component, org.xmpp.packet.IQ packet, org.xmpp.component.IQResultListener listener) throws org.xmpp.component.ComponentException
query
in interface org.xmpp.component.ComponentManager
org.xmpp.component.ComponentException
public void addListener(ComponentEventListener listener)
listener
- the new listener to notify of component events.public void removeListener(ComponentEventListener listener)
listener
- the listener to remove.public String getProperty(String name)
getProperty
in interface org.xmpp.component.ComponentManager
public void setProperty(String name, String value)
setProperty
in interface org.xmpp.component.ComponentManager
public String getServerName()
getServerName
in interface org.xmpp.component.ComponentManager
public String getHomeDirectory()
public boolean isExternalMode()
isExternalMode
in interface org.xmpp.component.ComponentManager
public boolean hasComponent(org.xmpp.packet.JID componentJID)
componentJID
- the address of the component. This is the complete domain.public void addPresenceRequest(org.xmpp.packet.JID prober, org.xmpp.packet.JID probee)
prober
- the jid probing.probee
- the presence being probed.public org.xmpp.packet.JID getAddress()
RoutableChannelHandler
getAddress
in interface RoutableChannelHandler
public void process(org.xmpp.packet.Packet packet) throws PacketException
process
in interface ChannelHandler<org.xmpp.packet.Packet>
packet
- the packet to process.PacketException
- thrown if the packet is malformed (results in the sender's
session being shutdown).public void joinedCluster()
ClusterEventListener
XMPPServer.getNodeID()
holds the new nodeID value.
When joining the cluster as the senior cluster member the ClusterEventListener.markedAsSeniorClusterMember()
event will be sent right after this event.
At this point the CacheFactory holds clustered caches. That means that modifications to the caches will be reflected in the cluster. The clustered caches were just obtained from the cluster and no local cached data was automatically moved.
joinedCluster
in interface ClusterEventListener
public void joinedCluster(byte[] nodeID)
ClusterEventListener
At this point the CacheFactory of the new node holds clustered caches. That means that modifications to the caches of this JVM will be reflected in the cluster and in particular in the new node.
joinedCluster
in interface ClusterEventListener
nodeID
- ID of the node that joined the cluster.public void leftCluster()
ClusterEventListener
Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the
island were this JVM belonged was marked as "old" then all nodes of that island will
get the left cluster event
and joined cluster events
. That means that
caches will be reset and thus will need to be repopulated again with fresh data from this JVM.
This also includes the case where this JVM was the senior cluster member and when the islands
met again then this JVM stopped being the senior member.
At this point the CacheFactory holds local caches. That means that modifications to the caches will only affect this JVM.
leftCluster
in interface ClusterEventListener
public void leftCluster(byte[] nodeID)
ClusterEventListener
Moreover, if we were in a "split brain" scenario (ie. separated cluster islands) and the
island were the other JVM belonged was marked as "old" then all nodes of that island will
get the left cluster event
and joined cluster events
. That means that
caches will be reset and thus will need to be repopulated again with fresh data from this JVM.
This also includes the case where the other JVM was the senior cluster member and when the islands
met again then the other JVM stopped being the senior member.
At this point the CacheFactory of the leaving node holds local caches. That means that modifications to the caches of this JVM will not affect the leaving node but other cluster members.
leftCluster
in interface ClusterEventListener
nodeID
- ID of the node that is left the cluster.public void markedAsSeniorClusterMember()
ClusterEventListener
Moreover, in the case of a "split brain" scenario (ie. separated cluster islands) each
island will have its own senior cluster member. However, when the islands meet again there
could only be one senior cluster member so one of the senior cluster members will stop playing
that role. When that happens the JVM no longer playing that role will receive the
ClusterEventListener.leftCluster()
and ClusterEventListener.joinedCluster()
events.
markedAsSeniorClusterMember
in interface ClusterEventListener
Copyright © 2003–2020 Ignite Realtime. All rights reserved.