@Override
 public void memberRemoved(MembershipEvent membershipEvent) {
   synchronized (listenerRegLock) {
     Member member = membershipEvent.getMember();
     members.remove(member);
     for (Map<Address, ClientEventRegistration> registrationMap : registrations.values()) {
       ClientEventRegistration registration = registrationMap.remove(member.getAddress());
       removeEventHandler(registration.getCallId());
     }
   }
 }
 // For Testing
 public Collection<ClientEventRegistration> getActiveRegistrations(String uuid) {
   synchronized (listenerRegLock) {
     Map<Address, ClientEventRegistration> registrationMap =
         registrations.get(new ClientRegistrationKey(uuid));
     if (registrationMap == null) {
       return Collections.EMPTY_LIST;
     }
     LinkedList<ClientEventRegistration> activeRegistrations =
         new LinkedList<ClientEventRegistration>();
     for (ClientEventRegistration registration : registrationMap.values()) {
       for (Member member : members) {
         if (member.getAddress().equals(registration.getSubscriber())) {
           activeRegistrations.add(registration);
         }
       }
     }
     return activeRegistrations;
   }
 }
  @Override
  public boolean deregisterListener(String userRegistrationId) {
    synchronized (listenerRegLock) {
      ClientRegistrationKey key = new ClientRegistrationKey(userRegistrationId);
      Map<Address, ClientEventRegistration> registrationMap = registrations.get(key);

      if (registrationMap == null) {
        return false;
      }

      boolean successful = true;
      for (ClientEventRegistration registration : registrationMap.values()) {
        Address subscriber = registration.getSubscriber();
        try {
          ListenerMessageCodec listenerMessageCodec = registration.getCodec();
          String serverRegistrationId = registration.getServerRegistrationId();
          ClientMessage request = listenerMessageCodec.encodeRemoveRequest(serverRegistrationId);
          Future future = new ClientInvocation(client, request, subscriber).invoke();
          future.get();
          removeEventHandler(registration.getCallId());
          registrationMap.remove(subscriber);
        } catch (Exception e) {
          successful = false;
          logger.warning(
              "Deregistration of listener with id "
                  + userRegistrationId
                  + " has failed to address "
                  + subscriber,
              e);
        }
      }

      if (successful) {
        registrations.remove(key);
      }
      return successful;
    }
  }