Search in sources :

Example 6 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class ExecutorServiceTest method testManagedContextAndLocal.

@Test
public void testManagedContextAndLocal() throws Exception {
    Config config = smallInstanceConfig();
    config.addExecutorConfig(new ExecutorConfig("test", 1));
    final AtomicBoolean initialized = new AtomicBoolean();
    config.setManagedContext(obj -> {
        if (obj instanceof RunnableWithManagedContext) {
            initialized.set(true);
        }
        return obj;
    });
    HazelcastInstance instance = createHazelcastInstance(config);
    IExecutorService executor = instance.getExecutorService("test");
    RunnableWithManagedContext task = new RunnableWithManagedContext();
    executor.submit(task).get();
    assertTrue("The task should have been initialized by the ManagedContext", initialized.get());
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ExecutorConfig(com.hazelcast.config.ExecutorConfig) Config(com.hazelcast.config.Config) IExecutorService(com.hazelcast.core.IExecutorService) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 7 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class DistributedExecutorServiceTest method testExecutorConfigCache_whenSecondTaskSubmitted_thenCachedConfigIsSame.

@Test
public void testExecutorConfigCache_whenSecondTaskSubmitted_thenCachedConfigIsSame() throws Exception {
    IExecutorService executorService = hz.getExecutorService(EXECUTOR_NAME);
    Future future = executorService.submit(new EmptyRunnable());
    future.get();
    ExecutorConfig cachedConfig = distributedExecutorService.executorConfigCache.get(EXECUTOR_NAME);
    future = executorService.submit(new EmptyRunnable());
    future.get();
    assertEquals("Executor config cache should have cached one element", 1, distributedExecutorService.executorConfigCache.size());
    assertSame("Executor config cache should have reused the same ExecutorConfig", cachedConfig, distributedExecutorService.executorConfigCache.get(EXECUTOR_NAME));
}
Also used : Future(java.util.concurrent.Future) IExecutorService(com.hazelcast.core.IExecutorService) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 8 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class ExecutorServiceTestSupport method createSingleNodeExecutorService.

IExecutorService createSingleNodeExecutorService(String name, int poolSize, boolean statsEnabled) {
    ExecutorConfig executorConfig = new ExecutorConfig(name, poolSize).setStatisticsEnabled(statsEnabled);
    HazelcastInstance instance = createHazelcastInstance(smallInstanceConfig().addExecutorConfig(executorConfig));
    return instance.getExecutorService(name);
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig)

Example 9 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class AbstractDynamicConfigGeneratorTest method testExecutor.

// EXECUTOR
@Test
public void testExecutor() {
    ExecutorConfig expectedConfig = new ExecutorConfig().setName("testExecutor").setStatisticsEnabled(true).setPoolSize(10).setQueueCapacity(100).setSplitBrainProtectionName("splitBrainProtection");
    Config config = new Config().addExecutorConfig(expectedConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    ExecutorConfig actualConfig = decConfig.getExecutorConfig(expectedConfig.getName());
    assertEquals(expectedConfig, actualConfig);
}
Also used : ListConfig(com.hazelcast.config.ListConfig) EventJournalConfig(com.hazelcast.config.EventJournalConfig) AwsConfig(com.hazelcast.config.AwsConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) MapConfig(com.hazelcast.config.MapConfig) PredicateConfig(com.hazelcast.config.PredicateConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) PartitioningStrategyConfig(com.hazelcast.config.PartitioningStrategyConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) DiscoveryStrategyConfig(com.hazelcast.config.DiscoveryStrategyConfig) DiskTierConfig(com.hazelcast.config.DiskTierConfig) IndexConfig(com.hazelcast.config.IndexConfig) NearCacheConfig(com.hazelcast.config.NearCacheConfig) MapStoreConfig(com.hazelcast.config.MapStoreConfig) QueueStoreConfig(com.hazelcast.config.QueueStoreConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) RingbufferStoreConfig(com.hazelcast.config.RingbufferStoreConfig) WanConsumerConfig(com.hazelcast.config.WanConsumerConfig) AttributeConfig(com.hazelcast.config.AttributeConfig) SetConfig(com.hazelcast.config.SetConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) QueueConfig(com.hazelcast.config.QueueConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig) WanCustomPublisherConfig(com.hazelcast.config.WanCustomPublisherConfig) WanBatchPublisherConfig(com.hazelcast.config.WanBatchPublisherConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) EvictionConfig(com.hazelcast.config.EvictionConfig) TieredStoreConfig(com.hazelcast.config.TieredStoreConfig) QueryCacheConfig(com.hazelcast.config.QueryCacheConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) TopicConfig(com.hazelcast.config.TopicConfig) Config(com.hazelcast.config.Config) DiscoveryConfig(com.hazelcast.config.DiscoveryConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) DataPersistenceConfig(com.hazelcast.config.DataPersistenceConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) WanReplicationConfig(com.hazelcast.config.WanReplicationConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) MerkleTreeConfig(com.hazelcast.config.MerkleTreeConfig) MemoryTierConfig(com.hazelcast.config.MemoryTierConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) Test(org.junit.Test)

Example 10 with ExecutorConfig

use of com.hazelcast.config.ExecutorConfig in project hazelcast by hazelcast.

the class DynamicConfigTest method testExecutorConfig.

@Test
public void testExecutorConfig() {
    ExecutorConfig config = new ExecutorConfig(name, 7).setStatisticsEnabled(true).setQueueCapacity(13);
    driver.getConfig().addExecutorConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ExecutorConfig (com.hazelcast.config.ExecutorConfig)30 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)15 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)15 Config (com.hazelcast.config.Config)12 Test (org.junit.Test)11 QuickTest (com.hazelcast.test.annotation.QuickTest)10 HazelcastInstance (com.hazelcast.core.HazelcastInstance)9 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)9 IExecutorService (com.hazelcast.core.IExecutorService)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)5 ListConfig (com.hazelcast.config.ListConfig)5 MapConfig (com.hazelcast.config.MapConfig)5 MultiMapConfig (com.hazelcast.config.MultiMapConfig)5 PNCounterConfig (com.hazelcast.config.PNCounterConfig)5 QueueConfig (com.hazelcast.config.QueueConfig)5 ReliableTopicConfig (com.hazelcast.config.ReliableTopicConfig)5 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)5 RingbufferConfig (com.hazelcast.config.RingbufferConfig)5