コード例 #1
0
ファイル: RemoteHandler.java プロジェクト: aldaris/opensso
 private void startTimeBufferingThread() {
   String period = manager.getProperty(LogConstants.BUFFER_TIME);
   long interval;
   if ((period != null) || (period.length() != 0)) {
     interval = Long.parseLong(period);
   } else {
     interval = LogConstants.BUFFER_TIME_DEFAULT;
   }
   interval *= 1000;
   if (bufferTask == null) {
     bufferTask = new TimeBufferingTask(interval);
     try {
       SystemTimer.getTimer()
           .schedule(
               bufferTask, new Date(((System.currentTimeMillis() + interval) / 1000) * 1000));
     } catch (IllegalArgumentException e) {
       Debug.error(logName + ":RemoteHandler:BuffTimeArg: " + e.getMessage());
     } catch (IllegalStateException e) {
       if (Debug.messageEnabled()) {
         Debug.message(logName + ":RemoteHandler:BuffTimeState: " + e.getMessage());
       }
     }
     if (Debug.messageEnabled()) {
       Debug.message("RemoteHandler: Time Buffering Thread Started");
     }
   }
 }
コード例 #2
0
ファイル: RemoteHandler.java プロジェクト: aldaris/opensso
  /** 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);
    }
  }
コード例 #3
0
ファイル: RemoteHandler.java プロジェクト: aldaris/opensso
  private URL getLogHostURL(String loggedBySID) {
    SessionID sid = new SessionID(loggedBySID);

    String sessionProtocol = sid.getSessionServerProtocol();
    String sessionHost = sid.getSessionServer();
    String sessionPort = sid.getSessionServerPort();
    String sessionURI = sid.getSessionServerURI();

    //
    //  if remote logging service and protocol, host, and port
    //  are null, get them from the logging service url in the
    //  AMConfig.properties file.
    //
    if ((!manager.isLocal)
        && ((sessionProtocol == null)
            || (sessionProtocol.length() <= 0)
            || (sessionHost == null)
            || (sessionHost.length() <= 0))) {
      if (Debug.messageEnabled()) {
        Debug.message("RemoteHandler.getLogHostURL(): remote serv = " + logServURL);
      }
      return (logServURL);
    }

    if (Debug.messageEnabled()) {
      Debug.message(
          "RemoteHandler.getLogHostURL(): "
              + " sessionProtocol: "
              + sessionProtocol
              + " sessionHost: "
              + sessionHost
              + " sessionPort: "
              + sessionPort
              + " sessionURI: "
              + sessionURI);
    }
    URL loggingURL = null;
    try {
      loggingURL =
          WebtopNaming.getServiceURL(
              LogConstants.LOGGING_SERVICE, sessionProtocol, sessionHost, sessionPort, sessionURI);

      if (Debug.messageEnabled()) {
        Debug.message(
            "RemoteHandler.getLogHostURL(): WebtopNaming logging" + "service URL: " + loggingURL);
      }
    } catch (URLNotFoundException unfe) {
      Debug.error("RemoteHandler.getLogHostURL(): URLNotFoundException: ", unfe);
      return null;
    }
    return loggingURL;
  }
コード例 #4
0
ファイル: RemoteHandler.java プロジェクト: aldaris/opensso
    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);
      }
    }
コード例 #5
0
ファイル: LogMessageID.java プロジェクト: aldaris/opensso
  static LogMessageID createInstance(String prefix, Node node) {
    LogMessageID messageID = null;

    if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
      String nodeName = node.getNodeName();

      if (nodeName.equals(LogMessageConstants.XML_LOG_MESSAGE_TAG_NAME)) {
        String name =
            ((Element) node).getAttribute(LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_NAME);
        String id = ((Element) node).getAttribute(LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_ID);
        String logLevel = ((Element) node).getAttribute(LogMessageConstants.XML_ATTRNAME_LOG_LEVEL);
        String description =
            ((Element) node).getAttribute(LogMessageConstants.XML_ATTRNAME_LOG_MESSAGE_DESCRIPTION);

        if ((name.length() > 0) && (id.length() > 0)) {
          try {
            messageID =
                new LogMessageID(
                    (Level) mapLogLevel.get(logLevel),
                    prefix,
                    Integer.parseInt(id),
                    name,
                    description,
                    getArrayCount(node, LogMessageConstants.XML_DATAINFO_TAG_NAME));
          } catch (NumberFormatException e) {
            Debug.error("LogMessageID.createInstance", e);
          }
        } else {
          Debug.error(
              "LogMessageID.createInstance: "
                  + "unable to create log message ID because its name is missing");
        }
      }
    }

    return messageID;
  }