[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [xmlblaster-devel] Get connection states of connected nodes...

Matthew Sargent wrote:
We are using the simple domain to master mapping and have setup several mater/slave relationships. I would like to test if the xmlBlaster instance I am connected to is further connected to others in the cluster. I have a list of domains that I am making subscriptions to and would like to use those to figure out if the masters associated with each particular domain is connected. I see many examples if you already have the master node id, but is there a way to get the master node id for a domain so I can use that to query the connection state?
Hmm, probably not out of the box ...

What you can certainly to is to register a native plugin in xmlBlasterPlugins.xml,
you can take a copy of org.xmlBlaster.engine.EventPlugin.java as a base and throw
out everything you don't need.
Find the code line where
this.engineGlob = ...
is assigned.
With this you can call

ClusterNode[] nodes = this.engineGlob.getClusterManager().getClusterNodes();
for (int i=0; i<nodes.length; i++) {
ClusterNode node = nodes[i];
node.getConnectionState(); // See javadoc, marks alive, polling
node.getId(); // the nodes name

Now you know the cluster nodes and if the connection is alive.

On the other side note that the EventPlugin implements I_SubscriptionListener.
With this listener you get notifed about all coming and going subscriptions:

public void subscriptionAdd(SubscriptionEvent subscriptionEvent) {
SubscriptionInfo subscriptionInfo = subscriptionEvent.getSubscriptionInfo();
String domain = subscriptionInfo.getKeyData().getDomain();
public void subscriptionRemove(SubscriptionEvent subscriptionEvent) {

Now you know about all subscribed domains.

You could now publish a PtP message to the clients interested or better publish the current list
to a topic (say oid="myCurrentDomainList") where your clients retrieve it from with get().


I would like to use the con.get() to gather this information periodically so I can report on connection status.