Package stream

Examples of stream.Data


  }

  @Override
  public Data process(Data input) {
    final String mapEventTypeName = (String) input.get("@stream");
    final Data event = input.createCopy();
    event.remove("@stream");
    event.remove("@stream:id");

    // If this event defines a start time, then adjust the current time if
    // necessary and replace the string value with the long value.
    final String startTimeKey = _startTimestampMap.get(mapEventTypeName);
    if (startTimeKey != null) {
      final long dataStartTime = Long.parseLong(input.get(startTimeKey)
          .toString());
      event.put(startTimeKey, dataStartTime);
      if (dataStartTime > _currentTime) {
        _currentTime = dataStartTime;
        final CurrentTimeEvent timeEvent = new CurrentTimeEvent(
            _currentTime);
        _log.debug("Sending time event new time: {}", _currentTime);
        _epRuntime.sendEvent(timeEvent);
      }
    }

    // If this event defines an end time, then replace the string value with
    // the long value.
    final String endTimeKey = _endTimestampMap.get(mapEventTypeName);
    if (endTimeKey != null) {
      final long dataEndTime = Long.parseLong(input.get(endTimeKey)
          .toString());
      event.put(endTimeKey, dataEndTime);
    }

    _epRuntime.sendEvent(event, mapEventTypeName);
    return null;
  }
View Full Code Here


   *            the values of an Esper event.
   * @throws Exception
   */
  public void update(Object... values) throws Exception {
    synchronized (_sink) {
      Data item = DataFactory.create();
      for (int i = 0; i < values.length; ++i) {
        item.put(_keys[i], (Serializable) values[i]);
      }
      item.put("@stream", _sink.getId());
      _log.debug("Updating subscriber {}, item {}", values, item);
      _sink.write(item);
    }
  }
