org.wso2.siddhi.core.event.Event.getTimestamp()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中org.wso2.siddhi.core.event.Event.getTimestamp()方法的一些代码示例,展示了Event.getTimestamp()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getTimestamp()方法的具体详情如下:
包路径:org.wso2.siddhi.core.event.Event
类名称:Event
方法名:getTimestamp

Event.getTimestamp介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public class EventComparator implements Comparator<Event>, Serializable {

  private static final long serialVersionUID = 1L;

  @Override
  public int compare(Event o1, Event o2) {
    return (o1.getTimestamp() < o2.getTimestamp() ? -1
        : (o1.getTimestamp() == o2.getTimestamp() ? 0 : 1));
  }

}

代码示例来源:origin: stackoverflow.com

public class MyActivity {

 private int times = 0;
 private long lastTimestamp;

 private void onTouchEvent(Event evt) {
  if (times > 0) {
   long delay = evt.getTimestamp() - lastTimestamp;
   // do something with the delay
  }
  lastTimestamp = evt.getTimestamp();
  times++;
 }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core

/**
 * Method that would publish events if this is the Active Node.
 *
 * @param event the event to be published.
 * @param sinkHandlerCallback callback that would publish events.
 */
@Override
public void handle(Event event, SinkHandlerCallback sinkHandlerCallback) {
  if (isActiveNode) {
    lastPublishedEventTimestamp = event.getTimestamp();
    sinkHandlerCallback.mapAndSend(event);
  }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core

/**
 * Method that would publish events if this is the Active Node.
 *
 * @param events the event array to be published.
 * @param sinkHandlerCallback callback that would publish events.
 */
@Override
public void handle(Event[] events, SinkHandlerCallback sinkHandlerCallback) {
  if (isActiveNode) {
    lastPublishedEventTimestamp = events[events.length - 1].getTimestamp();
    sinkHandlerCallback.mapAndSend(events);
  }
}

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core

public static List<Event> getWso2Events(org.wso2.carbon.databridge.commons.StreamDefinition streamDefinition,
                    int metaAttrCount, int correlationAttrCount, int payloadAttrCount,
                    org.wso2.siddhi.core.event.Event[] events) {
  List<Event> eventList = new ArrayList<>();
  for (org.wso2.siddhi.core.event.Event event : events) {
    eventList.add(getWso2Event(streamDefinition, metaAttrCount, correlationAttrCount, payloadAttrCount,
        event.getTimestamp(), event.getData()));
  }
  return eventList;
}

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.common

@Override
  public void receive(Event[] events) {
    for (Event event : events) {
      Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1);
      eventData[event.getData().length] = event.getTimestamp();
      outputCollector.emit(triggerId, Arrays.asList(eventData));
      if (log.isDebugEnabled()) {
        log.debug(logPrefix + "Trigger Event Emitted :" + Arrays.deepToString(eventData));
      }
    }
  }
});

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core

@Override
public void sendEvent(Event event) throws InterruptedException {
  inputHandler.send(event.getTimestamp(), event.getData());
}

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.common

@Override
  public void receive(Event[] events) {
    for (Event event : events) {
      Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1);
      eventData[event.getData().length] = event.getTimestamp();
      collector.emit(outputSiddhiDefinition.getId(), Arrays.asList(eventData));
      if (log.isDebugEnabled()) {
        log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() +
            ":" + Arrays.deepToString(eventData) + "@" + event.getTimestamp());
      }
      emitThroughputProbe.update();
    }
  }
});

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core

/**
 * Method that would process events if this is the Active Node.
 *
 * @param event        the event being sent to processing.
 * @param transportSyncProperties transport sync properties which used to sync passive source state
 * @param inputHandler callback that would send events for processing.
 */
