public StmtNamedWindowUpdateCallable(String threadName, EPRuntime runtime, int numRepeats) { this.runtime = (EPEventServiceSPI) runtime.getEventService(); this.numRepeats = numRepeats; this.threadName = threadName; }
public static EPDeployment deploy(EPCompiled compiledStmt, EPRuntime runtime) { try { return runtime.getDeploymentService().deploy(compiledStmt); } catch (EPDeployException e) { throw new RuntimeException(e); } }
public String runtimeURI() { return runtime.getURI(); }
public EPCompiled reflectiveCompile(String epl) { return provider.reflectiveCompile(epl, runtime.getConfigurationDeepCopy(), runtime.getRuntimePath()); }
private static EPDeployment createStmt(EPRuntime runtime, String epl) { try { Configuration configuration = runtime.getConfigurationDeepCopy(); CompilerArguments args = new CompilerArguments(configuration); args.getPath().add(runtime.getRuntimePath()); EPCompiled compiled = EPCompilerProvider.getCompiler().compile(epl, args); return runtime.getDeploymentService().deploy(compiled); } catch (Exception ex) { throw new RuntimeException(ex); } } }
public void run(Configuration config) { SupportRuntimeStateListener listener = new SupportRuntimeStateListener(); EPRuntime runtime = EPRuntimeProvider.getRuntime(this.getClass().getSimpleName() + "__listenerstatechange", config); runtime.addRuntimeStateListener(listener); runtime.destroy(); assertSame(runtime, listener.assertOneGetAndResetDestroyedEvents()); runtime.initialize(); assertSame(runtime, listener.assertOneGetAndResetInitializedEvents()); runtime.removeAllRuntimeStateListeners(); runtime.initialize(); assertTrue(listener.getInitializedEvents().isEmpty()); runtime.addRuntimeStateListener(listener); SupportRuntimeStateListener listenerTwo = new SupportRuntimeStateListener(); runtime.addRuntimeStateListener(listenerTwo); runtime.initialize(); assertSame(runtime, listener.assertOneGetAndResetInitializedEvents()); assertSame(runtime, listenerTwo.assertOneGetAndResetInitializedEvents()); assertTrue(runtime.removeRuntimeStateListener(listener)); runtime.initialize(); assertSame(runtime, listenerTwo.assertOneGetAndResetInitializedEvents()); assertTrue(listener.getInitializedEvents().isEmpty()); runtime.destroy(); } }
String runtimeURI = MultithreadStmtPatternFollowedBy.class.getSimpleName() + "_" + profile; EPRuntime runtime = EPRuntimeProvider.getRuntime(runtimeURI, config); runtime.initialize(); int[] threadTwoValues = new int[]{1, 3, 5, 7, 9}; Thread threadOne = new Thread(new SenderRunnable(runtime.getEventService(), threadOneValues), MultithreadStmtPatternFollowedBy.class.getSimpleName() + "-one"); Thread threadTwo = new Thread(new SenderRunnable(runtime.getEventService(), threadTwoValues), MultithreadStmtPatternFollowedBy.class.getSimpleName() + "-two"); runtime.getDeploymentService().undeploy(stmts[j].getDeploymentId()); } catch (EPUndeployException e) { throw new RuntimeException(e); runtime.destroy();
private EPStatement compileDeploy(String expression, String statementName) { try { CompilerArguments args = new CompilerArguments(runtime.getRuntimePath()); EPCompiled compiled = EPCompilerProvider.getCompiler().compile(expression, args); DeploymentOptions options = new DeploymentOptions(); options.setStatementNameRuntime(env -> statementName); return runtime.getDeploymentService().deploy(compiled, options).getStatements()[0]; } catch (Exception ex) { throw new RuntimeException("Failed to compile and deploy: " + ex.getMessage(), ex); } } }
public void run(Configuration configuration) { configuration.getRuntime().getExceptionHandling().getHandlerFactories().clear(); configuration.getCompiler().addPlugInAggregationFunctionForge("myinvalidagg", SupportInvalidAggregationFunctionForge.class.getName()); configuration.getCommon().addEventType(SupportBean.class); EPRuntime runtime = EPRuntimeProvider.getRuntime(ClientRuntimeExceptionHandlerNoHandler.class.getName(), configuration); String epl = "@Name('ABCName') select myinvalidagg() from SupportBean"; EPDeployment deployment; try { EPCompiled compiled = EPCompilerProvider.getCompiler().compile(epl, new CompilerArguments(configuration)); deployment = runtime.getDeploymentService().deploy(compiled); } catch (Throwable t) { throw new RuntimeException(t); } runtime.getEventService().sendEventBean(new SupportBean(), "SupportBean"); runtime.destroy(); } }
public void run(Configuration config) { config.getRuntime().getThreading().setInternalTimerEnabled(true); config.getCommon().getTimeSource().setTimeUnit(TimeUnit.MICROSECONDS); try { EPRuntimeProvider.getRuntime(this.getClass().getSimpleName(), config).initialize(); fail(); } catch (ConfigurationException ex) { SupportMessageAssertUtil.assertMessage(ex, "Internal timer requires millisecond time resolution"); } config.getRuntime().getThreading().setInternalTimerEnabled(false); EPRuntime runtime = EPRuntimeProvider.getRuntime(this.getClass().getSimpleName(), config); try { runtime.getEventService().clockInternal(); fail(); } catch (EPException ex) { SupportMessageAssertUtil.assertMessage(ex, "Internal timer requires millisecond time resolution"); } runtime.destroy(); } }
runtime.initialize(); runtime.getEventService().sendEventMap(theEvent, "SensorEvent"); args.getPath().add(runtime.getRuntimePath()); EPCompiled onDemandQueryCompiled; try { EPFireAndForgetPreparedQuery onDemandQuery = runtime.getFireAndForgetService().prepareQuery(onDemandQueryCompiled); queryParams.put("querytemp", sampleTemperature); runtime.getEventService().sendEventMap(queryParams, "SensorQueryEvent"); log.info("Executing on-select query " + numOnEventQueryExecutions + " times took " + deltaSec + " seconds"); runtime.destroy();
EPDeploymentService adminOne = runtimeOne.getDeploymentService(); runtimeOne.destroy(); EPAssertionUtil.assertNotContains(EPRuntimeProvider.getRuntimeURIs(), uriOne); EPAssertionUtil.assertContains(EPRuntimeProvider.getRuntimeURIs(), uriTwo); assertNull(EPRuntimeProvider.getExistingRuntime(uriOne)); assertTrue(runtimeOne.isDestroyed()); assertFalse(runtimeTwo.isDestroyed()); runtimeTwo.destroy(); EPAssertionUtil.assertNotContains(EPRuntimeProvider.getRuntimeURIs(), uriOne, uriTwo); assertNull(EPRuntimeProvider.getExistingRuntime(uriTwo)); assertTrue(runtimeOne.isDestroyed()); assertTrue(runtimeTwo.isDestroyed()); runtimeTwo.getEventService(); fail(); } catch (EPRuntimeDestroyedException ex) { runtimeTwo.getDeploymentService(); fail(); } catch (EPRuntimeDestroyedException ex) {
TicksPerSecondStatement tickPerSecStmt = new TicksPerSecondStatement(runtime.getDeploymentService(), configuration); tickPerSecStmt.addListener(new RateReportingListener()); TicksFalloffStatement falloffStmt = new TicksFalloffStatement(runtime.getDeploymentService(), configuration, runtime.getRuntimePath()); falloffStmt.addListener(new RateFalloffAlertListener()); runtime.destroy();
public void run(Configuration configuration) { configuration.getRuntime().getThreading().setInternalTimerEnabled(false); configuration.getCommon().addEventType(SupportBean.class); EPRuntime runtime = EPRuntimeProvider.getRuntime(ClientRuntimeTimeControlClockType.class.getSimpleName(), configuration); runtime.getEventService().advanceTime(0); assertEquals(0, runtime.getEventService().getCurrentTime()); assertTrue(runtime.getEventService().isExternalClockingEnabled()); runtime.getEventService().clockInternal(); assertFalse(runtime.getEventService().isExternalClockingEnabled()); long waitStart = System.currentTimeMillis(); while (System.currentTimeMillis() - waitStart < 10000) { if (runtime.getEventService().getCurrentTime() > 0) { break; } } assertNotEquals(0, runtime.getEventService().getCurrentTime()); assertTrue(System.currentTimeMillis() > runtime.getEventService().getCurrentTime() - 10000); runtime.getEventService().clockExternal(); assertTrue(runtime.getEventService().isExternalClockingEnabled()); runtime.getEventService().advanceTime(0); threadSleep(500); assertEquals(0, runtime.getEventService().getCurrentTime()); runtime.destroy(); } }
runtime.initialize(); runtime.getEventService().sendEventBean(theEvent, theEvent.getClass().getSimpleName());
producer = new KafkaProducer<>(context.getProperties()); } catch (Throwable t) { log.error("Error obtaining Kafka producer for URI '{}': {}", context.getRuntime().getURI(), t.getMessage(), t); String[] deploymentIds = context.getRuntime().getDeploymentService().getDeployments(); for (String depoymentId : deploymentIds) { EPStatement[] statements = context.getRuntime().getDeploymentService().getDeployment(depoymentId).getStatements(); for (EPStatement statement : statements) { processStatement(statement); runtime.getDeploymentService().addDeploymentStateListener(new DeploymentStateListener() { public void onDeployment(DeploymentStateEventDeployed event) { for (EPStatement statement : event.getStatements()) {
runtime.initialize(); runtime.getDeploymentService().getStatement(deployed.getDeploymentId(), "out").addListener(listener); runtime.destroy();
runtime.initialize(); runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("trivia")); } catch (Exception e) { throw new RuntimeException("Error compiling and deploying EPL from 'trivia.epl': " + e.getMessage(), e);
public void registerStatement(String epl, Object userObject) { // Compile statement. We simply use the provided configuration. CompilerArguments args = new CompilerArguments(runtime.getConfigurationDeepCopy()); args.getConfiguration().getCompiler().getByteCode().setAllowSubscriber(true); // using subcribers EPCompiled compiled; try { compiled = EPCompilerProvider.getCompiler().compile(epl, args); } catch (EPCompileException e) { throw new RuntimeException("Failed to compile: " + e.getMessage(), e); } EPStatement stmt; try { stmt = runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setStatementUserObjectRuntime(ctx -> userObject)).getStatements()[0]; } catch (EPDeployException e) { throw new RuntimeException("Failed to deploy: " + e.getMessage(), e); } if (System.getProperty("esper.benchmark.ul") != null) { stmt.addListener(updateListener); } else { stmt.setSubscriber(subscriber); } }
public void run(RegressionEnvironment env) { // Assure destroy order ESPER-489 Assert.assertEquals(2, SupportPluginLoader.getNames().size()); Assert.assertEquals(2, SupportPluginLoader.getPostInitializes().size()); Assert.assertEquals("MyLoader", SupportPluginLoader.getNames().get(0)); Assert.assertEquals("MyLoader2", SupportPluginLoader.getNames().get(1)); Assert.assertEquals("val", SupportPluginLoader.getProps().get(0).get("name")); Assert.assertEquals("val2", SupportPluginLoader.getProps().get(1).get("name2")); Object loader = getFromEnv(env, "plugin-loader/MyLoader"); assertTrue(loader instanceof SupportPluginLoader); loader = getFromEnv(env, "plugin-loader/MyLoader2"); assertTrue(loader instanceof SupportPluginLoader); SupportPluginLoader.getPostInitializes().clear(); SupportPluginLoader.getNames().clear(); env.runtime().initialize(); Assert.assertEquals(2, SupportPluginLoader.getPostInitializes().size()); Assert.assertEquals(2, SupportPluginLoader.getNames().size()); env.runtime().destroy(); Assert.assertEquals(2, SupportPluginLoader.getDestroys().size()); Assert.assertEquals("val2", SupportPluginLoader.getDestroys().get(0).get("name2")); Assert.assertEquals("val", SupportPluginLoader.getDestroys().get(1).get("name")); SupportPluginLoader.reset(); }