private static void deployWithResolver(RegressionEnvironment env, EPCompiled compiled, String statementName, StatementSubstitutionParameterOption resolver) { DeploymentOptions options = new DeploymentOptions().setStatementSubstitutionParameter(resolver); options.setStatementNameRuntime(context -> statementName); try { env.deployment().deploy(compiled, options); } catch (EPDeployException e) { throw new RuntimeException(e); } }
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); } }
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); } } }
for (int i = 0; i < countStatements; i++) { final String stmtName = "s" + i; env.deploy(compiled, new DeploymentOptions().setStatementNameRuntime(ctx -> stmtName)); env.statement(stmtName).addListener(listener);
String stmtName = "c" + i; try { env.deployment().deploy(compiled, new DeploymentOptions().setStatementNameRuntime(ctx -> stmtName)); } catch (EPDeployException e) { throw new RuntimeException(e);
public void run(RegressionEnvironment env) { EPCompiled compiled = env.compile("select * from SupportBean;select * from SupportBean;"); try { env.deployment().deploy(compiled, new DeploymentOptions().setStatementNameRuntime(new StatementNameRuntimeOption() { public String getStatementName(StatementNameRuntimeContext env) { return "x"; } })); fail(); } catch (EPDeployException e) { assertMessage(e, "Duplicate statement name provide by statement name resolver for statement name 'x'"); } } }
private static EPStatement[] createStmts(RegressionEnvironment env, String[] deploymentIds, String[] statementNames) { assertEquals(deploymentIds.length, statementNames.length); EPStatement[] statements = new EPStatement[statementNames.length]; EPCompiled compiled = env.compile("select * from SupportBean"); for (int i = 0; i < statementNames.length; i++) { final int num = i; try { EPDeployment deployed = env.deployment().deploy(compiled, new DeploymentOptions().setDeploymentId(deploymentIds[i]).setStatementNameRuntime(new StatementNameRuntimeOption() { public String getStatementName(StatementNameRuntimeContext env) { return statementNames[num]; } })); statements[i] = deployed.getStatements()[0]; } catch (EPDeployException e) { throw new RuntimeException(e); } } return statements; } }
for (int i = 0; i < countStatements; i++) { final String stmtName = "s" + i; env.deploy(compiled, new DeploymentOptions().setStatementNameRuntime(ctx -> stmtName)); env.statement(stmtName).addListener(listener);
public void run(RegressionEnvironment env) { env.advanceTime(0); String text = "select rstream theString from SupportBean#time(?::int)"; EPCompiled compiled = env.compile(text); env.deploy(compiled, new DeploymentOptions() .setStatementSubstitutionParameter(prepared -> prepared.setObject(1, 4)) .setStatementNameRuntime(ctx -> "s0")); env.deploy(compiled, new DeploymentOptions() .setStatementSubstitutionParameter(prepared -> prepared.setObject(1, 3)) .setStatementNameRuntime(ctx -> "s1")); env.addListener("s0").addListener("s1"); runAssertion(env); env.undeployAll(); } }
for (int i = 0; i < numEvents; i++) { String stmtName = "p" + i; env.deploy(compiled, new DeploymentOptions().setStatementNameRuntime(ctx -> stmtName)); EPStatement stmt = env.statement(stmtName); listener[i] = new SupportMTUpdateListener();
public void run(RegressionEnvironment env) { EPCompiled compiled = env.compile("expression myindex {pointregionquadtree(0, 0, 100, 100)}" + "select * from SupportSpatialAABB(point(?::int, ?::int, filterindex:myindex).inside(rectangle(x, y, width, height)))"); SupportUpdateListener listener = new SupportUpdateListener(); int count = 0; for (int x = 0; x < 10; x++) { for (int y = 0; y < 10; y++) { int finalX = x; int finalY = y; String name = x + "_" + y; DeploymentOptions options = new DeploymentOptions().setStatementSubstitutionParameter(prepared -> { prepared.setObject(1, finalX); prepared.setObject(2, finalY); }).setStatementNameRuntime(ctx -> name); env.deploy(compiled, options).statement(name).addListener(listener); // System.out.println("Deployed #" + count); count++; } } sendAssertSpatialAABB(env, listener, 10, 10, 1000); env.undeployAll(); } }
public void run(RegressionEnvironment env) { MyStatementNameRuntimeResolver.getContexts().clear(); String epl = "@name('s0') select * from SupportBean"; EPCompiled compiled = env.compile(epl); DeploymentOptions options = new DeploymentOptions(); options.setStatementNameRuntime(new MyStatementNameRuntimeResolver()); try { env.deployment().deploy(compiled, options); } catch (EPDeployException e) { fail(e.getMessage()); } StatementNameRuntimeContext ctx = MyStatementNameRuntimeResolver.getContexts().get(0); assertEquals("s0", ctx.getStatementName()); assertEquals(env.deploymentId("hello"), ctx.getDeploymentId()); assertSame(env.statement("hello").getAnnotations(), ctx.getAnnotations()); assertEquals(epl, ctx.getEpl()); assertEquals("hello", env.statement("hello").getName()); env.milestone(0); assertEquals("hello", env.statement("hello").getName()); env.undeployAll(); } }