Search in sources :

Example 71 with IExecutorService

use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecuteOnMember_WhenMemberNull.

@Test(expected = NullPointerException.class)
public void testExecuteOnMember_WhenMemberNull() {
    IExecutorService service = client.getExecutorService(randomString());
    service.executeOnMember(new MapPutRunnable("map"), null);
}
Also used : MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) IExecutorService(com.hazelcast.core.IExecutorService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 72 with IExecutorService

use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecuteOnKeyOwner.

@Test
public void testExecuteOnKeyOwner() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    Member member = server1.getCluster().getLocalMember();
    final String targetUuid = member.getUuid();
    String key = generateKeyOwnedBy(server1);
    service.executeOnKeyOwner(new MapPutRunnable(mapName), key);
    final IMap map = client.getMap(mapName);
    assertTrueEventually(new AssertTask() {

        public void run() throws Exception {
            assertTrue(map.containsKey(targetUuid));
        }
    });
}
Also used : IMap(com.hazelcast.core.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) AssertTask(com.hazelcast.test.AssertTask) 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 73 with IExecutorService

use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.

the class ClientExecutorServiceExecuteTest method testExecute.

@Test
public void testExecute() {
    IExecutorService service = client.getExecutorService(randomString());
    String mapName = randomString();
    service.execute(new MapPutRunnable(mapName));
    IMap map = client.getMap(mapName);
    assertSizeEventually(1, map);
}
Also used : IMap(com.hazelcast.core.IMap) MapPutRunnable(com.hazelcast.client.executor.tasks.MapPutRunnable) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 74 with IExecutorService

use of com.hazelcast.core.IExecutorService in project hazelcast by hazelcast.

the class ClientExecutorServiceInvokeTest method testInvokeAll_withTimeOut.

@Test(expected = UnsupportedOperationException.class)
public void testInvokeAll_withTimeOut() throws Throwable {
    IExecutorService service = client.getExecutorService(randomString());
    Collection<Callable<String>> collection = new ArrayList<Callable<String>>();
    collection.add(new AppendCallable());
    collection.add(new AppendCallable());
    service.invokeAll(collection, 1, TimeUnit.MINUTES);
}
Also used : AppendCallable(com.hazelcast.client.executor.tasks.AppendCallable) ArrayList(java.util.ArrayList) IExecutorService(com.hazelcast.core.IExecutorService) HazelcastTestSupport.randomString(com.hazelcast.test.HazelcastTestSupport.randomString) Callable(java.util.concurrent.Callable) AppendCallable(com.hazelcast.client.executor.tasks.AppendCallable) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 75 with IExecutorService

use of com.hazelcast.core.IExecutorService 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)

Aggregations

IExecutorService (com.hazelcast.core.IExecutorService)152 QuickTest (com.hazelcast.test.annotation.QuickTest)138 Test (org.junit.Test)138 ParallelTest (com.hazelcast.test.annotation.ParallelTest)137 HazelcastInstance (com.hazelcast.core.HazelcastInstance)66 Member (com.hazelcast.core.Member)57 HazelcastTestSupport.randomString (com.hazelcast.test.HazelcastTestSupport.randomString)46 Future (java.util.concurrent.Future)36 IMap (com.hazelcast.core.IMap)32 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)28 CountDownLatch (java.util.concurrent.CountDownLatch)28 MapPutRunnable (com.hazelcast.client.executor.tasks.MapPutRunnable)25 ExecutorConfig (com.hazelcast.config.ExecutorConfig)20 MultiExecutionCallback (com.hazelcast.core.MultiExecutionCallback)20 Config (com.hazelcast.config.Config)19 ExecutionException (java.util.concurrent.ExecutionException)18 AppendCallable (com.hazelcast.client.executor.tasks.AppendCallable)16 AssertTask (com.hazelcast.test.AssertTask)16 ICompletableFuture (com.hazelcast.core.ICompletableFuture)13 MapPutPartitionAwareRunnable (com.hazelcast.client.executor.tasks.MapPutPartitionAwareRunnable)11