Search in sources :

Example 6 with ScheduledTaskHandler

use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.

the class ScheduledTaskHandlerImplTest method of_withValidPartition.

@Test
public void of_withValidPartition() throws Exception {
    ScheduledTaskHandler handler = ScheduledTaskHandler.of("urn:hzScheduledTaskHandler:-0SchedulerTask");
    assertTrue(handler.isAssignedToPartition());
    assertEquals(0, handler.getPartitionId());
    assertEquals(null, handler.getAddress());
    assertEquals("Scheduler", handler.getSchedulerName());
    assertEquals("Task", handler.getTaskName());
}
Also used : ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 7 with ScheduledTaskHandler

use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.

the class ScheduledTaskHandlerImplTest method of_equalitySameRef.

@Test
public void of_equalitySameRef() throws Exception {
    String initialURN = "urn:hzScheduledTaskHandler:127.0.0.1:0-1SchedulerTask";
    ScheduledTaskHandler handler = ScheduledTaskHandler.of(initialURN);
    assertEquals(handler, handler);
}
Also used : ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 8 with ScheduledTaskHandler

use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.

the class ScheduledTaskHandlerImplTest method of_addressConstructor.

@Test
public void of_addressConstructor() throws Exception {
    Address addr = new Address("127.0.0.1", 0);
    ScheduledTaskHandler handler = ScheduledTaskHandlerImpl.of(addr, "Scheduler", "Task");
    String expectedURN = "urn:hzScheduledTaskHandler:127.0.0.1:0-1SchedulerTask";
    assertTrue(handler.isAssignedToMember());
    assertEquals(-1, handler.getPartitionId());
    assertEquals(addr, handler.getAddress());
    assertEquals("Scheduler", handler.getSchedulerName());
    assertEquals("Task", handler.getTaskName());
    assertEquals(expectedURN, handler.toUrn());
}
Also used : Address(com.hazelcast.nio.Address) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 9 with ScheduledTaskHandler

use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.

the class ScheduledTaskHandlerImplTest method of_withValidAddress.

@Test
public void of_withValidAddress() throws Exception {
    Address addr = new Address("127.0.0.1", 0);
    ScheduledTaskHandler handler = ScheduledTaskHandler.of("urn:hzScheduledTaskHandler:127.0.0.1:0-1SchedulerTask");
    assertTrue(handler.isAssignedToMember());
    assertEquals(-1, handler.getPartitionId());
    assertEquals(addr, handler.getAddress());
    assertEquals("Scheduler", handler.getSchedulerName());
    assertEquals("Task", handler.getTaskName());
}
Also used : Address(com.hazelcast.nio.Address) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 10 with ScheduledTaskHandler

use of com.hazelcast.scheduledexecutor.ScheduledTaskHandler in project hazelcast by hazelcast.

the class ScheduledExecutorGetAllScheduledMessageTask method accumulateTaskHandlersAsUrnValues.

@SuppressWarnings("unchecked")
private void accumulateTaskHandlersAsUrnValues(Map<Member, List<ScheduledTaskHandler>> accumulator, Map<?, ?> taskHandlersMap) {
    ClusterService clusterService = nodeEngine.getClusterService();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    for (Map.Entry<?, ?> entry : taskHandlersMap.entrySet()) {
        Member owner;
        Object key = entry.getKey();
        if (key instanceof Number) {
            owner = clusterService.getMember(partitionService.getPartitionOwner((Integer) key));
        } else {
            owner = (Member) key;
        }
        List<ScheduledTaskHandler> handlers = (List<ScheduledTaskHandler>) entry.getValue();
        if (accumulator.containsKey(owner)) {
            List<ScheduledTaskHandler> memberUrns = accumulator.get(owner);
            memberUrns.addAll(handlers);
        } else {
            accumulator.put(owner, handlers);
        }
    }
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) ScheduledTaskHandler(com.hazelcast.scheduledexecutor.ScheduledTaskHandler) IPartitionService(com.hazelcast.spi.partition.IPartitionService) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Member(com.hazelcast.core.Member)

Aggregations

ScheduledTaskHandler (com.hazelcast.scheduledexecutor.ScheduledTaskHandler)19 Test (org.junit.Test)13 ParallelTest (com.hazelcast.test.annotation.ParallelTest)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 ArrayList (java.util.ArrayList)4 Member (com.hazelcast.core.Member)3 List (java.util.List)3 Map (java.util.Map)3 ClusterService (com.hazelcast.internal.cluster.ClusterService)2 Address (com.hazelcast.nio.Address)2 IScheduledFuture (com.hazelcast.scheduledexecutor.IScheduledFuture)2 DistributedScheduledExecutorService (com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService)2 IPartitionService (com.hazelcast.spi.partition.IPartitionService)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedList (java.util.LinkedList)2 ClientMessage (com.hazelcast.client.impl.protocol.ClientMessage)1 ClientInvocation (com.hazelcast.client.spi.impl.ClientInvocation)1 ClientInvocationFuture (com.hazelcast.client.spi.impl.ClientInvocationFuture)1 AbstractDistributedObject (com.hazelcast.spi.AbstractDistributedObject)1