Search in sources :

Example 11 with ReplicatedMapConfig

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

the class ReplicatedMapAbstractTest method buildConfig.

protected Config buildConfig(InMemoryFormat inMemoryFormat) {
    Config config = new Config();
    ReplicatedMapConfig replicatedMapConfig = config.getReplicatedMapConfig("default");
    replicatedMapConfig.setInMemoryFormat(inMemoryFormat);
    return config;
}
Also used : Config(com.hazelcast.config.Config) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig)

Example 12 with ReplicatedMapConfig

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

the class DynamicConfigXmlGenerator method replicatedMapXmlGenerator.

public static void replicatedMapXmlGenerator(ConfigXmlGenerator.XmlGenerator gen, Config config) {
    for (ReplicatedMapConfig r : config.getReplicatedMapConfigs().values()) {
        MergePolicyConfig mergePolicyConfig = r.getMergePolicyConfig();
        gen.open("replicatedmap", "name", r.getName()).node("in-memory-format", r.getInMemoryFormat()).node("async-fillup", r.isAsyncFillup()).node("statistics-enabled", r.isStatisticsEnabled()).node("split-brain-protection-ref", r.getSplitBrainProtectionName()).node("merge-policy", mergePolicyConfig.getPolicy(), "batch-size", mergePolicyConfig.getBatchSize());
        if (!r.getListenerConfigs().isEmpty()) {
            gen.open("entry-listeners");
            for (ListenerConfig lc : r.getListenerConfigs()) {
                gen.node("entry-listener", classNameOrImplClass(lc.getClassName(), lc.getImplementation()), "include-value", lc.isIncludeValue(), "local", lc.isLocal());
            }
            gen.close();
        }
        gen.close();
    }
}
Also used : MergePolicyConfig(com.hazelcast.config.MergePolicyConfig) ItemListenerConfig(com.hazelcast.config.ItemListenerConfig) CacheSimpleEntryListenerConfig(com.hazelcast.config.CacheSimpleEntryListenerConfig) ListenerConfig(com.hazelcast.config.ListenerConfig) EntryListenerConfig(com.hazelcast.config.EntryListenerConfig) CachePartitionLostListenerConfig(com.hazelcast.config.CachePartitionLostListenerConfig) MapPartitionLostListenerConfig(com.hazelcast.config.MapPartitionLostListenerConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig)

Example 13 with ReplicatedMapConfig

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

the class ClusterWideConfigurationService method registerConfigLocally.

/**
 * Register a dynamic configuration in a local member. When a dynamic configuration with the same name already
 * exists then this call has no effect.
 *
 * @param newConfig       Configuration to register.
 * @param configCheckMode behaviour when a config is detected
 * @throws UnsupportedOperationException when given configuration type is not supported
 * @throws InvalidConfigurationException when conflict is detected and configCheckMode is on THROW_EXCEPTION
 */
