Search in sources :

Example 1 with LocalMultiMapStatsImpl

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;
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) Address(com.hazelcast.cluster.Address) MultiMapConfig(com.hazelcast.config.MultiMapConfig) ConfigValidator.checkMultiMapConfig(com.hazelcast.internal.config.ConfigValidator.checkMultiMapConfig) LocalMultiMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMultiMapStatsImpl) IPartition(com.hazelcast.internal.partition.IPartition) MigrationEndpoint(com.hazelcast.internal.partition.MigrationEndpoint)

Example 2 with LocalMultiMapStatsImpl

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);
    }
}
Also used : DeleteOperation(com.hazelcast.multimap.impl.operations.DeleteOperation) RemoveAllOperation(com.hazelcast.multimap.impl.operations.RemoveAllOperation) PutOperation(com.hazelcast.multimap.impl.operations.PutOperation) GetAllOperation(com.hazelcast.multimap.impl.operations.GetAllOperation) RemoveOperation(com.hazelcast.multimap.impl.operations.RemoveOperation) LocalMultiMapStatsImpl(com.hazelcast.internal.monitor.impl.LocalMultiMapStatsImpl)

Aggregations

LocalMultiMapStatsImpl (com.hazelcast.internal.monitor.impl.LocalMultiMapStatsImpl)2 Address (com.hazelcast.cluster.Address)1 MultiMapConfig (com.hazelcast.config.MultiMapConfig)1 ClusterService (com.hazelcast.internal.cluster.ClusterService)1 ConfigValidator.checkMultiMapConfig (com.hazelcast.internal.config.ConfigValidator.checkMultiMapConfig)1 IPartition (com.hazelcast.internal.partition.IPartition)1 MigrationEndpoint (com.hazelcast.internal.partition.MigrationEndpoint)1 DeleteOperation (com.hazelcast.multimap.impl.operations.DeleteOperation)1 GetAllOperation (com.hazelcast.multimap.impl.operations.GetAllOperation)1 PutOperation (com.hazelcast.multimap.impl.operations.PutOperation)1 RemoveAllOperation (com.hazelcast.multimap.impl.operations.RemoveAllOperation)1 RemoveOperation (com.hazelcast.multimap.impl.operations.RemoveOperation)1