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:- 0 Scheduler Task");
assertTrue(handler.isAssignedToPartition());
assertEquals(0, handler.getPartitionId());
assertEquals(null, handler.getAddress());
assertEquals("Scheduler", handler.getSchedulerName());
assertEquals("Task", handler.getTaskName());
}
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 -1 Scheduler Task";
ScheduledTaskHandler handler = ScheduledTaskHandler.of(initialURN);
assertEquals(handler, handler);
}
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 -1 Scheduler Task";
assertTrue(handler.isAssignedToMember());
assertEquals(-1, handler.getPartitionId());
assertEquals(addr, handler.getAddress());
assertEquals("Scheduler", handler.getSchedulerName());
assertEquals("Task", handler.getTaskName());
assertEquals(expectedURN, handler.toUrn());
}
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 -1 Scheduler Task");
assertTrue(handler.isAssignedToMember());
assertEquals(-1, handler.getPartitionId());
assertEquals(addr, handler.getAddress());
assertEquals("Scheduler", handler.getSchedulerName());
assertEquals("Task", handler.getTaskName());
}
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);
}
}
}
Aggregations