use of com.hazelcast.spi.MemberAttributeServiceEvent in project hazelcast by hazelcast.
the class QuorumTest method testQuorumIgnoresMemberAttributeEvents.
@Test
public void testQuorumIgnoresMemberAttributeEvents() {
final RecordingQuorumFunction function = new RecordingQuorumFunction();
QuorumConfig quorumConfig = new QuorumConfig().setName(randomString()).setEnabled(true).setQuorumFunctionImplementation(function);
Config config = new Config().addQuorumConfig(quorumConfig);
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
NodeEngineImpl nodeEngine = getNodeEngineImpl(hazelcastInstance);
MembershipAwareService service = nodeEngine.getService(QuorumServiceImpl.SERVICE_NAME);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
assertTrue(function.wasCalled);
}
});
function.wasCalled = false;
MemberAttributeServiceEvent event = mock(MemberAttributeServiceEvent.class);
service.memberAttributeChanged(event);
assertFalse(function.wasCalled);
}
use of com.hazelcast.spi.MemberAttributeServiceEvent 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