use of com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService in project hazelcast by hazelcast.
the class ReplicationOperation method run.
@Override
public void run() throws Exception {
DistributedDurableExecutorService service = getService();
DurableExecutorPartitionContainer partitionContainer = service.getPartitionContainer(getPartitionId());
for (DurableHolder durableHolder : list) {
partitionContainer.createExecutorContainer(durableHolder.name, durableHolder.ringBuffer);
}
}
use of com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService in project hazelcast by hazelcast.
the class DurableExecutorServiceTest method testDestroyCleansAllContainers.
@Test
public void testDestroyCleansAllContainers() throws Exception {
String executorName = randomMapName();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(NODE_COUNT);
HazelcastInstance[] instances = factory.newInstances(smallInstanceConfig());
DurableExecutorService service = instances[0].getDurableExecutorService(executorName);
InternalPartitionService partitionService = getNodeEngineImpl(instances[0]).getPartitionService();
List<Future<String>> futures = new ArrayList<>(TASK_COUNT);
for (int i = 0; i < TASK_COUNT; i++) {
futures.add(service.submit(new DummyCallable()));
}
for (Future<String> future : futures) {
future.get();
}
// wait for all backup operations to complete
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
NodeEngineImpl ne = getNodeEngineImpl(instance);
DistributedDurableExecutorService internalService = ne.getService(DistributedDurableExecutorService.SERVICE_NAME);
for (int partitionId = 0; partitionId < partitionService.getPartitionCount(); partitionId++) {
DurableExecutorContainer container = getDurableExecutorContainer(internalService, partitionId, executorName);
if (container != null) {
assertEquals(0, container.getRingBuffer().getTaskSize());
}
}
}
});
service.destroy();
assertTrueEventually(() -> {
for (HazelcastInstance instance : instances) {
NodeEngineImpl ne = getNodeEngineImpl(instance);
DistributedDurableExecutorService internalService = ne.getService(DistributedDurableExecutorService.SERVICE_NAME);
boolean allEmpty = true;
StringBuilder failMessage = new StringBuilder();
for (int partitionId = 0; partitionId < partitionService.getPartitionCount(); partitionId++) {
DurableExecutorContainer container = getDurableExecutorContainer(internalService, partitionId, executorName);
if (container != null) {
failMessage.append(String.format("Partition %d owned by %s on %s\n", partitionId, partitionService.getPartition(partitionId).getOwnerOrNull(), instance));
allEmpty = false;
}
}
assertTrue(String.format("Some partitions have non-null containers for executor %s:\n%s", executorName, failMessage.toString()), allEmpty);
}
}, 30);
}
Aggregations