Ejemplo n.º 1
0
  public static String versionsToString(long[] versions, ClusterSnapshot clusterSnapshot) {
    if (versions == null || versions.length == 0) {
      return "[]";
    } else if (clusterSnapshot != null && versions.length != clusterSnapshot.size()) {
      return "[N/A]";
    }

    if (clusterSnapshot == null) {
      if (versions.length == 1) {
        return "[" + versions[0] + "]";
      } else {
        StringBuilder stringBuilder = new StringBuilder("[");
        stringBuilder.append(versions[0]);
        for (int i = 1; i < versions.length; ++i) {
          stringBuilder.append(",").append(versions[i]);
        }
        return stringBuilder.append("]").toString();
      }
    }
    if (versions.length == 1) {
      return "[" + clusterSnapshot.get(0) + "=" + versions[0] + "]";
    } else {
      StringBuilder stringBuilder = new StringBuilder("[");
      stringBuilder.append(clusterSnapshot.get(0)).append("=").append(versions[0]);

      for (int i = 1; i < versions.length; ++i) {
        stringBuilder.append(",").append(clusterSnapshot.get(i)).append("=").append(versions[i]);
      }
      return stringBuilder.append("]").toString();
    }
  }
 /**
  * reset the state (before each round)
  *
  * @param clusterSnapshot the current cluster snapshot
  */
 public final synchronized void resetState(ClusterSnapshot clusterSnapshot) {
   this.clusterSnapshot = clusterSnapshot;
   accessesByPrimaryOwner = new Accesses[clusterSnapshot.size()];
   for (int i = 0; i < accessesByPrimaryOwner.length; ++i) {
     accessesByPrimaryOwner[i] = new Accesses();
   }
   hasAccessesCalculated = false;
 }