public void clearPartitionReplica(int partitionId) {
clearMigrationData(partitionId);
}
public LocalMapStats createStats(String name) {
LocalMultiMapStatsImpl stats = getLocalMultiMapStatsImpl(name);
long ownedEntryCount = 0;
long backupEntryCount = 0;
long dirtyCount = 0;
long ownedEntryMemoryCost = 0;
long backupEntryMemoryCost = 0;
long hits = 0;
long lockedEntryCount = 0;
//TODO @msk memory costs????
ClusterServiceImpl clusterService = (ClusterServiceImpl) nodeEngine.getClusterService();
Address thisAddress = clusterService.getThisAddress();
for (int i = 0; i < nodeEngine.getPartitionService().getPartitionCount(); i++) {
InternalPartition partition = nodeEngine.getPartitionService().getPartition(i);
MultiMapPartitionContainer partitionContainer = getPartitionContainer(i);
MultiMapContainer multiMapContainer = partitionContainer.getCollectionContainer(name);
if (multiMapContainer == null) {
continue;
}
Address owner = partition.getOwner();
if (owner == null) {
//no-op because the owner is not yet set.
} else if (owner.equals(thisAddress)) {
lockedEntryCount += multiMapContainer.getLockedCount();
for (MultiMapWrapper wrapper : multiMapContainer.multiMapWrappers.values()) {
hits += wrapper.getHits();
ownedEntryCount += wrapper.getCollection(false).size();
}
} else {
int backupCount = multiMapContainer.config.getTotalBackupCount();
for (int j = 1; j <= backupCount; j++) {
Address replicaAddress = partition.getReplicaAddress(j);
int memberSize = nodeEngine.getClusterService().getMembers().size();
int tryCount = 3;
// wait if the partition table is not updated yet
while (memberSize > backupCount && replicaAddress == null && tryCount-- > 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw ExceptionUtil.rethrow(e);
}
replicaAddress = partition.getReplicaAddress(j);
}
if (replicaAddress != null && replicaAddress.equals(thisAddress)) {
for (MultiMapWrapper wrapper : multiMapContainer.multiMapWrappers.values()) {
backupEntryCount += wrapper.getCollection(false).size();
}
}
}
}
}
stats.setOwnedEntryCount(ownedEntryCount);
stats.setBackupEntryCount(backupEntryCount);
stats.setHits(hits);
stats.setLockedEntryCount(lockedEntryCount);
return stats;
}