View Full Code Here

   * @throws Exception
   */
  public void update(java.util.Map<String, Serializable> values)
      throws Exception {
    synchronized (_sink) {
      Data item = DataFactory.create();
      item.put("@stream", _sink.getId());
      for (Entry<String, Serializable> entry : values.entrySet()) {
        item.put(entry.getKey().replace('`', ' ').trim(),
            entry.getValue());
      }
      _log.debug("Updating subscriber {}, item {}", values, item);
      _sink.write(item);
    }
View Full Code Here

    try {

      handler.reset();
      stream.parse(inputStream);

      Data data = handler.getItem();
      for (Processor p : processors) {
        data = p.process(data);
      }
      log.debug("Data parsed is:\n{}", data);
      data.put(IronBeeAuditEvent.SECTION_BOUNDARY_KEY, handler.boundary);
      return new IronBeeAuditEvent(data);

    } catch (Exception e) {
      throw new IOException(e.getMessage());
    }
View Full Code Here

    AuditEventMessage[] msgs = evt.getEventMessages();
    for (int i = 0; i < msgs.length; i++) {
      AuditEventMessage msg = msgs[i];

      Data item = DataFactory.create();
      item.put("version", "1.0");
      item.put("host", evt.get(ModSecurity.REQUEST_HEADERS + ":Host"));
      item.put("short_message", msg.getRuleMsg());
      item.put("full_message", msg.getRuleMsg());
      item.put("timestamp", timestamp.doubleValue() / 1000.0d);
      item.put("level", msg.getSeverity());
      item.put("facility",
          "ModSecurity:" + evt.get(AuditEvent.SENSOR_NAME));
      item.put("file", msg.getFile());
      item.put("line", msg.getLine());

      item.put("_event:txId", txId);
      String ruleId = msg.getRuleId();
      if (ruleId != null) {
        item.put(prefix + "id", msg.getRuleId());
      }

      List<String> tags = msg.getRuleTags();
      if (tags != null && !tags.isEmpty()) {
        item.put(prefix + "tags", join(msg.getRuleTags()));
      }

      log.debug("Emitting item {} to {}", item, address);
      emit(item);
    }
View Full Code Here

      String json;
      if (keys != null) {

        Set<String> selected = KeyFilter.select(input, keys);
        Data item = DataFactory.create();
        for (String k : selected) {
          item.put(k, input.get(k));
        }
        log.debug("Sending item {}", item);
        json = JSONObject.toJSONString(item);
      } else {
        json = JSONObject.toJSONString(input);
View Full Code Here

    AuditEvent evt = reader.readNext();
    if (evt == null)
      return null;

    Data item = DataFactory.create();
    item.put("event", evt);
    return item;
    // return new AuditData(evt);
  }
View Full Code Here

   * @return null, since this implementation works asynchronously.
   */
  @Override
  public Data process(Data input) {
    final String mapEventTypeName = (String) input.get("@stream");
    final Data event = input.createCopy();
    event.remove("@stream");
    event.remove("@stream:id");

    // If this event defines a start time, then adjust the current time if
    // necessary and replace the string value with the long value.
    final String startTimeKey = _startTimestampMap.get(mapEventTypeName);
    if (startTimeKey != null) {
      final long dataStartTime = ((Number) input.get(startTimeKey))
          .longValue();
      event.put(startTimeKey, dataStartTime);
      if (dataStartTime > _currentTime) {
        TimerEvent timeEvent = null;
        // If first timestamp to set, then advance to data time.
        if (_currentTime != Long.MIN_VALUE) {
          _currentTime = dataStartTime;
          timeEvent = new CurrentTimeEvent(_currentTime
              - _timeTolerance);
          _log.debug("Sending time event new time: {}", _currentTime);
          _log.debug("Data items per time interval: {}",
              _itemsCounter);
          _itemsCounter = 0;
        }
        // Advance to new data time.
        else {
          _currentTime = dataStartTime;
          timeEvent = new CurrentTimeEvent(_currentTime
              - _timeTolerance);
          _log.debug("Setting start time: {}", _currentTime);
          _log.debug("Data items per time interval: {}",
              _itemsCounter);
          _itemsCounter = 0;
        }
        _epRuntime.sendEvent(timeEvent);
      }
      // Data items that fall outside the time limit are ignored.
      else if (dataStartTime < _currentTime - _timeTolerance) {
        if (_log.isDebugEnabled()) {
          _log.debug("Time inconsistency! {} Tolerance: {}",
              (_currentTime - dataStartTime), _timeTolerance);
        }
        return null;
      }
    }

    ++_itemsCounter;

    // If this event defines an end time, then replace the string value with
    // the long value.
    final String endTimeKey = _endTimestampMap.get(mapEventTypeName);
    if (endTimeKey != null) {
      final long dataEndTime = Long.parseLong(input.get(endTimeKey)
          .toString());
      event.put(endTimeKey, dataEndTime);
    }

    _epRuntime.sendEvent(event, mapEventTypeName);
    return null;
  }
View Full Code Here

   *            the values of an Esper event.
   * @throws Exception
   */
  public void update(Object... values) throws Exception {
    synchronized (_sinksList) {
      Data item = DataFactory.create();
      for (int i = 0; i < values.length; ++i) {
        item.put(_keys[i], (Serializable) values[i]);
      }
      item.put("@stream", _sinksList[0].getId());
      _log.debug("Updating subscriber {}, item {}", values, item);
      _sinksList[0].write(item);
      for (int s = 1; s < _sinksList.length; ++s) {
        Data result = stream.data.DataFactory.copy(item);
        result.put("@stream", _sinksList[s].getId());
        _log.debug("Updating subscriber {}, item {}", values, result);
        _sinksList[s].write(result);
      }
    }
  }
View Full Code Here

   * @throws Exception
   */
  public void update(java.util.Map<String, Serializable> values)
      throws Exception {
    synchronized (_sinksList) {
      Data item = DataFactory.create();
      for (Entry<String, Serializable> entry : values.entrySet()) {
        item.put(entry.getKey().replace('`', ' ').trim(),
            entry.getValue());
      }
      item.put("@stream", _sinksList[0].getId());
      _log.debug("Updating subscriber {}, item {}", values, item);
      _sinksList[0].write(item);

     
      for (int s = 1; s < _sinksList.length; ++s) {
        Data result = stream.data.DataFactory.copy(item);
        result.put("@stream", _sinksList[s].getId());
        _log.debug("Updating subscriber {}, item {}", values, result);
        _sinksList[s].write(result);
      }
    }
  }
View Full Code Here

TOP

Related Classes of stream.Data

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.