public static EPDeployment deploy(EPCompiled compiledStmt, EPRuntime runtime) { try { return runtime.getDeploymentService().deploy(compiledStmt); } catch (EPDeployException e) { throw new RuntimeException(e); } }
public void destroy() { if (main != null) { try { EPRuntimeProvider.getRuntime(runtimeURI).getDeploymentService().undeployAll(); } catch (EPUndeployException e) { log.warn("Failed to undeploy: " + e.getMessage(), e); } } log.info("OHLCSample-example stopped."); } }
public RegressionEnvironment undeploy(String deploymentId) { try { runtime.getDeploymentService().undeploy(deploymentId); } catch (EPUndeployException ex) { throw notExpected(ex); } return this; }
public void traverseStatements(BiConsumer<EPDeployment, EPStatement> consumer) { for (String deploymentId : getDeploymentService().getDeployments()) { EPDeployment deployment = getDeploymentService().getDeployment(deploymentId); if (deployment == null) { continue; } for (EPStatement stmt : deployment.getStatements()) { consumer.accept(deployment, stmt); } } }
public void destroy(String statementName) { log.info("Via Java Management JMX proxy: Destroying statement '" + statementName + "'"); for (String deploymentId : runtime.getDeploymentService().getDeployments()) { EPDeployment deployment = runtime.getDeploymentService().getDeployment(deploymentId); for (EPStatement stmt : deployment.getStatements()) { if (statementName.equals(stmt.getName())) { try { runtime.getDeploymentService().undeploy(deploymentId); } catch (EPUndeployException e) { log.warn("Failed to undeploy: " + e.getMessage()); } } } } }
public synchronized void open(DataFlowOpOpenContext openContext) { // start observing statement management EPRuntimeSPI spi = (EPRuntimeSPI) agentInstanceContext.getRuntime(); spi.getDeploymentService().addDeploymentStateListener(this); if (statementDeploymentId != null && statementName != null) { EPStatement stmt = spi.getDeploymentService().getStatement(statementDeploymentId, statementName); if (stmt != null) { addStatement(stmt); } } else { String[] deployments = spi.getDeploymentService().getDeployments(); for (String deploymentId : deployments) { EPDeployment info = spi.getDeploymentService().getDeployment(deploymentId); if (info == null) { continue; } for (EPStatement stmt : info.getStatements()) { if (statementFilter.pass(toContext(stmt))) { addStatement(stmt); } } } } }
try { EPCompiled compiled = EPCompilerProvider.getCompiler().compile(epl, new CompilerArguments(runtime.getRuntimePath())); deployed = runtime.getDeploymentService().deploy(compiled); } catch (Exception ex) { throw new RuntimeException(ex); EPStatement stmtCount = runtime.getDeploymentService().getStatement(deployed.getDeploymentId(), "count"); stmtCount.addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { EPStatement stmtAlert = runtime.getDeploymentService().getStatement(deployed.getDeploymentId(), "out"); stmtAlert.addListener(listener);
public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { isCalled = true; try { // create statement for thread - this can be called multiple times as other threads send SupportBean EPDeployment deployment; try { deployment = env.runtime().getDeploymentService().deploy(compiled); } catch (EPDeployException e) { throw new RuntimeException(e); } SupportMTUpdateListener listener = new SupportMTUpdateListener(); deployment.getStatements()[0].addListener(listener); Object theEvent = new SupportMarketDataBean("", 0, (long) numThread, null); env.sendEventBean(theEvent, theEvent.getClass().getSimpleName()); env.runtime().getDeploymentService().undeploy(deployment.getDeploymentId()); EventBean[] eventsReceived = listener.getNewDataListFlattened(); boolean found = false; for (int i = 0; i < eventsReceived.length; i++) { if (eventsReceived[i].getUnderlying() == theEvent) { found = true; } } Assert.assertTrue(found); } catch (Throwable t) { lastException = t; } }
EPDeployment deployed; try { deployed = env.deployment().deploy(compiled); } catch (EPDeployException e) { throw new RuntimeException(e); EPDeployment deplomentInfo = env.deployment().getDeployment(deployed.getDeploymentId()); assertEquals("regression.test", deplomentInfo.getModuleName()); assertEquals(2, deplomentInfo.getStatements().length); env.deploy(compiledTwo); String[] deploymentIds = env.deployment().getDeployments(); assertEquals(2, deploymentIds.length); infoList.add(env.deployment().getDeployment(deploymentIds[i]));
public void run(RegressionEnvironment env) { EPCompiled compiled = env.readCompile("regression/test_module_9.epl"); EPDeployment result; try { result = env.runtime().getDeploymentService().deploy(compiled); } catch (EPDeployException ex) { throw new RuntimeException(ex); } assertTrue(env.runtime().getDeploymentService().isDeployed(result.getDeploymentId())); assertNotNull(result.getDeploymentId()); assertEquals(2, result.getStatements().length); assertEquals(1, env.deployment().getDeployments().length); assertEquals("@Name(\"StmtOne\")" + NEWLINE + "create schema MyEvent(id String, val1 int, val2 int)", env.statement("StmtOne").getProperty(StatementProperty.EPL)); assertEquals("@Name(\"StmtTwo\")" + NEWLINE + "select * from MyEvent", env.statement("StmtTwo").getProperty(StatementProperty.EPL)); assertEquals(0, result.getDeploymentIdDependencies().length); env.undeployAll(); assertFalse(env.runtime().getDeploymentService().isDeployed(result.getDeploymentId())); } }
public static Map<String, Integer> getScores(EPRuntime runtime) { EPStatement stmt = runtime.getDeploymentService().getStatement("trivia", "Score window"); Map<String, Integer> result = new LinkedHashMap<String, Integer>(); for (Iterator<EventBean> it = stmt.iterator(); it.hasNext(); ) { EventBean next = it.next(); String playerId = (String) next.get("playerId"); Integer score = (Integer) next.get("score"); result.put(playerId, score); } return result; }
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()) {
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 RegressionEnvironment undeployModuleContaining(String statementName) { String[] deployments = runtime.getDeploymentService().getDeployments(); try { for (String deployment : deployments) { EPDeployment info = runtime.getDeploymentService().getDeployment(deployment); for (EPStatement stmt : info.getStatements()) { if (stmt.getName().equals(statementName)) { runtime.getDeploymentService().undeploy(deployment); return this; } } } } catch (EPUndeployException ex) { throw notExpected(ex); } fail("Failed to find deployment with statement '" + statementName + "'"); return this; }
private static void assertRowsNamedWindow(RegressionEnvironment env, String deploymentId, String ident) { EPAssertionUtil.assertPropsPerRow(env.runtime().getDeploymentService().getStatement(deploymentId, "create").iterator(), "col1,myident".split(","), new Object[][]{{"E1", ident}, {"E2", ident}}); } }
public static String getFilterAll(EPRuntime runtime) { String[] deployments = runtime.getDeploymentService().getDeployments(); Set<Integer> statements = new HashSet<>(); for (String deployment : deployments) { EPDeployment info = runtime.getDeploymentService().getDeployment(deployment); for (EPStatement statement : info.getStatements()) { EPStatementSPI spi = (EPStatementSPI) statement; statements.add(spi.getStatementId()); } } FilterServiceSPI filterService = ((EPRuntimeSPI) runtime).getServicesContext().getFilterService(); Map<EventTypeIdPair, Map<Integer, List<FilterItem[]>>> pairs = filterService.get(statements); return pairs.toString(); } }
private EPDeployment tryDeploy(EPCompiled compiled) { try { return runtime.getDeploymentService().deploy(compiled); } catch (EPDeployException ex) { throw notExpected(ex); } }
runtime.getDeploymentService().deploy(compiled, new DeploymentOptions().setDeploymentId("assetmonitor")); } catch (EPDeployException ex) { throw new RuntimeException("Failed to deploy: " + ex.getMessage(), ex); EPStatement output = runtime.getDeploymentService().getStatement("assetmonitor", "out"); AssetZoneSplitListener listener = new AssetZoneSplitListener(); output.addListener(new AssetZoneSplitListener());
public void destroy() { if (main != null) { try { EPRuntimeProvider.getRuntime(runtimeURI).getDeploymentService().undeployAll(); } catch (EPUndeployException e) { log.warn("Failed to undeploy: " + e.getMessage(), e); } } try { simulationThread.interrupt(); simulationThread.join(); } catch (InterruptedException e) { log.info("Interrupted", e); } main = null; log.info("StockTicker-example stopped."); } }