Search in sources :

Example 6 with FlakeIdGeneratorConfig

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

the class MemberDomConfigProcessor method handleFlakeIdGenerator.

protected void handleFlakeIdGenerator(Node node) {
    String name = getAttribute(node, "name");
    FlakeIdGeneratorConfig generatorConfig = ConfigUtils.getByNameOrNew(config.getFlakeIdGeneratorConfigs(), name, FlakeIdGeneratorConfig.class);
    handleFlakeIdGeneratorNode(node, generatorConfig);
}
Also used : FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig)

Example 7 with FlakeIdGeneratorConfig

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

the class FlakeIdGenerator_MemberBackpressureTest method before.

@Before
public void before() {
    factory = new TestHazelcastInstanceFactory();
    instance = factory.newHazelcastInstance(new Config().addFlakeIdGeneratorConfig(new FlakeIdGeneratorConfig("gen").setPrefetchCount(BATCH_SIZE)));
}
Also used : Config(com.hazelcast.config.Config) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) Before(org.junit.Before)

Example 8 with FlakeIdGeneratorConfig

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

the class FlakeIdGeneratorProxyTest method givenNodeIdUninitialized_whenNodeIdRequestedConcurrently_thenItNeverReturnUninitializedId.

@Test
public void givenNodeIdUninitialized_whenNodeIdRequestedConcurrently_thenItNeverReturnUninitializedId() throws Exception {
    when(clusterService.getMemberListJoinVersion()).thenReturn(20);
    int threadCount = 20;
    int iterationCount = 5_000;
    ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
    AtomicInteger errorCounter = new AtomicInteger();
    FlakeIdGeneratorConfig genConfig = new FlakeIdGeneratorConfig();
    for (int i = 0; i < iterationCount; i++) {
        initialize(genConfig);
        FlakeIdGeneratorProxy localGen = gen;
        Runnable getNodeId = () -> {
            if (localGen.getNodeId(0) == -1) {
                // see FlakeIdGeneratorProxy#NODE_ID_NOT_YET_SET
                errorCounter.incrementAndGet();
            }
        };
        for (int z = 0; z < threadCount; z++) {
            executorService.submit(getNodeId);
        }
    }
    executorService.shutdown();
    executorService.awaitTermination(30, SECONDS);
    assertEquals(0, errorCounter.get());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) ExecutorService(java.util.concurrent.ExecutorService) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 9 with FlakeIdGeneratorConfig

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

the class AbstractDynamicConfigGeneratorTest method testFlakeIdGeneratorConfigGenerator.

// FLAKE ID GENERATOR
@Test
public void testFlakeIdGeneratorConfigGenerator() {
    FlakeIdGeneratorConfig figConfig = new FlakeIdGeneratorConfig("flake-id-gen1").setPrefetchCount(3).setPrefetchValidityMillis(10L).setEpochStart(1000000L).setNodeIdOffset(30L).setBitsSequence(2).setBitsNodeId(3).setAllowedFutureMillis(123L).setStatisticsEnabled(false);
    Config config = new Config().addFlakeIdGeneratorConfig(figConfig);
    Config decConfig = getNewConfigViaGenerator(config);
    FlakeIdGeneratorConfig decReplicatedConfig = decConfig.getFlakeIdGeneratorConfig("flake-id-gen1");
    assertEquals(figConfig, decReplicatedConfig);
}
Also used : FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) 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) Test(org.junit.Test)

Example 10 with FlakeIdGeneratorConfig

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

the class DynamicConfigTest method testFlakeIdGeneratorConfig.

@Test
public void testFlakeIdGeneratorConfig() {
    FlakeIdGeneratorConfig config = new FlakeIdGeneratorConfig(randomName()).setPrefetchCount(123).setPrefetchValidityMillis(456).setEpochStart(789).setNodeIdOffset(890).setBitsNodeId(11).setBitsSequence(22).setStatisticsEnabled(false);
    driver.getConfig().addFlakeIdGeneratorConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

FlakeIdGeneratorConfig (com.hazelcast.config.FlakeIdGeneratorConfig)17 Test (org.junit.Test)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 Config (com.hazelcast.config.Config)5 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)5 ExecutorConfig (com.hazelcast.config.ExecutorConfig)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 ScheduledExecutorConfig (com.hazelcast.config.ScheduledExecutorConfig)5 SetConfig (com.hazelcast.config.SetConfig)5 TopicConfig (com.hazelcast.config.TopicConfig)5 QuickTest (com.hazelcast.test.annotation.QuickTest)5 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)4