private static Map<String, Object> toMap(final EventBean bean) { final HashMap<String, Object> res = new HashMap<String, Object>(); for (final String attribute : bean.getEventType().getPropertyNames()) { res.put(attribute, bean.get(attribute)); } return res; } }
/** * Given an Event form the Esper core engine, get its timestamp * * @param newEvent Event to extract its timestamp from * @param configTimeAttribute time attribute in the publisher configuration, can be null * @return the event timestamp */ public static Long getEventMillis(EventBean newEvent, String configTimeAttribute) { Long timeInMs = null; if (configTimeAttribute != null) { EventPropertyDescriptor desc = newEvent.getEventType().getPropertyDescriptor(configTimeAttribute); if (desc != null) { Object value = newEvent.get(configTimeAttribute); if (value != null) { timeInMs = Long.parseLong(value.toString()); } } } if (timeInMs == null) { timeInMs = System.currentTimeMillis(); } return timeInMs; } }
/** * Given an Event from the Esper core engine, get its name. * This return null for UUID-based names (select statements), the specified name otherwise (named streams, e.g. insert) * * @param newEvent Event to extract the name from * @return event name if human-readable, null otherwise */ static String getEventName(EventBean newEvent) { String typeName = newEvent.getEventType().getName(); // For automatically generated event names (uuid, most likely from a select statement), the public name // is null. if (newEvent.getEventType() instanceof MapEventType) { typeName = ((MapEventType) newEvent.getEventType()).getMetadata().getPublicName(); } return typeName; }
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { EventType eventType = newEvents[0].getEventType(); String outputStreamName = eventType.getName(); Map<String, Object> statisticEvent = (Map<String, Object>) newEvents[0].getUnderlying(); if(epl.isAlarm()) collector.emit(new Values(outputStreamName, statisticEvent)); DBUtils.insertTriggerRecord(this.epl.getId(), this.epl.getEplName(), statisticEvent); } } }
private static Map<String, Object> toMap(EventBean bean) { HashMap<String, Object> res = new HashMap<String, Object>(); for (String attribute : bean.getEventType().getPropertyNames()) { res.put(attribute, bean.get(attribute)); } return res; } }
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { for (EventBean newEvent : newEvents) { EventTypeDescriptor eventType = getEventType(newEvent.getEventType().getName()); if (eventType == null) { // anonymous event ? eventType = getEventType(null); } if (eventType != null) { collector.emit(eventType.getStreamId(), toTuple(newEvent, eventType.getFields())); } } } }
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { for (EventBean newEvent : newEvents) { for (String attribute : newEvent.getEventType().getPropertyNames()) { add(attribute, new DateTime(DateTimeZone.UTC), newEvent.get(attribute)); } } } }
for (String attribute : newEvent.getEventType().getPropertyNames()) { String fullName = (typeName == null ? attribute : typeName + "." + attribute);
for (String attribute : newEvent.getEventType().getPropertyNames()) { String fullName = (typeName == null ? attribute : typeName + "." + attribute);
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { for (EventBean newEvent : newEvents) { for (String attribute : newEvent.getEventType().getPropertyNames()) { publisher.send(config.getPrefix() + "." + attribute, newEvent.get(attribute)); } } } } }
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { for (EventBean newEvent : newEvents) { for (String attribute : newEvent.getEventType().getPropertyNames()) { Object value = newEvent.get(attribute); if (value != null) { publisher.send(config.getPrefix() + "." + attribute, value); } } } } } }
String[] propertyNames = selected.getEventType().getPropertyNames();
@Override public void update(EventBean[] newEvents, EventBean[] oldEvents) { if (newEvents != null) { for (EventBean newEvent : newEvents) { String typeName = getEventName(newEvent); Long timeInMs = getEventMillis(newEvent, config.getTimeAttribute()); for (String attribute : newEvent.getEventType().getPropertyNames()) { String fullName = (typeName == null ? attribute : typeName + "." + attribute); if (config.isIncluded(fullName)) { Object value = newEvent.get(attribute); if (value != null) { publisher.send(config.getPrefix() + "." + attribute, timeInMs, value); } } } } } } }