Пример #1
0
 public void push(final Long userId, final Object data) {
   Queue<DeferredResult<Object>> queue = userIdToDeferredResultMap.get(userId);
   if (queue == null) {
     return;
   }
   for (DeferredResult<Object> deferredResult : queue) {
     if (!deferredResult.isSetOrExpired()) {
       try {
         deferredResult.setResult(data);
       } catch (Exception e) {
         queue.remove(deferredResult);
       }
     }
   }
 }
  @Override
  public void run() {
    long requests = concurrentRequests.getAndDecrement();

    if (deferredResult.isSetOrExpired()) {
      logger.warn(
          "{}: Processing of non-blocking request #{} already expired", requests, requestId);
    } else {
      logger.info("Retrieving result");
      NetworkServiceInstantiateReply reply = ServiceSelectionMsgTable.getInstance().get(requestId);
      if (reply != null) {
        logger.info("Retrieving reply from orchestrator with ns id {}", requestId);
      }

      boolean deferredStatus = deferredResult.setResult(reply);
      logger.debug(
          "{}: Processing of non-blocking request #{} done, deferredStatus = {}",
          requests,
          requestId,
          deferredStatus);
    }
  }