@Override
public void sendEvent(Event event, String[] transportSyncProperties, InputHandler inputHandler)
    throws InterruptedException {
  if (isActiveNode) {
    lastProcessedEventTimestamp = event.getTimestamp();
    if (passiveNodeAdded) {
      sendEventsToPassiveNode(event, transportSyncProperties);
    }
    inputHandler.send(event);
  }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core

/**
 * Method that would process events if this is the Active Node.
 * If Passive Node, events will be buffered during the state syncing state.
 *
 * @param events       the event array being sent to processing.
 * @param transportSyncProperties transport sync properties which used to sync passive source state
 * @param inputHandler callback that would send events for processing.
 */
@Override
public void sendEvent(Event[] events, String[] transportSyncProperties, InputHandler inputHandler)
    throws InterruptedException {
  if (isActiveNode) {
    lastProcessedEventTimestamp = events[events.length - 1].getTimestamp();
    if (passiveNodeAdded) {
      sendEventsToPassiveNode(events, transportSyncProperties);
    }
    inputHandler.send(events);
  }
}

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.common

@Override
  public void receive(Event[] events) {
    for (Event event : events) {
      Object[] eventData = Arrays.copyOf(event.getData(), event.getData().length + 1);
      eventData[event.getData().length] = event.getTimestamp();
      collector.emit(outputSiddhiDefinition.getId(), Arrays.asList(eventData));
      if (log.isDebugEnabled()) {
        if (++eventCount % 10000 == 0) {
          double timeSpentInSecs = (System.currentTimeMillis() - batchStartTime) / 1000.0D;
          double throughput = 10000 / timeSpentInSecs;
          log.debug(logPrefix + "Processed 10000 events in " + timeSpentInSecs + " " +
              "seconds, throughput : " + throughput + " events/sec. Stream : " +
              outputSiddhiDefinition.getId());
          eventCount = 0;
          batchStartTime = System.currentTimeMillis();
        }
        log.debug(logPrefix + "Emitted Event:" + outputSiddhiDefinition.getId() +
            ":" + Arrays.deepToString(eventData) + "@" + event.getTimestamp());
      }
    }
  }
});

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core

@Override
public void sendEvent(Event event) throws InterruptedException {
  asyncEventPublisher.sendEvent(event.getData(),event.getTimestamp(), this.siddhiStreamDefinition.getId());
}

代码示例来源:origin: apache/bahir-flink

@Override
public void receive(Event[] events) {
  for (Event event : events) {
    if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
      collectedRecords.add(new StreamRecord<R>((R) toMap(event), event.getTimestamp()));
    } else if (typeInfo.isTupleType()) {
      Tuple tuple = this.toTuple(event);
      collectedRecords.add(new StreamRecord<R>((R) tuple, event.getTimestamp()));
    } else if (typeInfo instanceof PojoTypeInfo) {
      R obj;
      try {
        obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
      } catch (IllegalArgumentException ex) {
        LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
        throw ex;
      }
      collectedRecords.add(new StreamRecord<R>(obj, event.getTimestamp()));
    } else {
      throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
    }
  }
}

代码示例来源:origin: haoch/flink-siddhi

@Override
public void receive(Event[] events) {
  for (Event event : events) {
    if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
      collectedRecords.add(new StreamRecord<R>((R) toMap(event), event.getTimestamp()));
    } else if (typeInfo.isTupleType()) {
      Tuple tuple = this.toTuple(event);
      collectedRecords.add(new StreamRecord<R>((R) tuple, event.getTimestamp()));
    } else if (typeInfo instanceof PojoTypeInfo) {
      R obj;
      try {
        obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
      } catch (IllegalArgumentException ex) {
        LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
        throw ex;
      }
      collectedRecords.add(new StreamRecord<R>(obj, event.getTimestamp()));
    } else {
      throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
    }
  }
}

代码示例来源:origin: org.wso2.carbon.analytics/org.wso2.carbon.stream.processor.core

+ BinaryMessageConverterUtil.getSize(queuedEvent.getEvent().getTimestamp()) + getEventSize(event) +
    4;
