Re: [jgroups-users] Ability to set the coordinator programaticaly and the ability to maintain a shared state
Questions/problems related to using JGroups <[email protected]> Wed, 2 May 2018 12:19:49 -0400
| Newsgroups | gmane.comp.java.javagroups.general |
|---|---|
| Message-ID | <mailman.2262.1525278675.27734.javagroups-users@lists.sourceforge.net> |
> > > The second question is about the ability to maintain a shared state. Is it > possible to maintain a state which is visible across the cluster?. So the > changes are synchronized among the available members and visible to all > members without explicit message passing about the changes. > After all the help I've received here, am responding to try to repay the favor. Hopefully I'm not misleading you on anything. Yes, you can have a shared state across the cluster. In our app, we have a state that includes a bunch of things about the cluster. It's a small Java object that implements org.jgroups.util.Streamable. In the base class for our main code, we override ReceiverAdapter getState and setState to do the appropriate things. When a new node joins the cluster, getState is called on the coordinator automatically and the result is used for setState on the new node. JGroups does that for you with the STATE_TRANSFER protocol. Whenever something happens in our cluster that would change this state, the coordinator sends a message to all the other nodes saying "reload the shared state." Each node (besides the coordinator) then calls JChannel#getState in a new thread to have the new state set on that node. For your case where you want to designate a "master" node separate from the coordinator, this might work for you. Look for 'state' here: http://www.jgroups.org/manual/html/user-channel.html Cheers, Bobby ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ javagroups-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/javagroups-users