Search in sources :

Example 1 with GetMemberUuidTask

use of com.hazelcast.client.executor.tasks.GetMemberUuidTask in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMembers.

@Test
public void testSubmitCallableToMembers() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    Callable<String> getUuidCallable = new GetMemberUuidTask();
    Collection<Member> collection = server.getCluster().getMembers();
    Map<Member, Future<String>> map = service.submitToMembers(getUuidCallable, collection);
    for (Member member : map.keySet()) {
        Future<String> result = map.get(member);
        String uuid = result.get();
        assertEquals(member.getUuid(), uuid);
    }
}
Also used : GetMemberUuidTask(com.hazelcast.client.executor.tasks.GetMemberUuidTask) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with GetMemberUuidTask

use of com.hazelcast.client.executor.tasks.GetMemberUuidTask in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMembers_withMemberSelector.

@Test
public void testSubmitCallableToMembers_withMemberSelector() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    Callable<String> getUuidCallable = new GetMemberUuidTask();
    MemberSelector selectAll = new SelectAllMembers();
    Map<Member, Future<String>> map = service.submitToMembers(getUuidCallable, selectAll);
    for (Member member : map.keySet()) {
        Future<String> result = map.get(member);
        String uuid = result.get();
        assertEquals(member.getUuid(), uuid);
    }
}
Also used : GetMemberUuidTask(com.hazelcast.client.executor.tasks.GetMemberUuidTask) MemberSelector(com.hazelcast.core.MemberSelector) SelectAllMembers(com.hazelcast.client.executor.tasks.SelectAllMembers) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with GetMemberUuidTask

use of com.hazelcast.client.executor.tasks.GetMemberUuidTask in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMember_withExecutionCallback.

@Test
public void testSubmitCallableToMember_withExecutionCallback() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    Callable getUuidCallable = new GetMemberUuidTask();
    Member member = server.getCluster().getLocalMember();
    final CountDownLatch responseLatch = new CountDownLatch(1);
    final AtomicReference<Object> result = new AtomicReference<Object>();
    service.submitToMember(getUuidCallable, member, new ExecutionCallback() {

        @Override
        public void onResponse(Object response) {
            result.set(response);
            responseLatch.countDown();
        }

        @Override
        public void onFailure(Throwable t) {
        }
    });
    assertOpenEventually("responseLatch", responseLatch);
    assertEquals(member.getUuid(), result.get());
}
Also used : GetMemberUuidTask(com.hazelcast.client.executor.tasks.GetMemberUuidTask) AtomicReference(java.util.concurrent.atomic.AtomicReference) IExecutorService(com.hazelcast.core.IExecutorService) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.core.Member) 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 4 with GetMemberUuidTask

use of com.hazelcast.client.executor.tasks.GetMemberUuidTask in project hazelcast by hazelcast.

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMember.

@Test
public void testSubmitCallableToMember() throws Exception {
    IExecutorService service = client.getExecutorService(randomString());
    Callable<String> getUuidCallable = new GetMemberUuidTask();
    Member member = server.getCluster().getLocalMember();
    Future<String> result = service.submitToMember(getUuidCallable, member);
    assertEquals(member.getUuid(), result.get());
}
Also used : GetMemberUuidTask(com.hazelcast.client.executor.tasks.GetMemberUuidTask) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) Member(com.hazelcast.core.Member) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

GetMemberUuidTask (com.hazelcast.client.executor.tasks.GetMemberUuidTask)4 IExecutorService (com.hazelcast.core.IExecutorService)4 Member (com.hazelcast.core.Member)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)3 Future (java.util.concurrent.Future)2 AppendCallable (com.hazelcast.client.executor.tasks.AppendCallable)1 MapPutPartitionAwareCallable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareCallable)1 NullCallable (com.hazelcast.client.executor.tasks.NullCallable)1 SelectAllMembers (com.hazelcast.client.executor.tasks.SelectAllMembers)1 ExecutionCallback (com.hazelcast.core.ExecutionCallback)1 MemberSelector (com.hazelcast.core.MemberSelector)1 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1