@SuppressWarnings("checkstyle:methodlength")
public void registerConfigLocally(IdentifiedDataSerializable newConfig, ConfigCheckMode configCheckMode) {
    IdentifiedDataSerializable currentConfig;
    if (newConfig instanceof MultiMapConfig) {
        MultiMapConfig multiMapConfig = (MultiMapConfig) newConfig;
        currentConfig = multiMapConfigs.putIfAbsent(multiMapConfig.getName(), multiMapConfig);
    } else if (newConfig instanceof MapConfig) {
        MapConfig newMapConfig = (MapConfig) newConfig;
        currentConfig = mapConfigs.putIfAbsent(newMapConfig.getName(), newMapConfig);
        if (currentConfig == null) {
            listener.onConfigRegistered(newMapConfig);
        }
    } else if (newConfig instanceof CardinalityEstimatorConfig) {
        CardinalityEstimatorConfig cardinalityEstimatorConfig = (CardinalityEstimatorConfig) newConfig;
        currentConfig = cardinalityEstimatorConfigs.putIfAbsent(cardinalityEstimatorConfig.getName(), cardinalityEstimatorConfig);
    } else if (newConfig instanceof RingbufferConfig) {
        RingbufferConfig ringbufferConfig = (RingbufferConfig) newConfig;
        currentConfig = ringbufferConfigs.putIfAbsent(ringbufferConfig.getName(), ringbufferConfig);
    } else if (newConfig instanceof ListConfig) {
        ListConfig listConfig = (ListConfig) newConfig;
        currentConfig = listConfigs.putIfAbsent(listConfig.getName(), listConfig);
    } else if (newConfig instanceof SetConfig) {
        SetConfig setConfig = (SetConfig) newConfig;
        currentConfig = setConfigs.putIfAbsent(setConfig.getName(), setConfig);
    } else if (newConfig instanceof ReplicatedMapConfig) {
        ReplicatedMapConfig replicatedMapConfig = (ReplicatedMapConfig) newConfig;
        currentConfig = replicatedMapConfigs.putIfAbsent(replicatedMapConfig.getName(), replicatedMapConfig);
    } else if (newConfig instanceof TopicConfig) {
        TopicConfig topicConfig = (TopicConfig) newConfig;
        currentConfig = topicConfigs.putIfAbsent(topicConfig.getName(), topicConfig);
    } else if (newConfig instanceof ExecutorConfig) {
        ExecutorConfig executorConfig = (ExecutorConfig) newConfig;
        currentConfig = executorConfigs.putIfAbsent(executorConfig.getName(), executorConfig);
    } else if (newConfig instanceof DurableExecutorConfig) {
        DurableExecutorConfig durableExecutorConfig = (DurableExecutorConfig) newConfig;
        currentConfig = durableExecutorConfigs.putIfAbsent(durableExecutorConfig.getName(), durableExecutorConfig);
    } else if (newConfig instanceof ScheduledExecutorConfig) {
        ScheduledExecutorConfig scheduledExecutorConfig = (ScheduledExecutorConfig) newConfig;
        currentConfig = scheduledExecutorConfigs.putIfAbsent(scheduledExecutorConfig.getName(), scheduledExecutorConfig);
    } else if (newConfig instanceof QueueConfig) {
        QueueConfig queueConfig = (QueueConfig) newConfig;
        currentConfig = queueConfigs.putIfAbsent(queueConfig.getName(), queueConfig);
    } else if (newConfig instanceof ReliableTopicConfig) {
        ReliableTopicConfig reliableTopicConfig = (ReliableTopicConfig) newConfig;
        currentConfig = reliableTopicConfigs.putIfAbsent(reliableTopicConfig.getName(), reliableTopicConfig);
    } else if (newConfig instanceof CacheSimpleConfig) {
        CacheSimpleConfig cacheSimpleConfig = (CacheSimpleConfig) newConfig;
        currentConfig = cacheSimpleConfigs.putIfAbsent(cacheSimpleConfig.getName(), cacheSimpleConfig);
        if (currentConfig == null) {
            listener.onConfigRegistered(cacheSimpleConfig);
        }
    } else if (newConfig instanceof FlakeIdGeneratorConfig) {
        FlakeIdGeneratorConfig config = (FlakeIdGeneratorConfig) newConfig;
        currentConfig = flakeIdGeneratorConfigs.putIfAbsent(config.getName(), config);
    } else if (newConfig instanceof PNCounterConfig) {
        PNCounterConfig config = (PNCounterConfig) newConfig;
        currentConfig = pnCounterConfigs.putIfAbsent(config.getName(), config);
    } else {
        throw new UnsupportedOperationException("Unsupported config type: " + newConfig);
    }
    checkCurrentConfigNullOrEqual(configCheckMode, currentConfig, newConfig);
    persist(newConfig);
}
Also used : IdentifiedDataSerializable(com.hazelcast.nio.serialization.IdentifiedDataSerializable) CacheSimpleConfig(com.hazelcast.config.CacheSimpleConfig) QueueConfig(com.hazelcast.config.QueueConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) ReliableTopicConfig(com.hazelcast.config.ReliableTopicConfig) TopicConfig(com.hazelcast.config.TopicConfig) PNCounterConfig(com.hazelcast.config.PNCounterConfig) ExecutorConfig(com.hazelcast.config.ExecutorConfig) ScheduledExecutorConfig(com.hazelcast.config.ScheduledExecutorConfig) DurableExecutorConfig(com.hazelcast.config.DurableExecutorConfig) FlakeIdGeneratorConfig(com.hazelcast.config.FlakeIdGeneratorConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) RingbufferConfig(com.hazelcast.config.RingbufferConfig) SetConfig(com.hazelcast.config.SetConfig) MapConfig(com.hazelcast.config.MapConfig) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) ListConfig(com.hazelcast.config.ListConfig) CardinalityEstimatorConfig(com.hazelcast.config.CardinalityEstimatorConfig)

