public static void deploy(EPRuntime runtime, EPCompiled compiled) { try { runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("stockticker")); } catch (EPDeployException ex) { throw new RuntimeException(ex); } } }
public void run(RegressionEnvironment env) { EPCompiled compiled = env.compile("select * from SupportBean"); env.deploy(compiled, new DeploymentOptions().setDeploymentId("ABC")); try { env.runtime().getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("ABC")); fail(); } catch (EPDeployDeploymentExistsException ex) { SupportMessageAssertUtil.assertMessage(ex, "Deployment by id 'ABC' already exists"); } catch (EPDeployException ex) { throw new RuntimeException(ex); } env.undeployAll(); } }
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; } }
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);
runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("assetmonitor")); } catch (EPDeployException ex) { throw new RuntimeException("Failed to deploy: " + ex.getMessage(), ex);
public CycleDetectMain() { Configuration configuration = new Configuration(); configuration.getCommon().addEventType(TransactionEvent.class); String[] functionNames = new String[]{CycleDetectorConstant.CYCLEDETECTED_NAME, CycleDetectorConstant.CYCLEOUTPUT_NAME}; ConfigurationCompilerPlugInAggregationMultiFunction config = new ConfigurationCompilerPlugInAggregationMultiFunction(functionNames, CycleDetectorAggregationForge.class.getName()); configuration.getCompiler().addPlugInAggregationMultiFunction(config); try { String eplCycleDetectEachEvent = "@Name('CycleDetector') " + "select cycleoutput() as out " + "from TransactionEvent#length(1000) " + "having cycledetected(fromAcct, toAcct)"; EPCompiled compiled = EPCompilerProvider.getCompiler().compile(eplCycleDetectEachEvent, new CompilerArguments(configuration)); runtime = EPRuntimeProvider.getDefaultRuntime(configuration); DeploymentOptions deploymentOptions = new DeploymentOptions().setDeploymentId("CycleDetect"); EPStatement stmt = runtime.getDeploymentService().deploy(compiled, deploymentOptions).getStatements()[0]; stmt.addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { for (EventBean event : newEvents) { @SuppressWarnings("unchecked") Collection<String> accts = (Collection<String>) event.get("out"); System.out.println("Cycle detected: " + accts); } } }); } catch (Exception ex) { throw new RuntimeException("Failed to deploy: " + ex.getMessage(), ex); } }
public static void setup(EPRuntime runtime, MatchAlertListener listener) { // Allocate a partition (session) that lasts for a mobile user until they sent a new event with new location String eplContext = "create context PerUser " + "initiated by MobileUserBean as mub " + "terminated by MobileUserBean(userId = mub.userId);\n"; // For each partition find a match within the location range String eplMatch = "@name('alert') context PerUser select mub as self, context.mub as other from MobileUserBean (" + "locationX in [(context.mub.locationX - 1) : (context.mub.locationX + 1)]," + "locationY in [(context.mub.locationY - 1) : (context.mub.locationY + 1)]," + "myGender = context.mub.preferredGender, " + "myAgeRange = context.mub.preferredAgeRange, " + "myHairColor = context.mub.preferredHairColor, " + "preferredGender = context.mub.myGender, " + "preferredAgeRange = context.mub.myAgeRange, " + "preferredHairColor = context.mub.myHairColor," + "userId != context.mub.userId" + ") as mub;\n"; try { EPCompiled compiled = EPCompilerProvider.getCompiler().compile(eplContext + eplMatch, new CompilerArguments(runtime.getRuntimePath())); runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("matchmaker-deployment")); } catch (Exception ex) { throw new RuntimeException(ex); } runtime.getDeploymentService().getStatement("matchmaker-deployment", "alert").addListener(listener); } }
public void run(RegressionEnvironment env) { MySubstitutionOption.getContexts().clear(); EPCompiled compiled = env.compile("@name('s0') select ?:p0:int as c0 from SupportBean"); DeploymentOptions options = new DeploymentOptions().setStatementSubstitutionParameter(new MySubstitutionOption()); options.setDeploymentId("abc"); try { env.deployment().deploy(compiled, options); fail(); } catch (EPDeployException e) { // expected } assertEquals(1, MySubstitutionOption.getContexts().size()); StatementSubstitutionParameterContext ctx = MySubstitutionOption.getContexts().get(0); assertNotNull(ctx.getAnnotations()); assertEquals("abc", ctx.getDeploymentId()); assertNotNull(ctx.getEpl()); assertTrue(ctx.getStatementId() > 0); assertEquals("s0", ctx.getStatementName()); assertEquals(Integer.class, ctx.getSubstitutionParameterTypes()[0]); assertEquals((Integer) 1, ctx.getSubstitutionParameterNames().get("p0")); } }
EPCompiled compiled = env.compile(epl); try { env.deployment().deploy(compiled, new DeploymentOptions().setDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { fail(e.getMessage()); env.deployment().deploy(compiled, new DeploymentOptions().setDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { fail(e.getMessage()); env.deployment().deploy(compiled, new DeploymentOptions().setDeploymentId("MyDeploymentId")); } catch (EPDeployException e) { fail(e.getMessage());
public void run(RegressionEnvironment env) { String epl = "@Name('flow') create dataflow MyGraph Emitter -> outstream<?> {}"; EPCompiled compiledGraph = env.compile(epl); try { env.deployment().deploy(compiledGraph, new DeploymentOptions().setDeploymentId("DEP1")); } catch (EPDeployException ex) { throw new RuntimeException(ex); } EPDataFlowService dfruntime = env.runtime().getDataFlowService(); EPAssertionUtil.assertEqualsAnyOrder(new DeploymentIdNamePair[]{new DeploymentIdNamePair(env.deploymentId("flow"), "MyGraph")}, dfruntime.getDataFlows()); EPDataFlowDescriptor desc = dfruntime.getDataFlow("DEP1", "MyGraph"); assertEquals("MyGraph", desc.getDataFlowName()); assertEquals("flow", desc.getStatementName()); dfruntime.instantiate(env.deploymentId("flow"), "MyGraph"); // stop - can no longer instantiate but still exists env.undeployModuleContaining("flow"); tryInstantiate(env, "DEP1", "MyGraph", "Data flow by name 'MyGraph' for deployment id 'DEP1' has not been defined"); tryInstantiate(env, "DEP1", "DUMMY", "Data flow by name 'DUMMY' for deployment id 'DEP1' has not been defined"); // destroy - should be gone assertEquals(null, dfruntime.getDataFlow("DEP1", "MyGraph")); assertEquals(0, dfruntime.getDataFlows().length); tryInstantiate(env, "DEP1", "MyGraph", "Data flow by name 'MyGraph' for deployment id 'DEP1' has not been defined"); // new one, try start-stop-start env.compileDeploy(epl); dfruntime.instantiate(env.deploymentId("flow"), "MyGraph"); env.undeployAll(); } }