Search in sources :

Example 6 with DistributedDurableExecutorService

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);
    }
}
Also used : DistributedDurableExecutorService(com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService) DurableExecutorPartitionContainer(com.hazelcast.durableexecutor.impl.DurableExecutorPartitionContainer)

Example 7 with DistributedDurableExecutorService

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);
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Accessors.getNodeEngineImpl(com.hazelcast.test.Accessors.getNodeEngineImpl) DistributedDurableExecutorService(com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService) InternalPartitionService(com.hazelcast.internal.partition.InternalPartitionService) ArrayList(java.util.ArrayList) DistributedDurableExecutorService(com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService) HazelcastInstance(com.hazelcast.core.HazelcastInstance) DurableExecutorContainer(com.hazelcast.durableexecutor.impl.DurableExecutorContainer) DurableExecutorServiceHelper.getDurableExecutorContainer(com.hazelcast.durableexecutor.impl.DurableExecutorServiceHelper.getDurableExecutorContainer) Future(java.util.concurrent.Future) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

DistributedDurableExecutorService (com.hazelcast.durableexecutor.impl.DistributedDurableExecutorService)7 QueueService (com.hazelcast.collection.impl.queue.QueueService)2 DurableExecutorPartitionContainer (com.hazelcast.durableexecutor.impl.DurableExecutorPartitionContainer)2 DistributedExecutorService (com.hazelcast.executor.impl.DistributedExecutorService)2 FlakeIdGeneratorService (com.hazelcast.flakeidgen.impl.FlakeIdGeneratorService)2 PNCounterService (com.hazelcast.internal.crdt.pncounter.PNCounterService)2 MapService (com.hazelcast.map.impl.MapService)2 MultiMapService (com.hazelcast.multimap.impl.MultiMapService)2 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)2 DistributedScheduledExecutorService (com.hazelcast.scheduledexecutor.impl.DistributedScheduledExecutorService)2 TopicService (com.hazelcast.topic.impl.TopicService)2 ReliableTopicService (com.hazelcast.topic.impl.reliable.ReliableTopicService)2 CacheService (com.hazelcast.cache.impl.CacheService)1 CardinalityEstimatorService (com.hazelcast.cardinality.impl.CardinalityEstimatorService)1 ListService (com.hazelcast.collection.impl.list.ListService)1 SetService (com.hazelcast.collection.impl.set.SetService)1 CacheConfig (com.hazelcast.config.CacheConfig)1 Config (com.hazelcast.config.Config)1 ConfigAccessor.getActiveMemberNetworkConfig (com.hazelcast.config.ConfigAccessor.getActiveMemberNetworkConfig)1 ManagementCenterConfig (com.hazelcast.config.ManagementCenterConfig)1