Exemplo n.º 1
0
  /** Flush any buffered output. */
  public synchronized void flush() {
    if (recCount <= 0) {
      if (Debug.messageEnabled()) {
        Debug.message("RemoteHandler.flush(): no records " + "in buffer to send");
      }
      return;
    }
    Vector responses = new Vector();
    if (Debug.messageEnabled()) {
      Debug.message("RemoteHandler.flush(): sending buffered records");
    }

    String thisAMException = null;
    try {
      Iterator sidIter = reqSetMap.keySet().iterator();
      while (sidIter.hasNext()) {
        String currentLoggedBySID = (String) sidIter.next();
        URL logHostURL = getLogHostURL(currentLoggedBySID);
        if (logHostURL == null) {
          Debug.error("RemoteHandler.flush(): logHostURL is null");
          this.recCount = 0;
          reqSetMap = new HashMap();
          return;
        }
        RequestSet reqSet = (RequestSet) reqSetMap.get(currentLoggedBySID);
        responses = PLLClient.send(logHostURL, reqSet);
        Iterator respIter = responses.iterator();
        while (respIter.hasNext()) {
          Response resp = (Response) respIter.next();
          String respContent = resp.getContent();
          if (!respContent.equals("OK")) {
            Debug.error("RemoteHandler.flush(): " + respContent + " on remote machine");
            if (thisAMException == null) {
              thisAMException = "RemoteHandler.flush(): " + respContent + " on remote machine";
            }
          }
        }
      }
    } catch (Exception e) {
      Debug.error("RemoteHandler.flush(): ", e);
    }
    this.recCount = 0;
    reqSetMap = new HashMap();
    if (thisAMException != null) {
      throw new AMLogException(thisAMException);
    }
  }
Exemplo n.º 2
0
    public void run() {
      Vector responses = new Vector();
      if (Debug.messageEnabled()) {
        Debug.message("RemoteHandler.FlushTask.run(): " + "sending buffered records");
      }

      String thisAMException = null;
      try {
        for (String currentLoggedBySID : logReqsMap.keySet()) {
          URL logHostURL = getLogHostURL(currentLoggedBySID);
          if (logHostURL == null) {
            Debug.error("RemoteHandler.FlushTask.run(): " + "logHostURL is null");
            return;
          }
          RequestSet reqSet = (RequestSet) logReqsMap.get(currentLoggedBySID);
          responses = PLLClient.send(logHostURL, reqSet);
          Iterator respIter = responses.iterator();
          while (respIter.hasNext()) {
            Response resp = (Response) respIter.next();
            String respContent = resp.getContent();
            if (!respContent.equals("OK")) {
              Debug.error("RemoteHandler.FlushTask.run(): " + respContent + " on remote machine");
              if (thisAMException == null) {
                thisAMException =
                    "RemoteHandler.FlushTask.run(): " + respContent + " on remote machine";
              }
            }
          }
        }
      } catch (Exception e) {
        Debug.error("RemoteHandler.FlushTask.run(): ", e);
      }

      if (thisAMException != null) {
        throw new AMLogException(thisAMException);
      }
    }