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);
}
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)));
}
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());
}
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);
}
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);
}
Aggregations