Find the answer to your question

Post

UniversalMembershipListenerAdapter Working

Hi,

I'm using in my system a UniversalMembershipListenerAdapter, a in my Pool Connection I added two locators, each locator has a server.
When I start my application I watched that the method memberJoined is invoked with a event of each server, then if I stoped the 2 server I watched that the method memberCrashed is called for a event of each server, but then when I started the 2 server , I watch a only event of memberJoined for one server.

It's subscription-enabled and min-connections is the value by default. My problems it's that I use the UniversalMembershipListenerAdapter to know if my clients are connect to at least one of servers, but with this behavior my implementation does not work in a rigth way. There is another way to know if the client is connected to the server

In my test, the client is only connecting to one of the two servers. This client doesn't do anything but start and create a cache with a subscription-enabled pool. The UniversalMembershipListenerAdapter memberJoined callback is triggered by either the pool being prefilled (1 minimum connection by default) or the subscription connection being created. When I kill the server the client is connected to, the UniversalMembershipListenerAdapter memberCrashed callback is triggered by the subscription connection being lost. This is the correct behavior since the client doesn't necessarily connect to both servers. You say you want to know if a client is connected to at least one of the servers. This is telling you exactly that, so I'm a bit confused. Are yo expecting the client to connect to all the servers?

No, the idea is that my client is connected to at least one of the servers, but I'm having problems with the UniversalMembershipListenerAdapter, because sometimes when I stop the servers and I start again the memberJoined is not called and I'm using this logic, with the memberJoined is called I add in a list the member when crash i removed, then if the list is empty my client is not connected, but I'm looking for other way to resolve that.

One is that the client didn't disconnect when the server crashed. Are you seeing the memberCrashed event when the server stops in the cases where you don't see the memberJoined event when it restarts? If not, then the client never disconnected from the server, so it doesn't know to reconnect.

If you're seeing the memberCrashed event when the server leaves, but not the memberJoined event when it starts again, then either the client didn't reconnect, or it did but the callback was not invoked.

Can you do some thread dumps in the client after the server leaves, then again after the server restarts. I'm really looking for these in the context when the memberJoined event doesn't happen.

I'm trying to analyze this using the stats. In the PoolStats of the client's stats there is one called servers that show the number of servers discovered.In this graph I see a variation between the values ​​(2, 1, 0 ).

Comparing with the logs where I see events memberCrashed and memberLeft, I see in a specific time this:

I see the behavior you're seeing. It only happens in certain circumstances though. I think it depends on which connection detects the serverCrashed event. I'll have to look more at that. In the meantime, here is some code you can use to track connections from the client to each server using ClientStats.

When I add this thread to my client, I see:

After starting the client:
Server 192.168.2.8:52783 connection count has increased from 0 to 1
Server 192.168.2.8:52798 connection count has increased from 0 to 1

After doing puts:
Server 192.168.2.8:52783 connection count has increased from 1 to 2
Server 192.168.2.8:52783 connection count has decreased from 2 to 1

After killing one server:
Server 192.168.2.8:52783 connection count has increased from 1 to 2
Server 192.168.2.8:52798 connection count has decreased from 1 to 0

After killing the other server:
Server 192.168.2.8:52783 connection count has decreased from 2 to 0