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