Search in sources :

Example 11 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class ClientReplicatedMapTest method clear_empties_internal_ttl_schedulers.

@Test
public void clear_empties_internal_ttl_schedulers() {
    String mapName = "test";
    HazelcastInstance node = factory.newHazelcastInstance(config);
    HazelcastInstance client = factory.newHazelcastClient();
    ReplicatedMap map = client.getReplicatedMap(mapName);
    for (int i = 0; i < 1000; i++) {
        map.put(i, i, 100, TimeUnit.DAYS);
    }
    map.clear();
    assertAllTtlSchedulersEmpty(node.getReplicatedMap(mapName));
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 12 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class BatchStageTest method mapUsingReplicatedMap.

@Test
public void mapUsingReplicatedMap() {
    // Given
    List<Integer> input = sequence(itemCount);
    String prefix = "value-";
    String replicatedMapName = randomMapName();
    ReplicatedMap<Integer, String> replicatedMap = member.getReplicatedMap(replicatedMapName);
    for (int i : input) {
        replicatedMap.put(i, prefix + i);
    }
    for (HazelcastInstance hz : allHazelcastInstances()) {
        assertSizeEventually(itemCount, hz.getReplicatedMap(replicatedMapName));
    }
    // When
    BatchStage<Entry<Integer, String>> stage = batchStageFromList(input).mapUsingReplicatedMap(replicatedMap, FunctionEx.identity(), Util::entry);
    // Then
    stage.writeTo(sink);
    execute();
    Function<Entry<Integer, String>, String> formatFn = e -> String.format("(%04d, %s)", e.getKey(), e.getValue());
    assertEquals(streamToString(input.stream().map(i -> entry(i, prefix + i)), formatFn), streamToString(sinkStreamOfEntry(), formatFn));
}
Also used : ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) AggregateOperations.counting(com.hazelcast.jet.aggregate.AggregateOperations.counting) Arrays(java.util.Arrays) ServiceFactories.sharedService(com.hazelcast.jet.pipeline.ServiceFactories.sharedService) QuickTest(com.hazelcast.test.annotation.QuickTest) QuadFunction(com.hazelcast.jet.function.QuadFunction) Collections.singletonList(java.util.Collections.singletonList) BiFunctionEx(com.hazelcast.function.BiFunctionEx) Arrays.asList(java.util.Arrays.asList) DAG(com.hazelcast.jet.core.DAG) PredicateEx(com.hazelcast.function.PredicateEx) FunctionEx(com.hazelcast.function.FunctionEx) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) Collections.emptyList(java.util.Collections.emptyList) Tag(com.hazelcast.jet.datamodel.Tag) Set(java.util.Set) Category(org.junit.experimental.categories.Category) Executors(java.util.concurrent.Executors) Objects(java.util.Objects) Tuple3.tuple3(com.hazelcast.jet.datamodel.Tuple3.tuple3) List(java.util.List) Stream(java.util.stream.Stream) ItemsByTag(com.hazelcast.jet.datamodel.ItemsByTag) Entry(java.util.Map.Entry) Function.identity(java.util.function.Function.identity) IntStream(java.util.stream.IntStream) Processors(com.hazelcast.jet.core.processor.Processors) CompletableFuture(java.util.concurrent.CompletableFuture) ServiceFactories.nonSharedService(com.hazelcast.jet.pipeline.ServiceFactories.nonSharedService) Function(java.util.function.Function) JoinClause.joinMapEntries(com.hazelcast.jet.pipeline.JoinClause.joinMapEntries) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AssertionSinks.assertAnyOrder(com.hazelcast.jet.pipeline.test.AssertionSinks.assertAnyOrder) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) AssertionSinks.assertOrdered(com.hazelcast.jet.pipeline.test.AssertionSinks.assertOrdered) Util.entry(com.hazelcast.jet.Util.entry) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ProcessorSupplier(com.hazelcast.jet.core.ProcessorSupplier) Tuple2(com.hazelcast.jet.datamodel.Tuple2) ExecutorService(java.util.concurrent.ExecutorService) Job(com.hazelcast.jet.Job) Tuple3(com.hazelcast.jet.datamodel.Tuple3) HazelcastInstance(com.hazelcast.core.HazelcastInstance) LongStream(java.util.stream.LongStream) AbstractStage.transformOf(com.hazelcast.jet.impl.pipeline.AbstractStage.transformOf) ProcessorMetaSupplier(com.hazelcast.jet.core.ProcessorMetaSupplier) Traversers.traverseItems(com.hazelcast.jet.Traversers.traverseItems) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) TimeUnit(java.util.concurrent.TimeUnit) Vertex(com.hazelcast.jet.core.Vertex) TestSources(com.hazelcast.jet.pipeline.test.TestSources) Collectors.toList(java.util.stream.Collectors.toList) Tuple2.tuple2(com.hazelcast.jet.datamodel.Tuple2.tuple2) LongAccumulator(com.hazelcast.jet.accumulator.LongAccumulator) Functions.wholeItem(com.hazelcast.function.Functions.wholeItem) Processors.noopP(com.hazelcast.jet.core.processor.Processors.noopP) TriFunction(com.hazelcast.jet.function.TriFunction) Collections(java.util.Collections) Util(com.hazelcast.jet.Util) Tuple4.tuple4(com.hazelcast.jet.datamodel.Tuple4.tuple4) Assert.assertEquals(org.junit.Assert.assertEquals) IMap(com.hazelcast.map.IMap) Entry(java.util.Map.Entry) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Util(com.hazelcast.jet.Util) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 13 with ReplicatedMap

use of com.hazelcast.replicatedmap.ReplicatedMap in project hazelcast by hazelcast.

the class DynamicConfigTest method testSameReplicatedMapConfig_canBeAddedTwice.

@Test
public void testSameReplicatedMapConfig_canBeAddedTwice() {
    ReplicatedMapConfig config = new ReplicatedMapConfig(name);
    driver.getConfig().addReplicatedMapConfig(config);
    ReplicatedMap map = driver.getReplicatedMap(name);
    driver.getConfig().addReplicatedMapConfig(config);
    assertConfigurationsEqualOnAllMembers(config);
}
Also used : ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ReplicatedMap(com.hazelcast.replicatedmap.ReplicatedMap) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ReplicatedMap (com.hazelcast.replicatedmap.ReplicatedMap)13 Test (org.junit.Test)13 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)12 QuickTest (com.hazelcast.test.annotation.QuickTest)12 HazelcastInstance (com.hazelcast.core.HazelcastInstance)10 Map (java.util.Map)6 HashMap (java.util.HashMap)5 AssertTask (com.hazelcast.test.AssertTask)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)1 Hz3Enrichment.mapUsingIMap (com.hazelcast.connector.Hz3Enrichment.mapUsingIMap)1 AsyncMap (com.hazelcast.connector.map.AsyncMap)1 Hz3MapAdapter (com.hazelcast.connector.map.Hz3MapAdapter)1 BiFunctionEx (com.hazelcast.function.BiFunctionEx)1 FunctionEx (com.hazelcast.function.FunctionEx)1 Functions.wholeItem (com.hazelcast.function.Functions.wholeItem)1 PredicateEx (com.hazelcast.function.PredicateEx)1 Job (com.hazelcast.jet.Job)1 Traversers.traverseItems (com.hazelcast.jet.Traversers.traverseItems)1 Util (com.hazelcast.jet.Util)1