use of com.hazelcast.core.MemberSelector in project hazelcast by hazelcast.
the class ClientExecutorServiceSubmitTest method submitCallable_withExecutionCallback.
@Test
public void submitCallable_withExecutionCallback() {
IExecutorService service = client.getExecutorService(randomString());
final CountDownLatch responseLatch = new CountDownLatch(1);
String msg = randomString();
Callable runnable = new AppendCallable(msg);
MemberSelector selector = new SelectAllMembers();
final AtomicReference<Object> result = new AtomicReference<Object>();
service.submit(runnable, selector, new ExecutionCallback() {
public void onResponse(Object response) {
result.set(response);
responseLatch.countDown();
}
public void onFailure(Throwable t) {
}
});
assertOpenEventually("responseLatch", responseLatch);
assertEquals(msg + AppendCallable.APPENDAGE, result.get());
}
use of com.hazelcast.core.MemberSelector in project hazelcast by hazelcast.
the class PartitionStateManager method createMemberGroups.
private Collection<MemberGroup> createMemberGroups(final Set<Address> excludedAddresses) {
MemberSelector exclude = new MemberSelector() {
@Override
public boolean select(Member member) {
return !excludedAddresses.contains(member.getAddress());
}
};
final MemberSelector selector = MemberSelectors.and(DATA_MEMBER_SELECTOR, exclude);
final Collection<Member> members = node.getClusterService().getMembers(selector);
return memberGroupFactory.createMemberGroups(members);
}
use of com.hazelcast.core.MemberSelector in project hazelcast by hazelcast.
the class MemberSelectorsTest method testOrMemberSelector2.
@Test
public void testOrMemberSelector2() {
MemberSelector selector = MemberSelectors.or(LOCAL_MEMBER_SELECTOR, LITE_MEMBER_SELECTOR);
assertFalse(selector.select(member));
verify(member).localMember();
verify(member).isLiteMember();
}
use of com.hazelcast.core.MemberSelector in project hazelcast by hazelcast.
the class MemberSelectorsTest method testOrMemberSelector.
@Test
public void testOrMemberSelector() {
when(member.localMember()).thenReturn(true);
MemberSelector selector = MemberSelectors.or(LOCAL_MEMBER_SELECTOR, LITE_MEMBER_SELECTOR);
assertTrue(selector.select(member));
verify(member).localMember();
verify(member, never()).isLiteMember();
}
use of com.hazelcast.core.MemberSelector in project hazelcast by hazelcast.
the class MemberSelectorsTest method testAndMemberSelector3.
@Test
public void testAndMemberSelector3() {
when(member.localMember()).thenReturn(true);
when(member.isLiteMember()).thenReturn(true);
MemberSelector selector = MemberSelectors.and(LOCAL_MEMBER_SELECTOR, LITE_MEMBER_SELECTOR);
assertTrue(selector.select(member));
verify(member).localMember();
verify(member).isLiteMember();
}
Aggregations