Search in sources :

Example 1 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapService method createReplicatedMapStats.

public LocalReplicatedMapStatsImpl createReplicatedMapStats(String name) {
    LocalReplicatedMapStatsImpl stats = getLocalMapStatsImpl(name);
    long hits = 0;
    long count = 0;
    long memoryUsage = 0;
    boolean isBinary = (getReplicatedMapConfig(name).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(Math.max(stats.getLastAccessTime(), record.getLastAccessTime()));
            stats.setLastUpdateTime(Math.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);
    return stats;
}
Also used : LocalReplicatedMapStatsImpl(com.hazelcast.monitor.impl.LocalReplicatedMapStatsImpl) ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 2 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapSplitBrainHandlerService method prepareMergeRunnable.

@Override
public Runnable prepareMergeRunnable() {
    HashMap<String, Collection<ReplicatedRecord>> recordMap = new HashMap<String, Collection<ReplicatedRecord>>();
    Address thisAddress = service.getNodeEngine().getThisAddress();
    List<Integer> partitions = nodeEngine.getPartitionService().getMemberPartitions(thisAddress);
    for (Integer partition : partitions) {
        PartitionContainer partitionContainer = service.getPartitionContainer(partition);
        ConcurrentMap<String, ReplicatedRecordStore> stores = partitionContainer.getStores();
        for (ReplicatedRecordStore store : stores.values()) {
            String name = store.getName();
            Collection<ReplicatedRecord> records = recordMap.get(name);
            if (records == null) {
                records = new ArrayList<ReplicatedRecord>();
            }
            Iterator<ReplicatedRecord> iterator = store.recordIterator();
            while (iterator.hasNext()) {
                ReplicatedRecord record = iterator.next();
                records.add(record);
            }
            recordMap.put(name, records);
            store.reset();
        }
    }
    return new Merger(recordMap);
}
Also used : ReplicatedRecord(com.hazelcast.replicatedmap.impl.record.ReplicatedRecord) Address(com.hazelcast.nio.Address) HashMap(java.util.HashMap) ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) Collection(java.util.Collection)

Example 3 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapProxy method initialize.

@Override
public void initialize() {
    service.initializeListeners(name);
    if (nodeEngine.getClusterService().getSize() == 1) {
        return;
    }
    fireMapDataLoadingTasks();
    if (!config.isAsyncFillup()) {
        for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
            ReplicatedRecordStore store = service.getReplicatedRecordStore(name, false, i);
            while (!store.isLoaded()) {
                if ((retryCount++) % RETRY_INTERVAL_COUNT == 0) {
                    requestDataForPartition(i);
                }
                sleep();
            }
        }
    }
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)

Example 4 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore 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)

Example 5 with ReplicatedRecordStore

use of com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore in project hazelcast by hazelcast.

the class ReplicatedMapService method getAllReplicatedRecordStores.

public Collection<ReplicatedRecordStore> getAllReplicatedRecordStores(String name) {
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    ArrayList<ReplicatedRecordStore> stores = new ArrayList<>(partitionCount);
    for (int i = 0; i < partitionCount; i++) {
        PartitionContainer partitionContainer = partitionContainers[i];
        if (partitionContainer == null) {
            continue;
        }
        ReplicatedRecordStore recordStore = partitionContainer.getRecordStore(name);
        if (recordStore == null) {
            continue;
        }
        stores.add(recordStore);
    }
    return stores;
}
Also used : ReplicatedRecordStore(com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore) ArrayList(java.util.ArrayList)

Aggregations

ReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.ReplicatedRecordStore)38 ReplicatedMapService (com.hazelcast.replicatedmap.impl.ReplicatedMapService)19 ReplicatedRecord (com.hazelcast.replicatedmap.impl.record.ReplicatedRecord)7 ArrayList (java.util.ArrayList)7 Data (com.hazelcast.internal.serialization.Data)5 ILogger (com.hazelcast.logging.ILogger)4 Nonnull (javax.annotation.Nonnull)4 Address (com.hazelcast.cluster.Address)3 SerializationService (com.hazelcast.internal.serialization.SerializationService)3 ReplicatedMapProxy (com.hazelcast.replicatedmap.impl.ReplicatedMapProxy)3 Map (java.util.Map)3 ReplicatedMapConfig (com.hazelcast.config.ReplicatedMapConfig)2 LocalReplicatedMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalReplicatedMapStatsImpl)2 DataCollection (com.hazelcast.map.impl.DataCollection)2 PartitionContainer (com.hazelcast.replicatedmap.impl.PartitionContainer)2 AbstractBaseReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractBaseReplicatedRecordStore)2 AbstractReplicatedRecordStore (com.hazelcast.replicatedmap.impl.record.AbstractReplicatedRecordStore)2 RecordMigrationInfo (com.hazelcast.replicatedmap.impl.record.RecordMigrationInfo)2 BitSet (java.util.BitSet)2 Member (com.hazelcast.cluster.Member)1