コード例 #1
0
ファイル: CounterContext.java プロジェクト: daidong/GraphTrek
  /**
   * Human-readable String from context.
   *
   * @param context counter context.
   * @return a human-readable String of the context.
   */
  public String toString(ByteBuffer context) {
    ContextState state = ContextState.wrap(context);
    StringBuilder sb = new StringBuilder();
    sb.append("[");

    while (state.hasRemaining()) {
      if (state.getElementIndex() > 0) sb.append(",");
      sb.append("{");
      sb.append(state.getCounterId()).append(", ");
      sb.append(state.getClock()).append(", ");
      sb.append(state.getCount());
      sb.append("}");
      if (state.isGlobal()) sb.append("$");
      else if (state.isLocal()) sb.append("*");
      state.moveToNext();
    }

    sb.append("]");
    return sb.toString();
  }
コード例 #2
0
 private String repairedNodes() {
   StringBuilder sb = new StringBuilder();
   sb.append(FBUtilities.getBroadcastAddress());
   for (InetAddress ep : endpoints) sb.append(", ").append(ep);
   return sb.toString();
 }