public void addListener(UpdateListener listener) { statement.addListener(listener); } }
public void addListener(UpdateListener listener) { statement.addListener(listener); } }
public void createEPL(String expression, String statementName, UpdateListener listener) { log.info("Via Java Management JMX proxy: Creating statement '" + expression + "' named '" + statementName + "'"); EPStatement stmt = compileDeploy(expression, statementName); stmt.addListener(listener); }
public DynaLatencySpikeMonitor(EPRuntime runtime) { this.runtime = runtime; EPStatement latency = MonitorUtil.compileDeploy("select * from LatencyLimit", runtime); latency.addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { LatencyLimit limitEvent = (LatencyLimit) newEvents[0].getUnderlying(); createLatencyCheck(limitEvent, runtime); } }); }
public void onDeployment(DeploymentStateEventDeployed event) { for (EPStatement stmt : event.getStatements()) { stmt.addListener(listener); } }
public ServiceHealthMonitor(EPRuntime runtime) { String epl = "select * from OperationMeasurement(success=false)\n" + " match_recognize (\n" + " measures a as a_events" + " pattern (a a a))"; EPStatement statement = MonitorUtil.compileDeploy(epl, runtime); statement.addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { log.debug(".update Alert, detected 3 errors in a row"); } }); }
public RegressionEnvironment addListener(String statementName, SupportListener listener) { getAssertStatement(statementName).addListener(listener); return this; }
public AverageLatencyMonitor(EPRuntime runtime) { EPStatement statement = MonitorUtil.compileDeploy("select * from OperationMeasurement#groupwin(customerId, operationName)#length(100)#uni(latency)", runtime); statement.addListener(new AverageLatencyListener(10000)); } }
public ErrorRateMonitor(EPRuntime runtime) { String fireEvery10SecondsEPL = "select * from pattern[every timer:at(*, *, *, *, *, */10)]"; EPStatement fireEvery10Seconds = MonitorUtil.compileDeploy(fireEvery10SecondsEPL, runtime); String countEventsEPL = "select count(*) as size from OperationMeasurement(success=false)#time(10 min)"; EPStatement countEvents = MonitorUtil.compileDeploy(countEventsEPL, runtime); fireEvery10Seconds.addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { long count = (Long) countEvents.iterator().next().get("size"); log.info(".update Info, error rate in the last 10 minutes is " + count); } }); }
public LatencySpikeMonitor(EPRuntime runtime) { String epl = "select * from OperationMeasurement(latency > 20000)"; EPStatement latencyAlert = MonitorUtil.compileDeploy(epl, runtime); latencyAlert.addListener(new LatencySpikeListener()); } }
private void processStatement(EPStatement statement) { if (statement == null) { return; } Annotation annotation = AnnotationUtil.findAnnotation(statement.getAnnotations(), KafkaOutputDefault.class); if (annotation == null) { return; } KafkaOutputDefaultListener listener = new KafkaOutputDefaultListener(runtime, statement, producer, topics); statement.addListener(listener); log.info("Added Kafka-Output-Adapter listener to statement '{}' topics {}", statement.getName(), topics.toString()); }
public static void deployAddListener(EPCompiled compiledStmt, String stmtName, UpdateListener listener, EPRuntime runtime) { try { EPDeployment deployed = runtime.getDeploymentService().deploy(compiledStmt, new DeploymentOptions().setStatementNameRuntime(ctx -> stmtName)); if (deployed.getStatements().length != 1) { throw new UnsupportedOperationException("This method is designed for a single statement"); } deployed.getStatements()[0].addListener(listener); } catch (EPDeployException e) { throw new RuntimeException(e); } }
public VariableReadWriteCallable(int threadNum, RegressionEnvironment env, int numRepeats) { this.runtime = env.runtime(); this.numRepeats = numRepeats; this.threadNum = threadNum; selectListener = new SupportUpdateListener(); String stmtText = "@name('t" + threadNum + "') select var1, var2, var3 from SupportBean_A(id='" + threadNum + "')"; env.compileDeploy(stmtText).statement("t" + threadNum).addListener(selectListener); }
public void run(RegressionEnvironment env) { SupportMTUpdateListener listenerSetOne = new SupportMTUpdateListener(); SupportMTUpdateListener listenerSetTwo = new SupportMTUpdateListener(); String stmtSetOneText = "@name('setOne') on SupportBean set var1=longPrimitive, var2=longPrimitive, var3=var3+1"; String stmtSetTwoText = "@name('setTwo')on SupportMarketDataBean set var1=volume, var2=volume, var3=var3+1"; env.compileDeploy(stmtSetOneText).statement("setOne").addListener(listenerSetOne); env.compileDeploy(stmtSetTwoText).statement("setTwo").addListener(listenerSetTwo); trySetAndReadAtomic(env, listenerSetOne, listenerSetTwo, 2, 10000); env.undeployAll(); }
private void runSubquerySample(EPRuntime runtime) { String epl = "select (select key2 from MySampleWindow where key1 = ste.triggerKey) as key2 from SampleTriggerEvent ste"; EPStatement stmt = compileDeploy(epl, runtime); SampleUpdateListener sampleListener = new SampleUpdateListener(); stmt.addListener(sampleListener); runtime.getEventService().sendEventBean(new SampleTriggerEvent("sample1"), "SampleTriggerEvent"); log.info("Subquery returned: " + sampleListener.getLastEvent().get("key2")); // For assertions against expected results please see the regression test suite }
public void run(RegressionEnvironment env) { RegressionPath path = new RegressionPath(); env.compileDeploy("@name('window') create window MyWindow#keepall as select theString, longPrimitive from SupportBean", path); SupportMTUpdateListener listenerWindow = new SupportMTUpdateListener(); env.statement("window").addListener(listenerWindow); env.compileDeploy("insert into MyWindow(theString, longPrimitive) select symbol, volume from SupportMarketDataBean", path); env.compileDeploy("on SupportBean_A as s0 delete from MyWindow as win where win.theString = s0.id", path); env.compileDeploy("@name('consumer') select irstream theString, longPrimitive from MyWindow", path); SupportMTUpdateListener listenerConsumer = new SupportMTUpdateListener(); env.statement("consumer").addListener(listenerConsumer); trySend(env, listenerWindow, listenerConsumer, 4, 1000); env.undeployAll(); }
/** * Starting this statement fires an event and the listener starts a new statement (same expression) again, * causing a loop. This listener limits to 10 - this is a smoke test. */ public void run(RegressionEnvironment env) { String patternExpr = "@name('s0') select * from pattern [not SupportBean]"; env.compileDeploy(patternExpr); env.statement("s0").addListener(new PatternUpdateListener(env)); env.undeployAll(); env.compileDeploy(patternExpr); env.undeployAll(); }
private void runJoinSample(EPRuntime runtime) { String epl = "select sw.* " + "from SampleJoinEvent#lastevent sje, MySampleWindow sw " + "where sw.key1 = sje.propOne and sw.key2 = sje.propTwo"; EPStatement stmt = compileDeploy(epl, runtime); SampleUpdateListener sampleListener = new SampleUpdateListener(); stmt.addListener(sampleListener); runtime.getEventService().sendEventBean(new SampleJoinEvent("sample1", "sample2"), "SampleJoinEvent"); // see values in SampleVirtualDataWindowIndex log.info("Join query returned: " + sampleListener.getLastEvent().get("key1") + " and " + sampleListener.getLastEvent().get("key2")); // For assertions against expected results please see the regression test suite }
public void run(RegressionEnvironment env) { String epl = "@name('s0') select * from pattern[every tag=SupportBean]"; env.compileDeploy(epl); SingleRouteUpdateListener listener = new SingleRouteUpdateListener(env.runtime()); env.statement("s0").addListener(listener); // Send first event that triggers the loop sendEvent(env.runtime(), 0); // Should have fired X times assertEquals(1000, listener.getCount()); env.undeployAll(); } }
public void run(RegressionEnvironment env) { env.compileDeploy("@name('s0') select * from SupportBean"); MyListener listener = new MyListener(); env.statement("s0").addListener(listener); env.sendEventBean(new SupportBean()); assertEquals(TEST_SECRET_VALUE, listener.getSecretValue()); env.undeployAll(); } }