コード例 #1
0
  // ------------------------------
  private void initialize(
      String user, String hashed_password, String userIp, HttpServletResponse res)
      throws Exception {

    sessionId_m =
        HtCommandProcessor.instance()
            .get_HtSecurityProxy()
            .remote_startUserSessionWithHashedPassword(user, hashed_password, userIp);

    if (sessionId_m == null) {
      throw new HtException(getContext(), "initialize", "Invalid user or password");
    }

    for (int i = 0; i < eventTypes_m.size(); i++) {
      RtGlobalEventManager.instance()
          .resolveListenerThread(RtGlobalEventManager.instance().MAIN_THREAD)
          .subscribeForEvent(eventTypes_m.get(i), 30, this);
    }

    // push event
    XmlEvent syncevent = new XmlEvent();
    syncevent.setEventType(XmlEvent.ET_SynchronizationEvent);
    RtGlobalEventManager.instance().pushCommonEvent(syncevent);

    // here we need to wait until the pending event will come through database layer to make sure
    // that we can select all data
    HtCommandProcessor.instance()
        .get_HtDatabaseProxy()
        .remote_waitDatabaseManagerWritePendingEvents(
            syncevent.getSequenceNumber(), WAIT_DB_PEND_EVENTS_SEC);
  }
コード例 #2
0
  private byte[] eventToBytes(XmlEvent event) throws Exception {
    XmlParameter xmlparameter = new XmlParameter();
    XmlEvent.convertEventToXmlParameter(event, xmlparameter);

    StringBuilder out = new StringBuilder();
    handler_m.serializeParameter(xmlparameter, out);

    return out.toString().getBytes("UTF-8");
  }
コード例 #3
0
  // ---------------------------
  // helpers
  private void sendSingleEvent(
      HttpServletResponse res, XmlEvent event, final ServletOutputStream ostrm) throws Exception {

    // need to filter out
    int evnetType = event.getEventType();
    if (evnetType == XmlEvent.ET_CommonLog) {
      CommonLogParameters clp =
          (CommonLogParameters) eventFilterParameters_m.get(XmlEvent.ET_CommonLog);

      CommonLog clog = event.getAsLog();

      // filter

      if (clp.end_date_hist > 0 && clog.getLogDate() > clp.end_date_hist) {
        return;
      }

      if (clp.begin_date_hist > 0 && clog.getLogDate() < clp.begin_date_hist) {
        return;
      }

      if (clog.getLogLevel() > clp.level) {
        return;
      }

      if (clp.threadFilter != null && clp.threadFilter.length() > 0) {
        Matcher mtch = clp.p_threadFilter.matcher(String.valueOf(clog.getLogThread()));
        if (!mtch.find()) {
          return;
        }
      }

      //
      if (clp.contextFilter != null && clp.contextFilter.length() > 0) {
        Matcher mtch = clp.p_contextFilter.matcher(String.valueOf(clog.getContext()));
        if (!mtch.find()) {
          return;
        }
      }

      if (clp.contentSmallFilter != null && clp.contentSmallFilter.length() > 0) {
        Matcher mtch = clp.p_contentSmallFilter.matcher(String.valueOf(clog.getContent()));
        if (!mtch.find()) {
          return;
        }
      }

      if (debugstream_m != null) {
        writeDebugEntry("Sending log event: " + clog.toSmallDebugString());
      }

    } else if (evnetType == XmlEvent.ET_DrawableObject) {
      DrawableObjectParameters clp =
          (DrawableObjectParameters) eventFilterParameters_m.get(XmlEvent.ET_DrawableObject);

      HtDrawableObject dobj = event.getAsDrawableObject();

      if (clp.end_date_hist > 0 && dobj.getTime() > clp.end_date_hist) {
        return;
      }

      if (clp.begin_date_hist > 0 && dobj.getTime() < clp.begin_date_hist) {
        return;
      }

      // filter out by type
      if (clp.allowed_type.size() > 0 && !clp.allowed_type.contains(dobj.getType())) {
        return;
      }

      if (clp.allowed_symbols_m != null) {
        if (!clp.allowed_symbols_m.contains(dobj.getSymbol())) {
          return;
        }
      }

      if (dobj.getType() == HtDrawableObject.DO_TEXT) {

        if (clp.shortTextFilter != null && clp.shortTextFilter.length() > 0) {
          Matcher mtch = clp.p_shortTextFilter.matcher(dobj.getAsText().shortText_m.toString());
          if (!mtch.find()) {
            return;
          }
        }

        if (clp.textFilter != null && clp.textFilter.length() > 0) {
          Matcher mtch = clp.p_textFilter.matcher(dobj.getAsText().text_m.toString());
          if (!mtch.find()) {
            return;
          }
        }
      }

    } else if (evnetType == XmlEvent.ET_RtProviderTicker) {
      RtDataParameters clp =
          (RtDataParameters) eventFilterParameters_m.get(XmlEvent.ET_RtProviderTicker);

      if (clp.allowed_symbols_m != null) {
        if (!clp.allowed_symbols_m.contains(event.getAsRtData().getSymbol())) {
          return;
        }
      }
    }

    HtXmlEventExchangePacket.Packet packet = new HtXmlEventExchangePacket.Packet();
    HtXmlEventExchangePacket.serializeSingleEvent(handler_m, event, packet);

    HtXmlEventExchangePacket.writePacketToStream(packet, ostrm, ll_m);
  }