use of com.hazelcast.internal.monitor.impl.LocalMultiMapStatsImpl in project hazelcast by hazelcast.
the class MultiMapService method createStats.
LocalMultiMapStats createStats(String name) {
LocalMultiMapStatsImpl stats = getLocalMultiMapStatsImpl(name);
long ownedEntryCount = 0;
long backupEntryCount = 0;
long hits = 0;
long lockedEntryCount = 0;
long lastAccessTime = 0;
long lastUpdateTime = 0;
ClusterService clusterService = nodeEngine.getClusterService();
MultiMapConfig config = nodeEngine.getConfig().findMultiMapConfig(name);
int backupCount = config.getTotalBackupCount();
Address thisAddress = clusterService.getThisAddress();
for (int partitionId = 0; partitionId < nodeEngine.getPartitionService().getPartitionCount(); partitionId++) {
IPartition partition = nodeEngine.getPartitionService().getPartition(partitionId, false);
MultiMapPartitionContainer partitionContainer = getPartitionContainer(partitionId);
MultiMapContainer multiMapContainer = partitionContainer.getMultiMapContainer(name, false);
if (multiMapContainer == null) {
continue;
}
Address owner = partition.getOwnerOrNull();
if (owner != null) {
if (owner.equals(thisAddress)) {
lockedEntryCount += multiMapContainer.getLockedCount();
lastAccessTime = max(lastAccessTime, multiMapContainer.getLastAccessTime());
lastUpdateTime = max(lastUpdateTime, multiMapContainer.getLastUpdateTime());
for (MultiMapValue multiMapValue : multiMapContainer.getMultiMapValues().values()) {
hits += multiMapValue.getHits();
ownedEntryCount += multiMapValue.getCollection(false).size();
}
} else {
for (int j = 1; j <= backupCount; j++) {
// wait if the partition table is not updated yet
Address replicaAddress = getReplicaAddress(partition, backupCount, j);
if (replicaAddress != null && replicaAddress.equals(thisAddress)) {
for (MultiMapValue multiMapValue : multiMapContainer.getMultiMapValues().values()) {
backupEntryCount += multiMapValue.getCollection(false).size();
}
}
}
}
}
}
stats.setOwnedEntryCount(ownedEntryCount);
stats.setBackupEntryCount(backupEntryCount);
stats.setHits(hits);
stats.setLockedEntryCount(lockedEntryCount);
stats.setBackupCount(backupCount);
stats.setLastAccessTime(lastAccessTime);
stats.setLastUpdateTime(lastUpdateTime);
return stats;
}
use of com.hazelcast.internal.monitor.impl.LocalMultiMapStatsImpl in project hazelcast by hazelcast.
the class MultiMapProxySupport method incrementOperationStats.
private void incrementOperationStats(long startTimeNanos, String name, Operation operation) {
LocalMultiMapStatsImpl localMultiMapStatsImpl = getService().getLocalMultiMapStatsImpl(name);
final long durationNanos = Timer.nanosElapsed(startTimeNanos);
if (operation instanceof PutOperation) {
localMultiMapStatsImpl.incrementPutLatencyNanos(durationNanos);
} else if (operation instanceof RemoveOperation || operation instanceof RemoveAllOperation || operation instanceof DeleteOperation) {
localMultiMapStatsImpl.incrementRemoveLatencyNanos(durationNanos);
} else if (operation instanceof GetAllOperation) {
localMultiMapStatsImpl.incrementGetLatencyNanos(durationNanos);
}
}
Aggregations