Esempio n. 1
0
  private void completeStart() {
    if (log.isInfoEnabled()) log.info("complete start");
    // okay, all streams are ready so send the start message
    promise.addResponse("start");

    // completely flush the cache now that every stream is started...
    for (Cache cache2 : cache.values()) {
      for (Object obj : cache2.getResponses()) {
        promise.addResponse(obj);
      }
    }
    cache.clear();
    cache = null;
  }
Esempio n. 2
0
 public void onThrowable(String url2, Throwable ex) {
   // don't log, it is logged elsewhere
   if (log.isInfoEnabled()) log.info("on throwable");
   Problem p = new Problem();
   p.setException(ex);
   p.setUrl(url2);
   promise.addResponse(p);
 }
Esempio n. 3
0
 private void sendFailure(String url) {
   Cache cache2 = cache.get(url);
   String body = cache2.getFailureBody();
   HttpResponseStatus status = cache2.getStatus();
   HttpBadResponse resp = new HttpBadResponse(url, status, body);
   promise.addResponse(resp);
   cache.clear();
 }
Esempio n. 4
0
 public void incomingJsonRow(JsonRow r) {
   synchronized (promise) {
     if (isFailed()) return;
     else if (numUrlsWaitingOnStatus > 0) {
       Cache cache2 = cache.get(r.getUrl());
       cache2.addResponse(r);
       return;
     }
     promise.addResponse(r);
   }
 }
Esempio n. 5
0
  public void complete(String url) {
    synchronized (promise) {
      if (log.isInfoEnabled())
        log.info(
            "complete.  failure url=" + failureUrl + " numUrlsWaiting=" + numUrlsWaitingOnStatus);
      if (isFailed()) {
        if (failureUrl.equals(url)) sendFailure(url);
        return;
      }

      Complete c = new Complete();
      c.setUrl(url);
      if (numUrlsWaitingOnStatus > 0) {
        if (log.isInfoEnabled()) log.info("cache the complete response");
        Cache cache2 = cache.get(url);
        cache2.addResponse(c);
        return;
      }

      if (log.isInfoEnabled()) log.info("add completion to promise");
      promise.addResponse(c);
    }
  }