Java源码示例:com.espertech.esper.client.EventType

示例1
@SuppressWarnings("unchecked")
public JetstreamEvent getJetstreamEvent(EventBean bean) throws EventException {
  JetstreamEvent jetstreamEvent = null;
  EventType eventType = bean.getEventType();
  if (eventType instanceof MapEventType) {
    MapEventType meType = (MapEventType) eventType;
    jetstreamEvent = new JetstreamEvent(meType.getName(), null, (Map<String, Object>) bean.getUnderlying());
  }
  //
  // Consider this:
  // INSERT INTO FDL SELECT
  // com.ebay.jetstream.identity.client.IdentityClient.findDirectLinks(metricUpdate.Guid, 'user') AS FindDirectLinks
  // FROM metricUpdate;
  // /*$OUTPUT*/ SELECT FindDirectLinks.* FROM FDL;
  //
  else if (eventType instanceof BeanEventType) {
    BeanEventType beType = (BeanEventType) eventType;
    jetstreamEvent = new JetstreamEvent(beType.getName(), null, (Map<String, Object>) bean.getUnderlying());
  }
  return jetstreamEvent;
}
 
示例2
/**
 * Creates the event type for this view.
 * @param statementContext is the event adapter service
 * @return event type of view
 */
public static EventType createEventType(StatementContext statementContext, StatViewAdditionalProps additionalProps, int streamNum) {
	Map<String, Object> eventTypeMap = new HashMap<String, Object>();
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS.getName(), Long.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL.getName(), Double.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV.getName(), Double.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA.getName(), Double.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE.getName(), Double.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE.getName(), Double.class);
	eventTypeMap.put(ViewFieldEnum.UNIVARIATE_STATISTICS__GEOMAVERAGE.getName(), double.class);
	StatViewAdditionalProps.addCheckDupProperties(eventTypeMap, additionalProps, ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS,
			ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL, ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV, ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA,
			ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE, ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE);
	String outputEventTypeName = statementContext.getStatementId() + "_statview_" + streamNum;
	return statementContext.getEventAdapterService().createAnonymousMapType(outputEventTypeName, eventTypeMap);
}
 
示例3
@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);
    }
}
 
示例4
boolean init() {
	try{
		
		compile(true);
		for (EventType type : m_epAdmin.getConfiguration().getEventTypes())
			m_setKnownEvent.add(type.getName());
		
		m_esperService.getEPRuntime().getEventSender("EsperStartup").sendEvent(new Object());
		
		return true;
	}
	catch (Throwable e) {
		if (getAlertListener() != null) {
			getAlertListener().sendAlert(getBeanName(), " Esper Processor: init failed with e=" +e, AlertListener.AlertStrength.RED);
		}
		if (getEsperExceptionHandler() != null) {
			getEsperExceptionHandler().setLastException(e.getMessage());
		}
		registerError(e);
		e.printStackTrace(System.err);
	
		logger.error( "Processor " + getBeanName()
				+ " failed to prepare. The application will be shut down immediately. Exception: " + e.getMessage());
				
		
		return false;
	}
}
 
示例5
/**
 * Constructor requires the name of the field to use in the parent view to compute the statistics.
 * @param fieldExpression is the expression to use to get numeric data points for this view to
 * compute the statistics on.
 * @param statementContext contains required view services
 */
public UnivariateStatisticsView(StatementContext statementContext, ExprNode fieldExpression, EventType eventType, StatViewAdditionalProps additionalProps) {
	this.statementContext = statementContext;
	this.fieldExpression = fieldExpression;
	this.fieldExpressionEvaluator = fieldExpression.getExprEvaluator();
	this.eventType = eventType;
	this.additionalProps = additionalProps;
}
 
示例6
public static EventBean populateMap(BaseStatisticsBean baseStatisticsBean, EventAdapterService eventAdapterService, EventType eventType,
		StatViewAdditionalProps additionalProps, Object[] lastNewValues) {
	Map<String, Object> result = new HashMap<String, Object>();
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__DATAPOINTS.getName(), baseStatisticsBean.getN());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__TOTAL.getName(), baseStatisticsBean.getXSum());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEV.getName(), baseStatisticsBean.getXStandardDeviationSample());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__STDDEVPA.getName(), baseStatisticsBean.getXStandardDeviationPop());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__VARIANCE.getName(), baseStatisticsBean.getXVariance());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__AVERAGE.getName(), baseStatisticsBean.getXAverage());
	result.put(ViewFieldEnum.UNIVARIATE_STATISTICS__GEOMAVERAGE.getName(), baseStatisticsBean.getGeomAvgX());
	if (additionalProps != null) {
		additionalProps.addProperties(result, lastNewValues);
	}
	return eventAdapterService.adaptorForTypedMap(result, eventType);
}
 
示例7
public void attach(EventType parentEventType, StatementContext statementContext, ViewFactory optionalParentFactory, List<ViewFactory> parentViewFactories) throws ViewParameterException
{
    ExprNode[] validatedNodes = ViewFactorySupport.validate("OHLC view", parentEventType, statementContext, viewParameters, false);

    timestampExpression = validatedNodes[0];
    valueExpression = validatedNodes[1];

    if ((timestampExpression.getExprEvaluator().getType() != long.class) && (timestampExpression.getExprEvaluator().getType() != Long.class)) {
        throw new ViewParameterException("View requires long-typed timestamp values in parameter 1");
    }
    if ((valueExpression.getExprEvaluator().getType() != double.class) && (valueExpression.getExprEvaluator().getType() != Double.class)) {
        throw new ViewParameterException("View requires double-typed values for in parameter 2");
    }
}
 
示例8
@Override
public EventType getEventType(String arg0) {
	
	return m_esperconfig.getEventType(arg0);
}
 
示例9
@Override
public EventType[] getEventTypes() {
	
	return m_esperconfig.getEventTypes();
}
 
示例10
public final EventType getEventType() {
	return this.eventType;
}
 
示例11
public EventType getEventType()
{
    return OHLCBarPlugInView.getEventType(viewFactoryContext.getEventAdapterService());
}
 
示例12
public EventType getEventType()
{
    return getEventType(statementContext.getEventAdapterService());
}
 
示例13
protected static EventType getEventType(EventAdapterService eventAdapterService)
{
    return eventAdapterService.addBeanType(OHLCBarValue.class.getName(), OHLCBarValue.class, false, false, false);
}