use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class AbstractCacheService method deregisterAllListener.
@Override
public void deregisterAllListener(String name) {
EventService eventService = getNodeEngine().getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, name);
if (registrations != null) {
for (EventRegistration registration : registrations) {
Closeable listener = closeableListeners.remove(registration.getId());
if (listener != null) {
IOUtil.closeResource(listener);
}
}
}
eventService.deregisterAllListeners(AbstractCacheService.SERVICE_NAME, name);
CacheContext cacheContext = cacheContexts.get(name);
if (cacheContext != null) {
cacheContext.resetCacheEntryListenerCount();
cacheContext.resetInvalidationListenerCount();
}
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class AbstractCacheService method deregisterListener.
@Override
public boolean deregisterListener(String name, String registrationId) {
EventService eventService = getNodeEngine().getEventService();
boolean result = eventService.deregisterListener(SERVICE_NAME, name, registrationId);
Closeable listener = closeableListeners.remove(registrationId);
if (listener != null) {
IOUtil.closeResource(listener);
}
return result;
}
use of com.hazelcast.spi.EventService in project hazelcast by hazelcast.
the class ClusterServiceImpl method removeMembershipListener.
public boolean removeMembershipListener(String registrationId) {
checkNotNull(registrationId, "registrationId cannot be null");
EventService eventService = nodeEngine.getEventService();
return eventService.deregisterListener(SERVICE_NAME, SERVICE_NAME, registrationId);
}
use of com.hazelcast.spi.EventService 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.spi.EventService in project hazelcast by hazelcast.
the class ClusterServiceImpl method sendMemberAttributeEvent.
private void sendMemberAttributeEvent(MemberImpl member, MemberAttributeOperationType operationType, String key, Object value) {
final MemberAttributeServiceEvent event = new MemberAttributeServiceEvent(this, member, operationType, key, value);
MemberAttributeEvent attributeEvent = new MemberAttributeEvent(this, member, operationType, key, value);
Collection<MembershipAwareService> membershipAwareServices = nodeEngine.getServices(MembershipAwareService.class);
if (membershipAwareServices != null && !membershipAwareServices.isEmpty()) {
for (final MembershipAwareService service : membershipAwareServices) {
// service events should not block each other
nodeEngine.getExecutionService().execute(ExecutionService.SYSTEM_EXECUTOR, new Runnable() {
public void run() {
service.memberAttributeChanged(event);
}
});
}
}
EventService eventService = nodeEngine.getEventService();
Collection<EventRegistration> registrations = eventService.getRegistrations(SERVICE_NAME, SERVICE_NAME);
for (EventRegistration reg : registrations) {
eventService.publishEvent(SERVICE_NAME, reg, attributeEvent, reg.getId().hashCode());
}
}
Aggregations