0

I have a series of clients which communicate with each other using JGroups library, they basically create a communication channel attached to a cluster name:

communicationChannel = new JChannel(AutoDiscovery.class.getResource("/resource/udp.xml"));
communicationChannel.connect("cluster1");

Now I would like them to first list available clusters to connect to and let the user decide which cluster connect to without hardwiring the name of the cluster in the code as above. Apparently the API has getName() which returns the logical name of the channel if set but there's no method to retrieve set up clusters.

I though using the org.jgroups.Message.getHeaders() and reading the header would yield the active clusters but nothing. Any help please?

dendini
  • 3,842
  • 9
  • 37
  • 74

1 Answers1

0

There's no way to find the currently available clusters, I suggest maintaining some extra state which stores (in-memory) all cluster names and their associated configuration.

Once thing you could do though is develop a custom protocol (insert it below GMS), which does the following: - Catches down(Event evt): if evt.getType() == Event.CONNECT*** (4 events), grab the cluster name ((String)evt.getArg()) and add it to a set - Catches down(Event evt): if evt.getType() == Event.DISCONNECT, grab the currently cluster name and remove it from the set

This doesn't give you the config info; you could get this too, if you subclasses JChannel and overwrote connectXXX() and disconnect().

Bela Ban
  • 2,186
  • 13
  • 12