protected static void markTrackerWithException(
     RequestTracker<?> tracker, Address dest, Throwable e, Object uuid) {
   log.tracef("Marking tracker to have exception");
   tracker.throwable = e;
   if (dest == null || tracker.lastResult(dest, null)) {
     if (uuid != null) {
       log.tracef("Tracker %s completed with exception, waking sleepers!", uuid);
     } else {
       log.trace("Tracker completed due to outside cause, waking sleepers! ");
     }
     tracker.completionLock.lock();
     try {
       tracker.completionCondition.signalAll();
     } finally {
       tracker.completionLock.unlock();
     }
   }
 }
  @Override
  public <R1> boolean receiveResponse(
      Object id, Address origin, boolean complete, Set<Integer> missingSegments, R1 response) {
    log.tracef(
        "Received response from %s with a completed response %s for id %s with %s suspected segments.",
        origin, complete, id, missingSegments);
    RequestTracker tracker = currentlyRunning.get(id);

    if (tracker != null) {
      boolean notify = false;
      // TODO: need to reorganize the tracker to reduce synchronization so it only contains missing
      // segments
      // and completing the tracker
      synchronized (tracker) {
        if (tracker.awaitingResponse.containsKey(origin)) {
          if (!missingSegments.isEmpty()) {
            tracker.missingSegments(missingSegments);
          }
          if (complete) {
            notify = tracker.lastResult(origin, response);
          } else {
            tracker.intermediateResults(origin, response);
          }
        }
      }
      if (notify) {
        log.tracef("Marking %s as completed!", id);
        tracker.completionLock.lock();
        try {
          currentlyRunning.remove(id);
          tracker.completionCondition.signalAll();
        } finally {
          tracker.completionLock.unlock();
        }
      }
      return !notify;
    } else {
      log.tracef(
          "Ignoring response as we already received a completed response for %s from %s",
          id, origin);
      return false;
    }
  }