* @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;
}