messageBuffer.putLong(event.getTimestamp());

代码示例来源:origin: apache/bahir-flink

@Override
public void receive(Event[] events) {
  StreamRecord<R> reusableRecord = new StreamRecord<>(null, 0L);
  for (Event event : events) {
    if (typeInfo == null || Map.class.isAssignableFrom(typeInfo.getTypeClass())) {
      reusableRecord.replace(toMap(event), event.getTimestamp());
      output.collect(reusableRecord);
    } else if (typeInfo.isTupleType()) {
      Tuple tuple = this.toTuple(event);
      reusableRecord.replace(tuple, event.getTimestamp());
      output.collect(reusableRecord);
    } else if (typeInfo instanceof PojoTypeInfo) {
      R obj;
      try {
        obj = objectMapper.convertValue(toMap(event), typeInfo.getTypeClass());
      } catch (IllegalArgumentException ex) {
        LOGGER.error("Failed to map event: " + event + " into type: " + typeInfo, ex);
        throw ex;
      }
      reusableRecord.replace(obj, event.getTimestamp());
      output.collect(reusableRecord);
    } else {
      throw new IllegalArgumentException("Unable to format " + event + " as type " + typeInfo);
    }
  }
}

代码示例来源:origin: haoch/flink-siddhi

|| (Map.class.isAssignableFrom(typeInfo.getTypeClass())
  || GenericRecord.class.isAssignableFrom(typeInfo.getTypeClass()))) {
  reusableRecord.replace(Tuple2.of(outputStreamId, new GenericRecord(buildMap(event))), event.getTimestamp());
  output.collect(reusableRecord);
} else if (Row.class.isAssignableFrom(typeInfo.getTypeClass())) {
  reusableRecord.replace(Tuple2.of(outputStreamId, buildRow(event)), event.getTimestamp());
  output.collect(reusableRecord);
} else if (typeInfo.isTupleType()) {
  Tuple tuple = this.toTuple(event);
  reusableRecord.replace(Tuple2.of(outputStreamId, tuple), event.getTimestamp());
  output.collect(reusableRecord);
} else if (typeInfo instanceof PojoTypeInfo) {
    throw ex;
  reusableRecord.replace(Tuple2.of(outputStreamId, obj), event.getTimestamp());
  output.collect(reusableRecord);
} else {

代码示例来源:origin: org.wso2.carbon.event-processing/org.wso2.carbon.event.processor.core

public void sendEvent(Event event) {
  try {
    /**
     * Setting tenant id here because sometimes Siddhi creates its own threads, which does not
     * have tenant information initialized. These method calls can be a performance hit,
     * which needs to be profiled properly. Please update this comment one day after the
     * profiling is done properly.
     */
    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext privilegedCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
    privilegedCarbonContext.setTenantId(this.tenantId);
    privilegedCarbonContext.setTenantDomain(this.tenantDomain);
    if (traceEnabled) {
      trace.info(tracerPrefix + event);
    }
    if (statisticsEnabled) {
      eventCounter.inc();
    }
    if (eventProducerCallback != null) {
      eventProducerCallback.sendEvent(EventProcessorUtil.getWso2Event(streamDefinition, metaAttributeCount,
          correlationAttributeCount, payloadAttributeCount, event.getTimestamp(), event.getData()));
    }
  } finally {
    PrivilegedCarbonContext.endTenantFlow();
  }
}

代码示例来源:origin: org.wso2.extension.siddhi.map.wso2event/siddhi-map-wso2event

wso2event.setTimeStamp(event.getTimestamp());
wso2event.setStreamId(this.outputStreamId);
Object[] eventData = event.getData();

代码示例来源:origin: apache/eagle

AlertStreamEvent event = new AlertStreamEvent();
event.setSiteId(siteId);
event.setTimestamp(e.getTimestamp());
event.setData(e.getData());
event.setStreamId(outputStream);

相关文章