Search in sources :

Example 16 with MemberSelector

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());
}
Also used : MemberSelector(com.hazelcast.core.MemberSelector) AppendCallable(com.hazelcast.client.executor.tasks.AppendCallable) SelectAllMembers(com.hazelcast.client.executor.tasks.SelectAllMembers) AtomicReference(java.util.concurrent.atomic.AtomicReference) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) CountDownLatch(java.util.concurrent.CountDownLatch) NullCallable(com.hazelcast.client.executor.tasks.NullCallable) Callable(java.util.concurrent.Callable) MapPutPartitionAwareCallable(com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable) AppendCallable(com.hazelcast.client.executor.tasks.AppendCallable) MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) ExecutionCallback(com.hazelcast.core.ExecutionCallback) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 17 with MemberSelector

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);
}
Also used : MemberSelector(com.hazelcast.core.MemberSelector) Member(com.hazelcast.core.Member)

Example 18 with MemberSelector

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();
}
Also used : MemberSelector(com.hazelcast.core.MemberSelector) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 19 with MemberSelector

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();
}
Also used : MemberSelector(com.hazelcast.core.MemberSelector) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 20 with MemberSelector

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();
}
Also used : MemberSelector(com.hazelcast.core.MemberSelector) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

MemberSelector (com.hazelcast.core.MemberSelector)20 QuickTest (com.hazelcast.test.annotation.QuickTest)19 Test (org.junit.Test)19 ParallelTest (com.hazelcast.test.annotation.ParallelTest)12 IExecutorService (com.hazelcast.core.IExecutorService)11 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)9 SelectAllMembers (com.hazelcast.client.executor.tasks.SelectAllMembers)8 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)6 Member (com.hazelcast.core.Member)6 IMap (com.hazelcast.core.IMap)4 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 AppendCallable (com.hazelcast.client.executor.tasks.AppendCallable)3 MapPutPartitionAwareCallable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable)2 MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)2 NullCallable (com.hazelcast.client.executor.tasks.NullCallable)2 ExecutionCallback (com.hazelcast.core.ExecutionCallback)2 Callable (java.util.concurrent.Callable)2 GetMemberUuidTask (com.hazelcast.client.executor.tasks.GetMemberUuidTask)1 SelectNoMembers (com.hazelcast.client.executor.tasks.SelectNoMembers)1