Search in sources :

Example 16 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class ReplicatedMapRemoveEntryListenerMessageTask method deRegisterListener.

@Override
protected boolean deRegisterListener() {
    ReplicatedMapService service = getService(ReplicatedMapService.SERVICE_NAME);
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    return eventPublishingService.removeEventListener(parameters.name, parameters.registrationId);
}
Also used : ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Example 17 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class TimedMemberStateFactory method createMemState.

private void createMemState(TimedMemberState timedMemberState, MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
    int count = 0;
    Config config = instance.getConfig();
    Set<String> longInstanceNames = new HashSet<String>(maxVisibleInstanceCount);
    for (StatisticsAwareService service : services) {
        if (count < maxVisibleInstanceCount) {
            if (service instanceof MapService) {
                count = handleMap(memberState, count, config, ((MapService) service).getStats(), longInstanceNames);
            } else if (service instanceof MultiMapService) {
                count = handleMultimap(memberState, count, config, ((MultiMapService) service).getStats(), longInstanceNames);
            } else if (service instanceof QueueService) {
                count = handleQueue(memberState, count, config, ((QueueService) service).getStats(), longInstanceNames);
            } else if (service instanceof TopicService) {
                count = handleTopic(memberState, count, config, ((TopicService) service).getStats(), longInstanceNames);
            } else if (service instanceof DistributedExecutorService) {
                count = handleExecutorService(memberState, count, config, ((DistributedExecutorService) service).getStats(), longInstanceNames);
            } else if (service instanceof ReplicatedMapService) {
                count = handleReplicatedMap(memberState, count, config, ((ReplicatedMapService) service).getStats(), longInstanceNames);
            }
        }
    }
    WanReplicationService wanReplicationService = instance.node.nodeEngine.getWanReplicationService();
    Map<String, LocalWanStats> wanStats = wanReplicationService.getStats();
    if (wanStats != null) {
        count = handleWan(memberState, count, wanStats, longInstanceNames);
    }
    if (cacheServiceEnabled) {
        ICacheService cacheService = getCacheService();
        for (CacheConfig cacheConfig : cacheService.getCacheConfigs()) {
            if (cacheConfig.isStatisticsEnabled() && count < maxVisibleInstanceCount) {
                CacheStatistics statistics = cacheService.getStatistics(cacheConfig.getNameWithPrefix());
                //is filled.git
                if (statistics != null) {
                    count = handleCache(memberState, count, cacheConfig, statistics, longInstanceNames);
                }
            }
        }
    }
    timedMemberState.setInstanceNames(longInstanceNames);
}
Also used : StatisticsAwareService(com.hazelcast.spi.StatisticsAwareService) CacheConfig(com.hazelcast.config.CacheConfig) Config(com.hazelcast.config.Config) GroupConfig(com.hazelcast.config.GroupConfig) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) QueueService(com.hazelcast.collection.impl.queue.QueueService) WanReplicationService(com.hazelcast.wan.WanReplicationService) CacheStatistics(com.hazelcast.cache.CacheStatistics) TopicService(com.hazelcast.topic.impl.TopicService) ICacheService(com.hazelcast.cache.impl.ICacheService) LocalWanStats(com.hazelcast.monitor.LocalWanStats) DistributedExecutorService(com.hazelcast.executor.impl.DistributedExecutorService) MultiMapService(com.hazelcast.multimap.impl.MultiMapService) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) MapService(com.hazelcast.map.impl.MapService) CacheConfig(com.hazelcast.config.CacheConfig) HashSet(java.util.HashSet)

Example 18 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class KeySetOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    Collection<ReplicatedRecordStore> stores = service.getAllReplicatedRecordStores(name);
    List keys = new ArrayList();
    for (ReplicatedRecordStore store : stores) {
        keys.addAll(store.keySet(false));
    }
    ArrayList<Data> dataKeys = new ArrayList<Data>(keys.size());
    SerializationService serializationService = getNodeEngine().getSerializationService();
    for (Object key : keys) {
        dataKeys.add(serializationService.toData(key));
    }
    response = new ReplicatedMapKeys(dataKeys);
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ArrayList(java.util.ArrayList) ReplicatedMapKeys(com.hazelcast.replicatedmap.impl.client.ReplicatedMapKeys) SerializationService(com.hazelcast.spi.serialization.SerializationService) List(java.util.List) ArrayList(java.util.ArrayList) Data(com.hazelcast.nio.serialization.Data)

Example 19 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class ReplicateUpdateOperation method run.

@Override
public void run() throws Exception {
    ReplicatedMapService service = getService();
    ReplicatedRecordStore store = service.getReplicatedRecordStore(name, true, getPartitionId());
    long currentVersion = store.getVersion();
    long updateVersion = response.getVersion();
    if (currentVersion >= updateVersion) {
        ILogger logger = getLogger();
        if (logger.isFineEnabled()) {
            logger.fine("Rejecting stale update received for replicated map: " + name + "  partitionId=" + getPartitionId() + " current version: " + currentVersion + " update version: " + updateVersion);
        }
        return;
    }
    Object key = store.marshall(dataKey);
    Object value = store.marshall(dataValue);
    if (isRemove) {
        store.removeWithVersion(key, updateVersion);
    } else {
        store.putWithVersion(key, value, ttl, TimeUnit.MILLISECONDS, false, updateVersion);
    }
    publishEvent();
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) ILogger(com.hazelcast.logging.ILogger)

Example 20 with ReplicatedMapService

use of com.hazelcast.replicatedmap.impl.ReplicatedMapService in project hazelcast by hazelcast.

the class ReplicateUpdateOperation method publishEvent.

private void publishEvent() {
    ReplicatedMapService service = getService();
    ReplicatedMapEventPublishingService eventPublishingService = service.getEventPublishingService();
    Data dataOldValue = getNodeEngine().toData(response.getResponse());
    if (isRemove) {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, null, name, origin);
    } else {
        eventPublishingService.fireEntryListenerEvent(dataKey, dataOldValue, dataValue, name, origin);
    }
}
Also used : ReplicatedMapService(com.hazelcast.replicatedmap.impl.ReplicatedMapService) Data(com.hazelcast.nio.serialization.Data) ReplicatedMapEventPublishingService(com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)

Aggregations

ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)32 ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)17 ILogger (com.hazelcast.logging.ILogger)6 Data (com.hazelcast.nio.serialization.Data)6 ReplicatedMapEventPublishingService (com.hazelcast.replicatedmap.impl.ReplicatedMapEventPublishingService)6 HazelcastInstance (com.hazelcast.core.HazelcastInstance)5 Test (org.junit.Test)5 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)4 ParallelTest (com.hazelcast.test.annotation.ParallelTest)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Config (com.hazelcast.config.Config)3 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)3 SerializationService (com.hazelcast.spi.serialization.SerializationService)3 ArrayList (java.util.ArrayList)3 QueueService (com.hazelcast.collection.impl.queue.QueueService)2 DistributedExecutorService (com.hazelcast.executor.impl.DistributedExecutorService)2 MapService (com.hazelcast.map.impl.MapService)2 MultiMapService (com.hazelcast.multimap.impl.MultiMapService)2 Address (com.hazelcast.nio.Address)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2