Example 14 with ReplicatedMapConfig

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

the class MemberDomConfigProcessor method handleReplicatedMap.

protected void handleReplicatedMap(Node node) {
    String name = getTextContent(getNamedItemNode(node, "name"));
    final ReplicatedMapConfig replicatedMapConfig = ConfigUtils.getByNameOrNew(config.getReplicatedMapConfigs(), name, ReplicatedMapConfig.class);
    handleReplicatedMapNode(node, replicatedMapConfig);
}
Also used : ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig)

Example 15 with ReplicatedMapConfig

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

the class LocalReplicatedMapStatsProvider method getLocalReplicatedMapStats.

LocalReplicatedMapStats getLocalReplicatedMapStats(String name) {
    ReplicatedMapConfig replicatedMapConfig = getReplicatedMapConfig(name);
    final LocalReplicatedMapStats result;
    if (!replicatedMapConfig.isStatisticsEnabled()) {
        result = EMPTY_LOCAL_MAP_STATS;
    } else {
        LocalReplicatedMapStatsImpl stats = getLocalReplicatedMapStatsImpl(name);
        long hits = 0;
        long count = 0;
        long memoryUsage = 0;
        boolean isBinary = (replicatedMapConfig.getInMemoryFormat() == InMemoryFormat.BINARY);
        for (PartitionContainer container : partitionContainers) {
            ReplicatedRecordStore store = container.getRecordStore(name);
            if (store == null) {
                continue;
            }
            Iterator<ReplicatedRecord> iterator = store.recordIterator();
            while (iterator.hasNext()) {
                ReplicatedRecord record = iterator.next();
                stats.setLastAccessTime(max(stats.getLastAccessTime(), record.getLastAccessTime()));
                stats.setLastUpdateTime(max(stats.getLastUpdateTime(), record.getUpdateTime()));
                hits += record.getHits();
                if (isBinary) {
                    memoryUsage += ((HeapData) record.getValueInternal()).getHeapCost();
                }
                count++;
            }
        }
        stats.setOwnedEntryCount(count);
        stats.setHits(hits);
        stats.setOwnedEntryMemoryCost(memoryUsage);
        result = stats;
    }
    return result;
}
Also used : LocalReplicatedMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl) ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapConfig(com.hazelcast.config.ReplicatedMapConfig) EmptyLocalReplicatedMapStats(com.hazelcast.internal.monitor.impl.EmptyLocalReplicatedMapStats) LocalReplicatedMapStats(com.hazelcast.replicatedmap.LocalReplicatedMapStats)

Aggregations

ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)36 Test (org.junit.Test)16 QuickTest (com.hazelcast.test.annotation.QuickTest)15 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)13 Config (com.hazelcast.config.Config)9 EntryListenerConfig (com.hazelcast.config.EntryListenerConfig)8 MergePolicyConfig (com.hazelcast.config.MergePolicyConfig)7 ListenerConfig (com.hazelcast.config.ListenerConfig)6 CacheSimpleConfig (com.hazelcast.config.CacheSimpleConfig)5 CacheSimpleEntryListenerConfig (com.hazelcast.config.CacheSimpleEntryListenerConfig)5 CardinalityEstimatorConfig (com.hazelcast.config.CardinalityEstimatorConfig)5 DurableExecutorConfig (com.hazelcast.config.DurableExecutorConfig)5 ExecutorConfig (com.hazelcast.config.ExecutorConfig)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