Exemple #1
0
  // produce the contents of the repair log.
  public List<Iv2RepairLogResponseMessage> contents(long requestId, boolean forMPI) {
    List<Item> items = new LinkedList<Item>();
    // All cases include the log of MP transactions
    items.addAll(m_logMP);
    // SP repair requests also want the SP transactions
    if (!forMPI) {
      items.addAll(m_logSP);
    }

    // Contents need to be sorted in increasing spHandle order
    Collections.sort(items, m_handleComparator);

    int ofTotal = items.size() + 1;
    if (tmLog.isDebugEnabled()) {
      tmLog.debug("Responding with " + ofTotal + " repair log parts.");
    }
    List<Iv2RepairLogResponseMessage> responses = new LinkedList<Iv2RepairLogResponseMessage>();

    // this constructor sets its sequence no to 0 as ack
    // messages are first in the sequence
    Iv2RepairLogResponseMessage hheader =
        new Iv2RepairLogResponseMessage(
            requestId,
            ofTotal,
            m_lastSpHandle,
            m_lastMpHandle,
            TheHashinator.getCurrentVersionedConfigCooked());
    responses.add(hheader);

    int seq = responses.size(); // = 1, as the first sequence

    Iterator<Item> itemator = items.iterator();
    while (itemator.hasNext()) {
      Item item = itemator.next();
      Iv2RepairLogResponseMessage response =
          new Iv2RepairLogResponseMessage(
              requestId, seq++, ofTotal, item.getHandle(), item.getTxnId(), item.getMessage());
      responses.add(response);
    }
    return responses;
  }