Search in sources :

Example 1 with GetMemberUuidTask

use of com.hazelcast.client.test.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<UUID> getUuidCallable = new GetMemberUuidTask();
    MemberSelector selectAll = new SelectAllMembers();
    Map<Member, Future<UUID>> map = service.submitToMembers(getUuidCallable, selectAll);
    for (Member member : map.keySet()) {
        Future<UUID> result = map.get(member);
        UUID uuid = result.get();
        assertEquals(member.getUuid(), uuid);
    }
}
Also used : GetMemberUuidTask(com.hazelcast.client.test.executor.tasks.GetMemberUuidTask) MemberSelector(com.hazelcast.cluster.MemberSelector) SelectAllMembers(com.hazelcast.client.test.executor.tasks.SelectAllMembers) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) UUID(java.util.UUID) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 2 with GetMemberUuidTask

use of com.hazelcast.client.test.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<UUID> getUuidCallable = new GetMemberUuidTask();
    Collection<Member> collection = server.getCluster().getMembers();
    Map<Member, Future<UUID>> map = service.submitToMembers(getUuidCallable, collection);
    for (Member member : map.keySet()) {
        Future<UUID> result = map.get(member);
        UUID uuid = result.get();
        assertEquals(member.getUuid(), uuid);
    }
}
Also used : GetMemberUuidTask(com.hazelcast.client.test.executor.tasks.GetMemberUuidTask) Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) UUID(java.util.UUID) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 3 with GetMemberUuidTask

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

the class ClientExecutorServiceSubmitTest method testSubmitCallableToMember_withExecutionCallback.

@Test
public void testSubmitCallableToMember_withExecutionCallback() {
    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.test.executor.tasks.GetMemberUuidTask) AtomicReference(java.util.concurrent.atomic.AtomicReference) IExecutorService(com.hazelcast.core.IExecutorService) CountDownLatch(java.util.concurrent.CountDownLatch) Member(com.hazelcast.cluster.Member) NullCallable(com.hazelcast.client.test.executor.tasks.NullCallable) Callable(java.util.concurrent.Callable) AppendCallable(com.hazelcast.client.test.executor.tasks.AppendCallable) MapPutPartitionAwareCallable(com.hazelcast.client.test.executor.tasks.MapPutPartitionAwareCallable) MultiExecutionCallback(com.hazelcast.core.MultiExecutionCallback) ExecutionCallback(com.hazelcast.core.ExecutionCallback) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 4 with GetMemberUuidTask

use of com.hazelcast.client.test.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<UUID> getUuidCallable = new GetMemberUuidTask();
    Member member = server.getCluster().getLocalMember();
    Future<UUID> result = service.submitToMember(getUuidCallable, member);
    assertEquals(member.getUuid(), result.get());
}
Also used : GetMemberUuidTask(com.hazelcast.client.test.executor.tasks.GetMemberUuidTask) IExecutorService(com.hazelcast.core.IExecutorService) UUID(java.util.UUID) Member(com.hazelcast.cluster.Member) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

GetMemberUuidTask (com.hazelcast.client.test.executor.tasks.GetMemberUuidTask)4 Member (com.hazelcast.cluster.Member)4 IExecutorService (com.hazelcast.core.IExecutorService)4 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 UUID (java.util.UUID)3 Future (java.util.concurrent.Future)2 AppendCallable (com.hazelcast.client.test.executor.tasks.AppendCallable)1 MapPutPartitionAwareCallable (com.hazelcast.client.test.executor.tasks.MapPutPartitionAwareCallable)1 NullCallable (com.hazelcast.client.test.executor.tasks.NullCallable)1 SelectAllMembers (com.hazelcast.client.test.executor.tasks.SelectAllMembers)1 MemberSelector (com.hazelcast.cluster.MemberSelector)1 ExecutionCallback (com.hazelcast.core.ExecutionCallback)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