Ejemplo n.º 1
0
  /** Calculates and adds replica partition stats. */
  protected void addReplicaPartitionStats(
      LocalMapOnDemandCalculatedStats onDemandStats,
      String mapName,
      int partitionId,
      InternalPartition partition,
      InternalPartitionService partitionService,
      int backupCount,
      Address thisAddress) {
    long backupEntryCount = 0;
    long backupEntryMemoryCost = 0;

    for (int replica = 1; replica <= backupCount; replica++) {
      Address replicaAddress = getReplicaAddress(replica, partition, partitionService, backupCount);
      if (!isReplicaAvailable(replicaAddress, partitionService, backupCount)) {
        printWarning(partition, replica);
        continue;
      }
      if (isReplicaOnThisNode(replicaAddress, thisAddress)) {
        RecordStore recordStore = getRecordStoreOrNull(mapName, partitionId);
        if (hasRecords(recordStore)) {
          backupEntryMemoryCost += recordStore.getHeapCost();
          backupEntryCount += recordStore.size();
        }
      }
    }
    onDemandStats.incrementHeapCost(backupEntryMemoryCost);
    onDemandStats.incrementBackupEntryMemoryCost(backupEntryMemoryCost);
    onDemandStats.incrementBackupEntryCount(backupEntryCount);
  }