This content has been marked as final.
Show 9 replies
-
1. Re: Distinguishing members
belaban Sep 16, 2005 10:44 AM (in response to motormind)You can attach some bytes to a JGroups IpAddress, check out HAPartitionImpl in JBoss for how to do this
-
2. Re: Distinguishing members
motormind Sep 16, 2005 10:50 AM (in response to motormind)"bela@jboss.com" wrote:
You can attach some bytes to a JGroups IpAddress, check out HAPartitionImpl in JBoss for how to do this
I thought about that, but didn't see a way to obtain the IP-address & port of a process that uses the cache. -
3. Re: Distinguishing members
belaban Sep 16, 2005 11:02 AM (in response to motormind)TreeCache.getLocalAddress() return an instance of org.jgroups.stack.IpAddress. The problem is that JBoss already uses the additional bytes to stick the logical node name into the IpAddress...
-
4. Re: Distinguishing members
motormind Sep 16, 2005 11:46 AM (in response to motormind)"bela@jboss.com" wrote:
TreeCache.getLocalAddress() return an instance of org.jgroups.stack.IpAddress. The problem is that JBoss already uses the additional bytes to stick the logical node name into the IpAddress...
Hmm.. TreeCache.getLocalAddress() actually returns a null on my system -
5. Re: Distinguishing members
belaban Sep 16, 2005 4:09 PM (in response to motormind)Only when the cache is replicated; and started
-
6. Re: Distinguishing members
motormind Sep 17, 2005 7:20 AM (in response to motormind)"bela@jboss.com" wrote:
Only when the cache is replicated; and started
Right. So how amd I going to distinguish between members? -
7. Re: Distinguishing members
belaban Sep 18, 2005 2:43 PM (in response to motormind)Look at AddDataTest:
JChannel c=new JChannel(properties); Map m=new HashMap(); m.put("additional_data", new byte[]{'b', 'e', 'l', 'a'}); c.down(new Event(Event.CONFIG, m)); c.connect("bla"); IpAddress addr=(IpAddress)c.getLocalAddress(); System.out.println("address is " + addr); assertNotNull(addr.getAdditionalData()); assertEquals(addr.getAdditionalData()[0], 'b');
IpAddress.getAdditionalData() returns a byte[] buffer, that you can use -
8. Re: Distinguishing members
motormind Sep 19, 2005 12:55 AM (in response to motormind)"bela@jboss.com" wrote:
Look at AddDataTest:JChannel c=new JChannel(properties); Map m=new HashMap(); m.put("additional_data", new byte[]{'b', 'e', 'l', 'a'}); c.down(new Event(Event.CONFIG, m)); c.connect("bla"); IpAddress addr=(IpAddress)c.getLocalAddress(); System.out.println("address is " + addr); assertNotNull(addr.getAdditionalData()); assertEquals(addr.getAdditionalData()[0], 'b');
IpAddress.getAdditionalData() returns a byte[] buffer, that you can use
But you're saying that it is already used by JBoss Cache... won't it upset the system when I set it myself? -
9. Re: Distinguishing members
belaban Sep 19, 2005 2:32 AM (in response to motormind)No, it is not used by JBossCache; it is used by JBoss Clustering. So for JBossCache, the additional data is available.
Another solution would be to replicate the information whether a node is a client or server across the cluster using clustering or cache, this is probably more portable and you don't need to worry about who's using additional_data.