use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class LocalMapStatsProvider method createAllLocalMapStats.
public Map<String, LocalMapStats> createAllLocalMapStats() {
Map statsPerMap = new HashMap();
PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
for (int i = 0; i < partitionContainers.length; i++) {
PartitionContainer partitionContainer = partitionContainers[i];
Collection<RecordStore> allRecordStores = partitionContainer.getAllRecordStores();
for (RecordStore recordStore : allRecordStores) {
if (!isStatsCalculationEnabledFor(recordStore)) {
continue;
}
IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId(), false);
if (partition.isLocal()) {
addStatsOfPrimaryReplica(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
} else {
addStatsOfBackupReplica(recordStore, getOrCreateOnDemandStats(statsPerMap, recordStore));
}
}
}
// reuse same HashMap to return calculated LocalMapStats.
for (Object object : statsPerMap.entrySet()) {
Map.Entry entry = (Map.Entry) object;
String mapName = ((String) entry.getKey());
LocalMapStatsImpl existingStats = getLocalMapStatsImpl(mapName);
LocalMapOnDemandCalculatedStats onDemand = ((LocalMapOnDemandCalculatedStats) entry.getValue());
addNearCacheStats(mapName, existingStats, onDemand);
addIndexStats(mapName, existingStats);
addStructureStats(mapName, onDemand);
LocalMapStatsImpl updatedStats = onDemand.updateAndGet(existingStats);
entry.setValue(updatedStats);
}
addStatsOfNoDataIncludedMaps(statsPerMap);
return statsPerMap;
}
use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class LocalMapStatsProvider method updateMapOnDemandStats.
private void updateMapOnDemandStats(String mapName, LocalMapOnDemandCalculatedStats onDemandStats) {
PartitionContainer[] partitionContainers = mapServiceContext.getPartitionContainers();
for (PartitionContainer partitionContainer : partitionContainers) {
IPartition partition = partitionService.getPartition(partitionContainer.getPartitionId());
RecordStore existingRecordStore = partitionContainer.getExistingRecordStore(mapName);
if (existingRecordStore == null) {
continue;
}
if (partition.isLocal()) {
addStatsOfPrimaryReplica(existingRecordStore, onDemandStats);
} else {
addStatsOfBackupReplica(existingRecordStore, onDemandStats);
}
}
addStructureStats(mapName, onDemandStats);
}
use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class MapProxySupport method readBackupDataOrNull.
private Data readBackupDataOrNull(Data key) {
int partitionId = partitionService.getPartitionId(key);
IPartition partition = partitionService.getPartition(partitionId, false);
if (!partition.isOwnerOrBackup(thisAddress)) {
return null;
}
PartitionContainer partitionContainer = mapServiceContext.getPartitionContainer(partitionId);
RecordStore recordStore = partitionContainer.getExistingRecordStore(name);
if (recordStore == null) {
return null;
}
return recordStore.readBackupData(key);
}
use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class QueueService method createLocalQueueStats.
/**
* Returns the local queue statistics for the given name and
* partition ID. If this node is the owner for the partition,
* returned stats contain {@link LocalQueueStats#getOwnedItemCount()},
* otherwise it contains {@link LocalQueueStats#getBackupItemCount()}.
*
* @param name the name of the queue for which the statistics are returned
* @param partitionId the partition ID for which the statistics are returned
* @return the statistics
*/
public LocalQueueStats createLocalQueueStats(String name, int partitionId) {
LocalQueueStatsImpl stats = getLocalQueueStatsImpl(name);
stats.setOwnedItemCount(0);
stats.setBackupItemCount(0);
QueueContainer container = containerMap.get(name);
if (container == null) {
return stats;
}
Address thisAddress = nodeEngine.getClusterService().getThisAddress();
IPartition partition = partitionService.getPartition(partitionId, false);
Address owner = partition.getOwnerOrNull();
if (thisAddress.equals(owner)) {
stats.setOwnedItemCount(container.size());
} else if (owner != null) {
stats.setBackupItemCount(container.backupSize());
}
container.setStats(stats);
return stats;
}
use of com.hazelcast.internal.partition.IPartition in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createMemberState.
private void createMemberState(MemberStateImpl memberState, Collection<StatisticsAwareService> services) {
Node node = instance.node;
final Collection<Client> clients = instance.node.clientEngine.getClients();
final Set<ClientEndPointDTO> serializableClientEndPoints = createHashSet(clients.size());
for (Client client : clients) {
serializableClientEndPoints.add(new ClientEndPointDTO(client));
}
memberState.setClients(serializableClientEndPoints);
memberState.setName(instance.getName());
memberState.setUuid(node.getThisUuid());
if (instance.getConfig().getCPSubsystemConfig().getCPMemberCount() == 0) {
memberState.setCpMemberUuid(null);
} else {
CPMember localCPMember = instance.getCPSubsystem().getLocalCPMember();
memberState.setCpMemberUuid(localCPMember != null ? localCPMember.getUuid() : null);
}
Address thisAddress = node.getThisAddress();
memberState.setAddress(thisAddress.getHost() + ":" + thisAddress.getPort());
memberState.setEndpoints(node.getLocalMember().getAddressMap());
MemberPartitionStateImpl memberPartitionState = (MemberPartitionStateImpl) memberState.getMemberPartitionState();
InternalPartitionService partitionService = node.getPartitionService();
IPartition[] partitions = partitionService.getPartitions();
List<Integer> partitionList = memberPartitionState.getPartitions();
for (IPartition partition : partitions) {
if (partition.isLocal()) {
partitionList.add(partition.getPartitionId());
}
}
memberPartitionState.setMemberStateSafe(memberStateSafe);
memberState.setOperationStats(getOperationStats());
createMemState(memberState, services);
createNodeState(memberState);
createHotRestartState(memberState);
createClusterHotRestartStatus(memberState);
memberState.setClientStats(getClientAttributes(node.getClientEngine().getClientStatistics()));
}
Aggregations