use of com.hazelcast.core.InitialMembershipListener in project hazelcast by hazelcast.
the class ClusterServiceImpl method addMembershipListener.
public String addMembershipListener(MembershipListener listener) {
checkNotNull(listener, "listener cannot be null");
EventService eventService = nodeEngine.getEventService();
EventRegistration registration;
if (listener instanceof InitialMembershipListener) {
lock.lock();
try {
((InitialMembershipListener) listener).init(new InitialMembershipEvent(this, getMembers()));
registration = eventService.registerLocalListener(SERVICE_NAME, SERVICE_NAME, listener);
} finally {
lock.unlock();
}
} else {
registration = eventService.registerLocalListener(SERVICE_NAME, SERVICE_NAME, listener);
}
return registration.getId();
}
use of com.hazelcast.core.InitialMembershipListener in project hazelcast by hazelcast.
the class ClientClusterServiceImpl method initMembershipListener.
private void initMembershipListener(MembershipListener listener) {
if (listener instanceof InitialMembershipListener) {
Cluster cluster = client.getCluster();
Collection<Member> memberCollection = members.get().values();
LinkedHashSet<Member> members = new LinkedHashSet<Member>(memberCollection);
InitialMembershipEvent event = new InitialMembershipEvent(cluster, members);
((InitialMembershipListener) listener).init(event);
}
}
Aggregations