当前位置: 首页>>代码示例>>Java>>正文


Java EPAdministrator.createEPL方法代码示例

本文整理汇总了Java中com.espertech.esper.client.EPAdministrator.createEPL方法的典型用法代码示例。如果您正苦于以下问题:Java EPAdministrator.createEPL方法的具体用法?Java EPAdministrator.createEPL怎么用?Java EPAdministrator.createEPL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.espertech.esper.client.EPAdministrator的用法示例。


在下文中一共展示了EPAdministrator.createEPL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testTimestamp

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
@Test
public void testTimestamp() {
	final Configuration cepConfig = new Configuration();
	cepConfig.addEventType("Event", EapEvent.class.getName());
	final EPServiceProvider cep = EPServiceProviderManager.getProvider("myCEPEngine", cepConfig);
	final EPRuntime cepRT = cep.getEPRuntime();
	final EPAdministrator cepAdm = cep.getEPAdministrator();

	// create statement
	final EPStatement timeStatement = cepAdm.createEPL("select count(*) from Event.win:time(1 hour)");
	timeStatement.addListener(new CEPListener());

	// create events
	final List<EapEvent> ratingEvents = this.createRatingEvents();
	this.sortEventListByDate(ratingEvents);

	// pass events to Esper engine
	for (final EapEvent event : ratingEvents) {
		cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
		// System.out.println(new
		// CurrentTimeEvent(event.getTimestamp().getTime()).toString());
		cepRT.sendEvent(new CurrentTimeEvent(event.getTimestamp().getTime()));
		cepRT.sendEvent(event);
	}
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:26,代码来源:StatementTest.java

示例2: FindMissingEventStmt

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public FindMissingEventStmt(EPAdministrator admin) {
    // The inner table to both A and B is C.
    //
    // The listener will consider old events generated when either A or B leave the window, with
    // a window size for A and B of 30 minutes.
    //
    // The window of C is declared large to ensure the C events don't leave the window before A and B
    // thus generating false alerts, making these obvious via timestamp. Lets keep 1 hour of data for C.
    String stmt = "select irstream * from " +
            "TxnEventA#time(30 min) A " +
            "full outer join " +
            "TxnEventC#time(1 hour) C on A.transactionId = C.transactionId " +
            "full outer join " +
            "TxnEventB#time(30 min) B on B.transactionId = C.transactionId " +
            "where C.transactionId is null";

    statement = admin.createEPL(stmt);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:FindMissingEventStmt.java

示例3: CombinedEventStmt

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public CombinedEventStmt(EPAdministrator admin) {
    // We need to take in events A, B and C and produce a single, combined event
    String stmt = "insert into CombinedEvent(transactionId, customerId, supplierId, latencyAC, latencyBC, latencyAB)" +
            "select C.transactionId," +
            "customerId," +
            "supplierId," +
            "C.timestamp - A.timestamp," +
            "C.timestamp - B.timestamp," +
            "B.timestamp - A.timestamp " +
            "from TxnEventA#time(30 min) A," +
            "TxnEventB#time(30 min) B," +
            "TxnEventC#time(30 min) C " +
            "where A.transactionId = B.transactionId and B.transactionId = C.transactionId";

    statement = admin.createEPL(stmt);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:17,代码来源:CombinedEventStmt.java

示例4: createStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public static void createStatement(EPAdministrator admin) {
    EPStatement statement = admin.createEPL("select istream ipAddress, avg(duration) from SampleEvent#time(10 sec) group by ipAddress output snapshot every 2 seconds order by ipAddress asc");
    statement.addListener(new UpdateListener() {
        public void update(EventBean[] newEvents, EventBean[] oldEvents) {
            if (newEvents == null) {
                return;
            }

            for (int i = 0; i < newEvents.length; i++) {
                if (log.isInfoEnabled()) {
                    log.info("IPAddress: " + newEvents[i].get("ipAddress") +
                            " Avg Duration: " + newEvents[i].get("avg(duration)"));
                }
            }
        }
    });

}
 
开发者ID:espertechinc,项目名称:esper,代码行数:19,代码来源:SampleStatement.java

示例5: EsperOperation

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public EsperOperation() {
	Configuration cepConfig = new Configuration();
	cepConfig.addEventType("StockTick", Stock.class.getName());
	EPServiceProvider cep = EPServiceProviderManager.getProvider(
			"myCEPEngine", cepConfig);
	cepRT = cep.getEPRuntime();

	EPAdministrator cepAdm = cep.getEPAdministrator();
	EPStatement cepStatement = cepAdm
			.createEPL("select sum(price),product from "
					+ "StockTick.win:time_batch(5 sec) "
					+ "group by product");

	cepStatement.addListener(new CEPListener());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Apache-Storm,代码行数:16,代码来源:EsperOperation.java

示例6: testContextQuery

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
@Test
public void testContextQuery() {
	final Configuration cepConfig = new Configuration();
	cepConfig.addEventType("Event", EapEvent.class.getName());
	final EPServiceProvider cep = EPServiceProviderManager.getProvider("myCEPEngine", cepConfig);
	final EPRuntime cepRT = cep.getEPRuntime();

	final EPAdministrator cepAdm = cep.getEPAdministrator();

	cepAdm.createEPL("" + "CREATE CONTEXT NestedContext " + "CONTEXT SegmentedByLocation PARTITION BY values('Location') FROM Event, " + "CONTEXT SegmentedByTime INITIATED BY Event(values('Action')='Ende') TERMINATED AFTER 1 hour, " + "CONTEXT SegmentedByRating PARTITION BY values('Rating') FROM Event");

	final EPStatement transformationStatement = cepAdm.createEPL("" + "CONTEXT NestedContext " + "SELECT ID, values('Location'), values('Rating'), count(*) " + "FROM Event " + "GROUP BY values('Location'), values('Rating') " + "OUTPUT LAST EVERY 30 minute");

	transformationStatement.addListener(new CEPListener());

	final List<EapEvent> events = new ArrayList<EapEvent>();
	events.addAll(this.createRatingEvents());
	events.addAll(this.createKinoEvents());
	this.sortEventListByDate(events);

	for (final EapEvent event : events) {
		cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_EXTERNAL));
		cepRT.sendEvent(new CurrentTimeEvent(event.getTimestamp().getTime()));
		cepRT.sendEvent(event);
	}

	cepRT.sendEvent(new TimerControlEvent(TimerControlEvent.ClockType.CLOCK_INTERNAL));
}
 
开发者ID:bptlab,项目名称:Unicorn,代码行数:29,代码来源:StatementTest.java

示例7: RealtimeSummaryStmt

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public RealtimeSummaryStmt(EPAdministrator admin) {
    //
    // Min,Max,Average total latency from the events (difference in time between A and C) over the past 30 minutes.
    // Min,Max,Average latency between events A/B (time stamp of B minus A) and B/C (time stamp of C minus B).
    //
    String stmtTotal = "select min(latencyAC) as minLatencyAC, " +
            "max(latencyAC) as maxLatencyAC, " +
            "avg(latencyAC) as avgLatencyAC, " +
            "min(latencyAB) as minLatencyAB, " +
            "max(latencyAB) as maxLatencyAB, " +
            "avg(latencyAB) as avgLatencyAB, " +
            "min(latencyBC) as minLatencyBC, " +
            "max(latencyBC) as maxLatencyBC, " +
            "avg(latencyBC) as avgLatencyBC " +
            "from CombinedEvent#time(30 min)";

    totalsStatement = admin.createEPL(stmtTotal);

    //
    // Min,Max,Average latency grouped by (a) customer ID and (b) supplier ID.
    // In other words, metrics on the the latency of the orders coming from each customer and going to each supplier.
    //
    String stmtCustomer = "select customerId," +
            "min(latencyAC) as minLatency," +
            "max(latencyAC) as maxLatency," +
            "avg(latencyAC) as avgLatency " +
            "from CombinedEvent#time(30 min) " +
            "group by customerId";

    byCustomerStatement = admin.createEPL(stmtCustomer);

    String stmtSupplier = "select supplierId," +
            "min(latencyAC) as minLatency," +
            "max(latencyAC) as maxLatency," +
            "avg(latencyAC) as avgLatency " +
            "from CombinedEvent#time(30 min) " +
            "group by supplierId";

    bySupplierStatement = admin.createEPL(stmtSupplier);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:41,代码来源:RealtimeSummaryStmt.java

示例8: start

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public static void start() {
    EPAdministrator admin = EPServiceProviderManager.getDefaultProvider().getEPAdministrator();

    EPStatement statView = admin.createEPL(
            "select * from " + OperationMeasurement.class.getName() +
                    "#groupwin(customerId, operationName)" +
                    "#length(100)#uni(latency)");

    statView.addListener(new AverageLatencyListener(10000));
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:11,代码来源:AverageLatencyMonitor.java

示例9: TicksFalloffStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public TicksFalloffStatement(EPAdministrator admin) {
    String stmt = "select feed, avg(cnt) as avgCnt, cnt as feedCnt from TicksPerSecond#time(10 sec) " +
            "group by feed " +
            "having cnt < avg(cnt) * 0.75 ";

    statement = admin.createEPL(stmt);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:8,代码来源:TicksFalloffStatement.java

示例10: RFIDTagsPerSensorStmt

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public RFIDTagsPerSensorStmt(EPAdministrator admin) {
    String stmt = "select ID as sensorId, coalesce(sum(countTags), 0) as numTagsPerSensor " +
            "from AutoIdRFIDExample#time(60 sec) " +
            "where Observation[0].Command = 'READ_PALLET_TAGS_ONLY' " +
            "group by ID";

    statement = admin.createEPL(stmt);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:9,代码来源:RFIDTagsPerSensorStmt.java

示例11: EsperTestAggregationStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public EsperTestAggregationStatement(EPAdministrator admin) {
  admin.createEPL("INSERT INTO S SELECT 1.1+guid AS V, workerId, guid FROM EsperTestAggregationEvent");
  admin.createEPL("INSERT INTO S SELECT 2.2+guid AS V, workerId, guid FROM EsperTestAggregationEvent");
  admin.createEPL("INSERT INTO S SELECT 3.3+guid AS V, workerId, guid FROM EsperTestAggregationEvent");
  admin.createEPL("INSERT INTO S SELECT 4.4+guid AS V, workerId, guid FROM EsperTestAggregationEvent");
  admin.createEPL("CREATE WINDOW SW.win:keepall() AS (V double, workerId long, guid int)");
  admin.createEPL("INSERT INTO SW SELECT V, workerId, guid FROM S");
  admin.createEPL("ON CleanupWindowEvent DELETE FROM SW WHERE SW.workerId = CleanupWindowEvent.workerId");
  statement = admin.createEPL("SELECT * FROM OutputEvent");
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:11,代码来源:EsperTestAggregationStatement.java

示例12: createStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
@Override
public EPStatement createStatement(EPAdministrator administrator) {
    return administrator.createEPL(query);
}
 
开发者ID:phil3k3,项目名称:flink-esper,代码行数:5,代码来源:EsperQuery.java

示例13: TicksPerSecondStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public TicksPerSecondStatement(EPAdministrator admin) {
    String stmt = "insert into TicksPerSecond " +
            "select feed, count(*) as cnt from MarketDataEvent#time_batch(1 sec) group by feed";

    statement = admin.createEPL(stmt);
}
 
开发者ID:espertechinc,项目名称:esper,代码行数:7,代码来源:TicksPerSecondStatement.java

示例14: EsperTestStatement

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
public EsperTestStatement(EPAdministrator admin) {
	String stmt = "select id, field1, field2, field3 from EsperTestEvent";
    statement = admin.createEPL(stmt);
}
 
开发者ID:pulsarIO,项目名称:jetstream-esper,代码行数:5,代码来源:EsperTestStatement.java

示例15: handleDeployRule

import com.espertech.esper.client.EPAdministrator; //导入方法依赖的package包/类
protected void handleDeployRule(String strategyName, String moduleName, String ruleName, Integer targetId) throws Exception {

		EPAdministrator administrator = getServiceProvider(strategyName).getEPAdministrator();

		// do nothing if the statement already exists
		EPStatement oldStatement = administrator.getStatement(ruleName);
		if (oldStatement != null && oldStatement.isStarted()) {
			return;
		}

		// read the statement from the module
		EPDeploymentAdmin deployAdmin = administrator.getDeploymentAdmin();
		Module module = deployAdmin.read("module-" + moduleName + ".epl");
		List<ModuleItem> items = module.getItems();

		// go through all statements in the module
		EPStatement newStatement = null;
		items: for (ModuleItem item : items) {
			String exp = item.getExpression();

			// get the ObjectModel for the statement
			EPStatementObjectModel model;
			EPPreparedStatementImpl prepared = null;
			if (exp.contains("?")) {
				prepared = (EPPreparedStatementImpl) administrator.prepareEPL(exp);
				model = prepared.getModel();
			} else {
				model = administrator.compileEPL(exp);
			}

			// go through all annotations and check if the statement has the 'name' 'ruleName'
			List<AnnotationPart> annotationParts = model.getAnnotations();
			for (AnnotationPart annotationPart : annotationParts) {
				if (annotationPart.getName().equals("Name")) {
					for (AnnotationAttribute attribute : annotationPart.getAttributes()) {
						if (attribute.getValue().equals(ruleName)) {

							// create the statement
							newStatement = administrator.createEPL(model.toEPL());

							// check if the statement is elgible, other destory it righ away
							processAnnotations(strategyName, newStatement);

							// break iterating over the statements
							break items;
						}
					}
				}
			}
		}

		if (newStatement == null) {
			logger.warn("statement " + ruleName + " was not found");
		} else {
			logger.debug("deployed rule " + newStatement.getName() + " on service provider: " + strategyName);
		}
	}
 
开发者ID:curtiszimmerman,项目名称:AlgoTrader,代码行数:58,代码来源:RuleServiceImpl.java


注:本文中的com.espertech.esper.client.EPAdministrator.createEPL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。