You can use a ClientMembershipListener (example attached) to be notified
when a connection is made between a client and server. The client will be
notified the first time a connection is made to a specific server and the
last time a connection is lost from a specific server.

Make sure you register the client membership listener like below before
initializing the client cache. This will ensure that the client gets
callbacks for servers that connect when its pool is pre-filled with
connections.

ClientMembership.registerClientMembershipListener(new
TestClientMembershipListener());

With this TestClientMembershipListener, the client will log messages like
below when connections are made to servers:

Server hostname(server2:22215)<v6>:53874 joined (current count is 1)
Server hostname(server1:22200)<v5>:23502 joined (current count is 2)
Server hostname(server3:22234)<v7>:29411 joined (current count is 3)

And messages like below when the servers crash:

Server hostname(server2:22215)<v6>:53874 crashed (current count is 2)
Server hostname(server1:22200)<v5>:23502 crashed (current count is 1)
Server hostname(server3:22234)<v7>:29411 crashed (current count is 0)

The pool's ping interval controls how often the ClientMembershipListener
callbacks are invoked. The ping interval is 10000 ms by default.

The ClientMembershipListener only tracks servers the client is connected
to. So, if the client is not connected to all servers, the listener might
get something like this when there is a failover:

Server hostname(server2:22714)<v24>:13358 joined (current count is 1)
Server hostname(server2:22714)<v24>:13358 crashed (current count is 0)
Server hostname(server1:22699)<v23>:22894 joined (current count is 1)


Barry Oglesby
GemFire Advanced Customer Engineering (ACE)
For immediate support please contact Pivotal Support at
http://support.pivotal.io/


On Thu, Sep 24, 2015 at 12:40 PM, Eric Pederson <[email protected]> wrote:

> Hi all:
>
>
>
> Currently if the entire cluster goes down a client can find out in one of
> two ways: 1)  ACQStatusListener will fire onCqDisconnected or 2) when we
> do an operation it will throw an exception (NoAvailableServersException,
> NoAvailableLocatorsException, etc).   Some of our client applications are
> publish-only, that is, they don’t have any CQs.  These applications might
> not publish again for a few hours.  We’d like to be notified right away,
> like how CQStatusListener.onCqDisconnected works.  Is there a way to do
> that, outside of setting up a CQ or a thread that queries the cache every X
> seconds and responds to exceptions?
>
>
>
> Thanks,
>
> -- Eric
>

Attachment: TestClientMembershipListener.java
Description: Binary data

Reply via email to