本文整理汇总了Java中com.espertech.esper.client.EPStatement.start方法的典型用法代码示例。如果您正苦于以下问题:Java EPStatement.start方法的具体用法?Java EPStatement.start怎么用?Java EPStatement.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.espertech.esper.client.EPStatement
的用法示例。
在下文中一共展示了EPStatement.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runAssertion1kValidStmtsPerformance
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertion1kValidStmtsPerformance(EPServiceProvider epService) {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
String text = "select * from " + SupportBean.class.getName();
EPStatement stmt = epService.getEPAdministrator().createEPL(text, "s1");
assertEquals("s1", stmt.getName());
stmt.stop();
stmt.start();
stmt.stop();
stmt.destroy();
}
long end = System.currentTimeMillis();
long delta = end - start;
assertTrue(".test10kValid delta=" + delta, delta < 10000);
epService.getEPAdministrator().destroyAllStatements();
}
示例2: addEvent
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
/**
* stores a EapEvent in a triplestore converts a EapEvent to a XMLEvent and
* sends it to Esper if a semantic part of an transformation rule exists,
* its EPL query will be evaluated against the event only if the semantic
* query returned a positive result
*
* @param event
*/
public void addEvent(final EapEvent event) {
final List<EPStatement> statementsWithStoppedListeners = new ArrayList<EPStatement>();
final long semStart = System.currentTimeMillis();
final List<TransformationRule> transformationRules = TransformationRule.getTransformationRulesForEvent(event);
final long semEnd = System.currentTimeMillis();
StreamProcessingAdapter.logger.debug(String.format("Semantic processing of event took %.2f seconds", (double) (semEnd - semStart) / 1000));
final long xmlStart = System.currentTimeMillis();
final Node node = XMLUtils.eventToNode(event);
final long xmlEnd = System.currentTimeMillis();
StreamProcessingAdapter.logger.debug(String.format("Conversion of event to node took %.2f seconds", (double) (xmlEnd - xmlStart) / 1000));
// XMLUtils.printDocument((Document) node);
if (node == null) {
System.err.println("Event was not parseable!");
}
// long timeInMilliseconds = event.getTimestamp().getTime();
// this.esperRuntime.sendEvent(new
// CurrentTimeEvent(timeInMilliseconds));
final long esperStart = System.currentTimeMillis();
/**
* THIS DOES THE ACTUAL TRIGGERING STUFF
*/
this.esperRuntime.sendEvent(node);
final long esperEnd = System.currentTimeMillis();
StreamProcessingAdapter.logger.debug(String.format("Esper processing of event took %.2f seconds", (double) (esperEnd - esperStart) / 1000));
// reactivate Esper statements
for (final EPStatement statement : statementsWithStoppedListeners) {
statement.start();
}
}
示例3: runAssertionStartStop
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStop(EPServiceProvider epService) {
String epl = "select count(*) as size from " + SupportBean.class.getName();
EPStatement sizeStmt = epService.getEPAdministrator().createEPL(epl);
// View created is automatically started
assertEquals(0L, sizeStmt.iterator().next().get("size"));
sizeStmt.stop();
// Send an event, view stopped
sendEvent(epService);
assertNull(sizeStmt.iterator());
// Start view
sizeStmt.start();
assertEquals(0L, sizeStmt.iterator().next().get("size"));
// Send event
sendEvent(epService);
assertEquals(1L, sizeStmt.iterator().next().get("size"));
// Stop view
sizeStmt.stop();
assertNull(sizeStmt.iterator());
// Start again, iterator is zero
sizeStmt.start();
assertEquals(0L, sizeStmt.iterator().next().get("size"));
sizeStmt.destroy();
}
示例4: run
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public void run(EPServiceProvider epService) throws Exception {
epService.getEPAdministrator().createEPL("create objectarray schema MyEvent(SubscriberName string, ValueInt float)");
final String query = "select SubscriberName, avg(ValueInt) "
+ "from MyEvent#groupwin(SubscriberName)#length(4)"
+ "group by SubscriberName output snapshot every 1 events";
final String query2 = "select SubscriberName, avedev(ValueInt) "
+ "from MyEvent#groupwin(SubscriberName)#length(3) "
+ "group by SubscriberName output snapshot every 1 events";
final String[] groups = {
"G_A", "G_A", "G_A", "G_A", "G_B", "G_B", "G_B", "G_B",
"G_B", "G_B", "G_B", "G_B", "G_B", "G_B", "G_B", "G_B",
"G_B", "G_B", "G_B", "G_B", "G_C", "G_C", "G_C", "G_C",
"G_D", "G_A", "G_D", "G_D", "G_A", "G_D", "G_D", "G_D",
"G_A", "G_A", "G_A", "G_A", "G_C", "G_C", "G_C", "G_C",
"G_D", "G_A", "G_D", "G_D", "G_D", "G_A", "G_D", "G_D",
"G_D", "G_E"};
EPStatement statement = epService.getEPAdministrator().createEPL(query, "myquery");
EPStatement statement2 = epService.getEPAdministrator().createEPL(query2, "myquery2");
SupportUpdateListener listener = new SupportUpdateListener();
statement.addListener(listener);
statement2.addListener(listener);
int i = 0;
for (String csv : groups) {
Object[] event = {csv, 0f};
epService.getEPRuntime().sendEvent(event, "MyEvent");
i++;
EPStatement stmt = epService.getEPAdministrator().getStatement("myquery");
if (i % 6 == 0) {
stmt.stop();
} else if (i % 6 == 4) {
stmt.start();
}
}
}
示例5: runAssertionUngroupedUncorrelatedTwoAggStopStart
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionUngroupedUncorrelatedTwoAggStopStart(EPServiceProvider epService) {
String stmtText = "select (select avg(id) + max(id) from S1#length(3)) as value from S0";
EPStatement stmt = epService.getEPAdministrator().createEPL(stmtText);
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
sendEventS0(epService, 1);
assertEquals(null, listener.assertOneGetNewAndReset().get("value"));
sendEventS1(epService, 100);
sendEventS0(epService, 2);
assertEquals(200.0, listener.assertOneGetNewAndReset().get("value"));
sendEventS1(epService, 200);
sendEventS0(epService, 3);
assertEquals(350.0, listener.assertOneGetNewAndReset().get("value"));
stmt.stop();
sendEventS1(epService, 10000);
sendEventS0(epService, 4);
assertFalse(listener.isInvoked());
stmt.start();
sendEventS1(epService, 10);
sendEventS0(epService, 5);
assertEquals(20.0, listener.assertOneGetNewAndReset().get("value"));
stmt.destroy();
}
示例6: runAssertionStartStopStatement
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStopStatement(EPServiceProvider epService) {
String stmtText = "select id from S0 where (select true from S1#length(1000))";
EPStatement stmt = epService.getEPAdministrator().createEPL(stmtText);
SupportUpdateListener listener = new SupportUpdateListener();
stmt.addListener(listener);
epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
assertFalse(listener.isInvoked());
epService.getEPRuntime().sendEvent(new SupportBean_S1(10));
epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
assertEquals(2, listener.assertOneGetNewAndReset().get("id"));
stmt.stop();
epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
assertFalse(listener.isInvoked());
stmt.start();
epService.getEPRuntime().sendEvent(new SupportBean_S0(2));
assertFalse(listener.isInvoked());
epService.getEPRuntime().sendEvent(new SupportBean_S1(10));
epService.getEPRuntime().sendEvent(new SupportBean_S0(3));
assertEquals(3, listener.assertOneGetNewAndReset().get("id"));
stmt.destroy();
}
示例7: runAssertionUnmatchedSendEvent
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionUnmatchedSendEvent(EPServiceProvider epService) {
MyUnmatchedListener listener = new MyUnmatchedListener();
epService.getEPRuntime().setUnmatchedListener(listener);
// no statement, should be unmatched
SupportBean theEvent = sendEvent(epService, "E1");
assertEquals(1, listener.getReceived().size());
assertSame(theEvent, listener.getReceived().get(0).getUnderlying());
listener.reset();
// no unmatched listener
epService.getEPRuntime().setUnmatchedListener(null);
sendEvent(epService, "E1");
assertEquals(0, listener.getReceived().size());
// create statement and re-register unmatched listener
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from " + SupportBean.class.getName());
epService.getEPRuntime().setUnmatchedListener(listener);
sendEvent(epService, "E1");
assertEquals(0, listener.getReceived().size());
// stop statement
stmt.stop();
theEvent = sendEvent(epService, "E1");
assertEquals(1, listener.getReceived().size());
assertSame(theEvent, listener.getReceived().get(0).getUnderlying());
listener.reset();
// start statement
stmt.start();
sendEvent(epService, "E1");
assertEquals(0, listener.getReceived().size());
// destroy statement
stmt.destroy();
theEvent = sendEvent(epService, "E1");
assertEquals(1, listener.getReceived().size());
assertSame(theEvent, listener.getReceived().get(0).getUnderlying());
}
示例8: runAssertionStartStopStatement
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStopStatement(EPServiceProvider epService) {
SubscriberInterface subscriber = new SubscriberInterface();
EPStatement stmt = epService.getEPAdministrator().createEPL("select * from SupportMarkerInterface");
stmt.setSubscriber(subscriber);
SupportBean_A a1 = new SupportBean_A("A1");
epService.getEPRuntime().sendEvent(a1);
EPAssertionUtil.assertEqualsExactOrder(new Object[]{a1}, subscriber.getAndResetIndicate().toArray());
SupportBean_B b1 = new SupportBean_B("B1");
epService.getEPRuntime().sendEvent(b1);
EPAssertionUtil.assertEqualsExactOrder(new Object[]{b1}, subscriber.getAndResetIndicate().toArray());
stmt.stop();
SupportBean_C c1 = new SupportBean_C("C1");
epService.getEPRuntime().sendEvent(c1);
assertEquals(0, subscriber.getAndResetIndicate().size());
stmt.start();
SupportBean_D d1 = new SupportBean_D("D1");
epService.getEPRuntime().sendEvent(d1);
EPAssertionUtil.assertEqualsExactOrder(new Object[]{d1}, subscriber.getAndResetIndicate().toArray());
stmt.destroy();
}
示例9: runAssertionSubclassInterface
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionSubclassInterface(EPServiceProvider epService) {
epService.getEPAdministrator().getConfiguration().addEventType("ISupportRevisionFull", ISupportRevisionFull.class);
epService.getEPAdministrator().getConfiguration().addEventType("ISupportDeltaFive", ISupportDeltaFive.class);
ConfigurationRevisionEventType config = new ConfigurationRevisionEventType();
config.addNameBaseEventType("ISupportRevisionFull");
config.setKeyPropertyNames(new String[]{"k0"});
config.addNameDeltaEventType("ISupportDeltaFive");
epService.getEPAdministrator().getConfiguration().addRevisionEventType("MyInterface", config);
EPStatement stmtCreateWin = epService.getEPAdministrator().createEPL("create window MyInterfaceWindow#keepall as select * from MyInterface");
epService.getEPAdministrator().createEPL("insert into MyInterfaceWindow select * from ISupportRevisionFull");
epService.getEPAdministrator().createEPL("insert into MyInterfaceWindow select * from ISupportDeltaFive");
EPStatement consumerOne = epService.getEPAdministrator().createEPL("@Audit select irstream k0,p0,p1 from MyInterfaceWindow");
SupportUpdateListener listenerOne = new SupportUpdateListener();
consumerOne.addListener(listenerOne);
String[] fields = "k0,p0,p1".split(",");
EPAssertionUtil.assertEqualsAnyOrder(consumerOne.getEventType().getPropertyNames(), fields);
epService.getEPRuntime().sendEvent(new SupportRevisionFull(null, "00", "10", "20", "30", "40", "50"));
EPAssertionUtil.assertProps(listenerOne.assertOneGetNewAndReset(), fields, new Object[]{null, "00", "10"});
epService.getEPRuntime().sendEvent(new SupportDeltaFive(null, "999", null));
EPAssertionUtil.assertProps(listenerOne.getLastNewData()[0], fields, new Object[]{null, "00", "999"});
EPAssertionUtil.assertProps(listenerOne.getLastOldData()[0], fields, new Object[]{null, "00", "10"});
listenerOne.reset();
stmtCreateWin.stop();
stmtCreateWin.start();
consumerOne.stop();
consumerOne.start();
epService.getEPRuntime().sendEvent(new SupportRevisionFull("zz", "xx", "yy", "20", "30", "40", "50"));
EPAssertionUtil.assertProps(listenerOne.assertOneGetNewAndReset(), fields, new Object[]{"zz", "xx", "yy"});
}
示例10: activateTransformationRule
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
public void activateTransformationRule(final TransformationRule transformationRule) {
final EPStatement statement = StreamProcessingAdapter.getInstance().getStatement(TransformationRuleLogic.generateStatementName(transformationRule));
statement.start();
}
示例11: runAssertionStartStopConsumer
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStopConsumer(EPServiceProvider epService, boolean namedWindow) {
// create window
String stmtTextCreate = namedWindow ?
"create window MyInfra#keepall as select theString as a, intPrimitive as b from " + SupportBean.class.getName() :
"create table MyInfra(a string primary key, b int primary key)";
EPStatement stmtCreate = epService.getEPAdministrator().createEPL(stmtTextCreate);
SupportUpdateListener listenerWindow = new SupportUpdateListener();
stmtCreate.addListener(listenerWindow);
// create insert into
String stmtTextInsertOne = "insert into MyInfra select theString as a, intPrimitive as b from " + SupportBean.class.getName();
epService.getEPAdministrator().createEPL(stmtTextInsertOne);
// create consumer
String[] fields = new String[]{"a", "b"};
String stmtTextSelect = "select a, b from MyInfra as s1";
EPStatement stmtSelect = epService.getEPAdministrator().createEPL(stmtTextSelect);
SupportUpdateListener listenerSelect = new SupportUpdateListener();
stmtSelect.addListener(listenerSelect);
// send 1 event
sendSupportBean(epService, "E1", 1);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E1", 1});
EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fields, new Object[]{"E1", 1});
}
EPAssertionUtil.assertPropsPerRow(stmtCreate.iterator(), fields, new Object[][]{{"E1", 1}});
// stop consumer
stmtSelect.stop();
sendSupportBean(epService, "E2", 2);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E2", 2});
}
assertFalse(listenerSelect.isInvoked());
EPAssertionUtil.assertPropsPerRowAnyOrder(stmtCreate.iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}});
// start consumer: the consumer has the last event even though he missed it
stmtSelect.start();
EPAssertionUtil.assertPropsPerRowAnyOrder(stmtSelect.iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}});
// consumer receives the next event
sendSupportBean(epService, "E3", 3);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E3", 3});
EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fields, new Object[]{"E3", 3});
EPAssertionUtil.assertPropsPerRow(stmtSelect.iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}, {"E3", 3}});
}
EPAssertionUtil.assertPropsPerRowAnyOrder(stmtCreate.iterator(), fields, new Object[][]{{"E1", 1}, {"E2", 2}, {"E3", 3}});
// destroy consumer
stmtSelect.destroy();
sendSupportBean(epService, "E4", 4);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E4", 4});
}
assertFalse(listenerSelect.isInvoked());
epService.getEPAdministrator().destroyAllStatements();
epService.getEPAdministrator().getConfiguration().removeEventType("MyInfra", false);
}
示例12: runAssertionStartStopInserter
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStopInserter(EPServiceProvider epService, boolean namedWindow) {
// create window
String stmtTextCreate = namedWindow ?
"create window MyInfra#keepall as select theString as a, intPrimitive as b from " + SupportBean.class.getName() :
"create table MyInfra(a string primary key, b int primary key)";
EPStatement stmtCreate = epService.getEPAdministrator().createEPL(stmtTextCreate);
SupportUpdateListener listenerWindow = new SupportUpdateListener();
stmtCreate.addListener(listenerWindow);
// create insert into
String stmtTextInsertOne = "insert into MyInfra select theString as a, intPrimitive as b from " + SupportBean.class.getName();
EPStatement stmtInsert = epService.getEPAdministrator().createEPL(stmtTextInsertOne);
// create consumer
String[] fields = new String[]{"a", "b"};
String stmtTextSelect = "select a, b from MyInfra as s1";
EPStatement stmtSelect = epService.getEPAdministrator().createEPL(stmtTextSelect);
SupportUpdateListener listenerSelect = new SupportUpdateListener();
stmtSelect.addListener(listenerSelect);
// send 1 event
sendSupportBean(epService, "E1", 1);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E1", 1});
EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fields, new Object[]{"E1", 1});
}
EPAssertionUtil.assertPropsPerRow(stmtCreate.iterator(), fields, new Object[][]{{"E1", 1}});
// stop inserter
stmtInsert.stop();
sendSupportBean(epService, "E2", 2);
assertFalse(listenerWindow.isInvoked());
assertFalse(listenerSelect.isInvoked());
// start inserter
stmtInsert.start();
// consumer receives the next event
sendSupportBean(epService, "E3", 3);
if (namedWindow) {
EPAssertionUtil.assertProps(listenerWindow.assertOneGetNewAndReset(), fields, new Object[]{"E3", 3});
EPAssertionUtil.assertProps(listenerSelect.assertOneGetNewAndReset(), fields, new Object[]{"E3", 3});
EPAssertionUtil.assertPropsPerRow(stmtSelect.iterator(), fields, new Object[][]{{"E1", 1}, {"E3", 3}});
}
EPAssertionUtil.assertPropsPerRowAnyOrder(stmtCreate.iterator(), fields, new Object[][]{{"E1", 1}, {"E3", 3}});
// destroy inserter
stmtInsert.destroy();
sendSupportBean(epService, "E4", 4);
assertFalse(listenerWindow.isInvoked());
assertFalse(listenerSelect.isInvoked());
epService.getEPAdministrator().destroyAllStatements();
epService.getEPAdministrator().getConfiguration().removeEventType("MyInfra", false);
}
示例13: runAssertionStatementFilter
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStatementFilter(EPServiceProvider epService) throws Exception {
epService.getEPAdministrator().getConfiguration().addEventType(SupportBean.class);
epService.getEPAdministrator().getConfiguration().addEventType(SupportBean_A.class);
epService.getEPAdministrator().getConfiguration().addEventType(SupportBean_B.class);
// one statement exists before the data flow
EPStatement stmt = epService.getEPAdministrator().createEPL("select id from SupportBean_B");
epService.getEPAdministrator().createEPL("create dataflow MyDataFlowOne " +
"create schema AllObjects Object," +
"EPStatementSource -> thedata<AllObjects> {} " +
"DefaultSupportCaptureOp(thedata) {}");
DefaultSupportCaptureOp<Object> captureOp = new DefaultSupportCaptureOp<Object>();
EPDataFlowInstantiationOptions options = new EPDataFlowInstantiationOptions();
MyFilter myFilter = new MyFilter();
options.parameterProvider(new DefaultSupportGraphParamProvider(Collections.<String, Object>singletonMap("statementFilter", myFilter)));
options.operatorProvider(new DefaultSupportGraphOpProvider(captureOp));
EPDataFlowInstance df = epService.getEPRuntime().getDataFlowRuntime().instantiate("MyDataFlowOne", options);
df.start();
epService.getEPRuntime().sendEvent(new SupportBean_B("B1"));
captureOp.waitForInvocation(200, 1);
EPAssertionUtil.assertProps(captureOp.getCurrentAndReset()[0], "id".split(","), new Object[]{"B1"});
epService.getEPAdministrator().createEPL("select theString, intPrimitive from SupportBean");
epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
captureOp.waitForInvocation(200, 1);
EPAssertionUtil.assertProps(captureOp.getCurrentAndReset()[0], "theString,intPrimitive".split(","), new Object[]{"E1", 1});
EPStatement stmtTwo = epService.getEPAdministrator().createEPL("select id from SupportBean_A");
epService.getEPRuntime().sendEvent(new SupportBean_A("A1"));
captureOp.waitForInvocation(200, 1);
EPAssertionUtil.assertProps(captureOp.getCurrentAndReset()[0], "id".split(","), new Object[]{"A1"});
stmtTwo.stop();
epService.getEPRuntime().sendEvent(new SupportBean_A("A2"));
Thread.sleep(50);
assertEquals(0, captureOp.getCurrent().length);
stmtTwo.start();
epService.getEPRuntime().sendEvent(new SupportBean_A("A3"));
captureOp.waitForInvocation(200, 1);
EPAssertionUtil.assertProps(captureOp.getCurrentAndReset()[0], "id".split(","), new Object[]{"A3"});
epService.getEPRuntime().sendEvent(new SupportBean_B("B2"));
captureOp.waitForInvocation(200, 1);
EPAssertionUtil.assertProps(captureOp.getCurrentAndReset()[0], "id".split(","), new Object[]{"B2"});
df.cancel();
epService.getEPRuntime().sendEvent(new SupportBean("E1", 1));
epService.getEPRuntime().sendEvent(new SupportBean_A("A1"));
epService.getEPRuntime().sendEvent(new SupportBean_B("B3"));
assertEquals(0, captureOp.getCurrent().length);
epService.getEPAdministrator().destroyAllStatements();
}
示例14: runAssertionIntoTable
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionIntoTable(EPServiceProvider epService) throws Exception {
String eplCreate = "create table abc (total count(*))";
String eplUse = "select abc from SupportBean";
String eplInto = "into table abc select count(*) as total from SupportBean";
// typical select-use-destroy
EPStatement stmtCreate = epService.getEPAdministrator().createEPL(eplCreate);
EPStatement stmtSelect = epService.getEPAdministrator().createEPL(eplUse);
EPStatement stmtInto = epService.getEPAdministrator().createEPL(eplInto);
assertNotNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__public"));
assertNotNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__internal"));
stmtCreate.destroy();
stmtSelect.destroy();
assertFailCreate(epService, eplCreate);
stmtInto.destroy();
// destroy-all
epService.getEPAdministrator().createEPL(eplCreate);
epService.getEPAdministrator().createEPL(eplInto);
epService.getEPAdministrator().createEPL(eplUse);
epService.getEPAdministrator().destroyAllStatements();
stmtCreate = epService.getEPAdministrator().createEPL(eplCreate);
stmtCreate.destroy();
// deploy and undeploy as module
String module = eplCreate + ";\n" + eplUse + ";\n" + eplInto + ";\n";
DeploymentResult deployed = epService.getEPAdministrator().getDeploymentAdmin().parseDeploy(module);
assertNotNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__public"));
assertNotNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__internal"));
assertFailCreate(epService, eplCreate);
epService.getEPAdministrator().getDeploymentAdmin().undeploy(deployed.getDeploymentId());
assertNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__public"));
assertNull(epService.getEPAdministrator().getConfiguration().getEventType("table_abc__internal"));
// stop and start
EPStatement stmtCreateTwo = epService.getEPAdministrator().createEPL(eplCreate);
stmtCreateTwo.stop();
assertFailCreate(epService, eplCreate);
stmtCreateTwo.start();
assertFailCreate(epService, eplCreate);
epService.getEPAdministrator().destroyAllStatements();
epService.getEPAdministrator().createEPL(eplCreate);
epService.getEPAdministrator().destroyAllStatements();
}
示例15: runAssertionStartStop
import com.espertech.esper.client.EPStatement; //导入方法依赖的package包/类
private void runAssertionStartStop(EPServiceProvider epService) {
String epl = "@IterableUnbound every tag=" + SupportBean.class.getName();
EPStatement patternStmt = epService.getEPAdministrator().createPattern(epl, "MyPattern");
assertEquals(StatementType.PATTERN, ((EPStatementSPI) patternStmt).getStatementMetadata().getStatementType());
// Pattern started when created
assertFalse(patternStmt.iterator().hasNext());
SafeIterator<EventBean> safe = patternStmt.safeIterator();
assertFalse(safe.hasNext());
safe.close();
// Stop pattern
patternStmt.stop();
sendEvent(epService);
assertNull(patternStmt.iterator());
// Start pattern
patternStmt.start();
assertFalse(patternStmt.iterator().hasNext());
// Send event
SupportBean theEvent = sendEvent(epService);
assertSame(theEvent, patternStmt.iterator().next().get("tag"));
safe = patternStmt.safeIterator();
assertSame(theEvent, safe.next().get("tag"));
safe.close();
// Stop pattern
patternStmt.stop();
assertNull(patternStmt.iterator());
// Start again, iterator is zero
patternStmt.start();
assertFalse(patternStmt.iterator().hasNext());
// assert statement-eventtype reference info
EPServiceProviderSPI spi = (EPServiceProviderSPI) epService;
assertTrue(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
Set<String> stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
assertTrue(stmtNames.contains("MyPattern"));
patternStmt.destroy();
assertFalse(spi.getStatementEventTypeRef().isInUse(SupportBean.class.getName()));
stmtNames = spi.getStatementEventTypeRef().getStatementNamesForType(SupportBean.class.getName());
assertFalse(stmtNames.contains("MyPattern"));
}