private static void resolveAssertionService(EPRuntime epServiceProvider) { String provider = System.getProperty(PROVIDER_PROPERTY); if (provider == null) { throw new RuntimeException("Failed to find '" + PROVIDER_PROPERTY + "' system property"); } EPRuntimeSPI spi = (EPRuntimeSPI) epServiceProvider; assertionService = (InstrumentationAssertionService) JavaClassHelper.instantiate(InstrumentationAssertionService.class, provider, spi.getServicesContext().getClassForNameProvider()); } }
private EPDeployment compileDeploySubscription(EPRuntimeSPI runtime, String eventTypeName, String name) { try { String epl = "@name('" + name + "') select * from " + eventTypeName; CompilerArguments args = new CompilerArguments(runtime.getConfigurationDeepCopy()); args.getPath().add(runtime.getRuntimePath()); EPCompiled compiled = EPCompilerProvider.getCompiler().compile(epl, args); return runtime.getDeploymentService().deploy(compiled); } catch (Exception ex) { throw new EPException("Failed to compile and deploy subscription: " + ex.getMessage(), ex); } }
public void setRuntime(EPRuntime runtime) { if (runtime == null) { throw new NullPointerException("runtime cannot be null"); } if (!(runtime instanceof EPRuntimeSPI)) { throw new IllegalArgumentException("Invalid type of runtime"); } EPRuntimeSPI spi = (EPRuntimeSPI) runtime; processEvent = spi.getEventService(); schedulingService = spi.getServicesContext().getSchedulingService(); sender.setRuntime(processEvent); }
epRuntime, eventRenderer, epRuntime.getEventServiceSPI(), (EPEventServiceSPI) epRuntime.getEventService(), eventBeanService, eventBeanTypedEventFactory,
public void setUpdateListeners(EPStatementListenerSet updateListeners, boolean isRecovery) { // indicate that listeners were updated for potential persistence of listener set, once the statement context is known if (epStatement != null) { if (!isRecovery) { StatementContext stmtCtx = epStatement.getStatementContext(); epServicesContext.getEpServicesHA().getListenerRecoveryService().put(stmtCtx.getStatementId(), stmtCtx.getStatementName(), updateListeners.getListeners()); } } this.statementListenerSet = updateListeners; isMakeNatural = statementListenerSet.getSubscriber() != null; isMakeSynthetic = !(statementListenerSet.getListeners().length == 0) || statementInformationals.isAlwaysSynthesizeOutputEvents(); if (statementListenerSet.getSubscriber() == null) { statementResultNaturalStrategy = null; isMakeNatural = false; return; } try { statementResultNaturalStrategy = ResultDeliveryStrategyFactory.create(epStatement, statementListenerSet.getSubscriber(), statementListenerSet.getSubscriberMethodName(), selectClauseTypes, selectClauseColumnNames, runtime.getURI(), runtime.getServicesContext().getClasspathImportServiceRuntime()); isMakeNatural = true; } catch (ResultDeliveryStrategyInvalidException ex) { throw new EPSubscriberException(ex.getMessage(), ex); } }
public void destroy() throws EPException { if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) { log.debug(".destroy"); } for (String deployment : deploymentIds) { try { spi.getDeploymentService().undeploy(deployment); } catch (EPUndeployException e) { throw new EPException("Failed to undeploy: " + e.getMessage(), e); } } stateManager.destroy(); }
private void handleObject(Object input) { try { if (input instanceof Map) { Map map = (Map) input; String type = (String) map.get("stream"); if (type == null) { log.warn("Expected value for event type not found in map event provided to adapter"); return; } runtime.getEventService().sendEventMap(map, type); } else { runtime.getEventService().sendEventBean(input, input.getClass().getSimpleName()); } } catch (Throwable t) { log.error("Unexpected exception encountered sending event " + input + " service '" + serviceName + "' :" + t.getMessage(), t); } }
private void handle(Map<String, String> parameters) { String eventTypeName = parameters.get("stream"); EsperHttpRequestCacheEntry cacheEntry = streamCache.get(eventTypeName); if (cacheEntry == null) { cacheEntry = makeCacheEntry(eventTypeName); streamCache.put(eventTypeName, cacheEntry); } if (cacheEntry == null) { return; } Object[] values = new Object[cacheEntry.getParsers().length]; for (int i = 0; i < cacheEntry.getParsers().length; i++) { String value = parameters.get(cacheEntry.getWritableProperties()[i].getPropertyName()); if (value == null) { continue; } values[i] = cacheEntry.getParsers()[i].parse(value); } EventBean theEvent = cacheEntry.getEventBeanManufacturer().make(values); runtime.getEventServiceSPI().processWrappedEvent(theEvent); }
public ExprNode compileFilterExpression(String filterExpression) { try { return runtimeSPI.getReflectiveCompileSvc().reflectiveCompileExpression(filterExpression, new EventType[]{statementRowType}, new String[]{statementRowType.getName()}); } catch (Throwable t) { throw new EPException("Failed to compiler filter: " + t.getMessage(), t); } }
if (theEvent instanceof Node) { Node node = (Node) theEvent; runtime.getEventService().sendEventXMLDOM(node, node.getNodeName()); } else if (theEvent instanceof EventBean) { runtime.getEventServiceSPI().processWrappedEvent((EventBean) theEvent); } else { runtime.getEventServiceSPI().sendEventBean(theEvent, theEvent.getClass().getSimpleName());
/** * Destroy the adapter. */ public synchronized void destroy() { if (log.isDebugEnabled()) { log.debug("Destroying Esper HTTP Adapter"); } EPRuntimeSPI runtime = (EPRuntimeSPI) EPRuntimeProvider.getRuntime(runtimeURI); for (String deployment : deployments) { try { runtime.getDeploymentService().undeploy(deployment); } catch (EPUndeployException e) { throw new EPException("Failed to undeploy: " + e.getMessage(), e); } } for (EsperHttpServiceBase service : services.values()) { try { service.destroy(); } catch (Throwable t) { log.info("Error destroying service '" + service.getServiceName() + "' :" + t.getMessage()); } } services.clear(); }
public void start() throws EPException { if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) { log.debug(".start"); } if (runtime.getEventService() == null) { throw new EPException( "Attempting to start an Adapter that hasn't had the runtime provided"); } startTime = System.currentTimeMillis(); if (log.isDebugEnabled()) { log.debug(".start startTime==" + startTime); } stateManager.start(); }
runtime.getEventServiceSPI().processWrappedEvent(theEvent); } catch (Throwable t) { log.error("Unexpected exception encountered sending event " + input + " service '" + serviceName + "' :" + t.getMessage(), t);
public void run(RegressionEnvironment env) { env.compileDeploy( "@public create window MyWindow#keepall as SupportBean;\n" + "insert into MyWindow select * from SupportBean;\n"); env.sendEventBean(new SupportBean("E1", 10)); EPRuntimeSPI spi = (EPRuntimeSPI) env.runtime(); EPRuntimeCompileReflectiveSPI svc = spi.getReflectiveCompileSvc(); assertTrue(svc.isCompilerAvailable()); EPCompiled compiledFAF = svc.reflectiveCompileFireAndForget("select * from MyWindow"); EPFireAndForgetQueryResult result = env.runtime().getFireAndForgetService().executeQuery(compiledFAF); EPAssertionUtil.assertPropsPerRow(result.iterator(), new String[]{"theString"}, new Object[][]{{"E1"}}); EPCompiled compiledFromEPL = svc.reflectiveCompile("@name('s0') select * from MyWindow"); env.deploy(compiledFromEPL); EPAssertionUtil.assertPropsPerRow(env.iterator("s0"), new String[]{"theString"}, new Object[][]{{"E1"}}); Module module = new Module(); module.getItems().add(new ModuleItem("@name('s1') select * from MyWindow")); EPCompiled compiledFromModule = svc.reflectiveCompile(module); env.deploy(compiledFromModule); EPAssertionUtil.assertPropsPerRow(env.iterator("s1"), new String[]{"theString"}, new Object[][]{{"E1"}}); ExprNode node = svc.reflectiveCompileExpression("1*1", null, null); assertEquals(1, node.getForge().getExprEvaluator().evaluate(null, true, null)); EPStatementObjectModel model = spi.getReflectiveCompileSvc().reflectiveEPLToModel("select * from MyWindow"); assertNotNull(model); Module moduleParsed = spi.getReflectiveCompileSvc().reflectiveParseModule("select * from MyWindow"); assertEquals(1, moduleParsed.getItems().size()); assertEquals("select * from MyWindow", moduleParsed.getItems().get(0).getExpression()); env.undeployAll(); } }
private static void resolveAssertionService(EPRuntime runtime) { String provider = System.getProperty(PROVIDER_PROPERTY); if (provider == null) { throw new RuntimeException("Failed to find '" + PROVIDER_PROPERTY + "' system property"); } if (provider.toLowerCase(Locale.ENGLISH).trim().equals("default")) { assertionService = new DefaultInstrumentationAssertionService(); } else { EPRuntimeSPI spi = (EPRuntimeSPI) runtime; assertionService = (InstrumentationAssertionService) JavaClassHelper.instantiate(InstrumentationAssertionService.class, provider, spi.getServicesContext().getClasspathImportServiceRuntime().getClassForNameProvider()); } }
private EPDeployment compileDeploySubscription(EPRuntimeSPI runtime, String eventTypeName, String name) { try { String epl = "@name('" + name + "') select * from " + eventTypeName; CompilerArguments args = new CompilerArguments(runtime.getConfigurationDeepCopy()); args.getPath().add(runtime.getRuntimePath()); EPCompiled compiled = EPCompilerProvider.getCompiler().compile(epl, args); return runtime.getDeploymentService().deploy(compiled); } catch (Exception ex) { throw new EPException("Failed to compile and deploy subscription: " + ex.getMessage(), ex); } } }
public void setRuntime(EPRuntime runtime) { if (runtime == null) { throw new NullPointerException("runtime cannot be null"); } if (!(runtime instanceof EPRuntimeSPI)) { throw new IllegalArgumentException("Invalid type of runtime"); } EPRuntimeSPI spi = (EPRuntimeSPI) runtime; processEvent = spi.getEventService(); schedulingService = spi.getServicesContext().getSchedulingService(); sender.setRuntime(processEvent); }
/** * Destroy the adapter. */ public synchronized void destroy() { if (log.isDebugEnabled()) { log.debug("Destroying Esper DB Adapter"); } EPRuntimeSPI runtime = (EPRuntimeSPI) EPRuntimeProvider.getRuntime(runtimeURI); for (String deployment : deployments) { try { runtime.getDeploymentService().undeploy(deployment); } catch (EPUndeployException e) { throw new EPException("Failed to undeploy: " + e.getMessage(), e); } } executorFactory.destroy(); } }
public void start() throws EPException { if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) { log.debug(".start"); } if (spi.getEventService() == null) { throw new EPException("Attempting to start an Adapter that hasn't had the runtime provided"); } startTime = System.currentTimeMillis(); if ((ExecutionPathDebugLog.isDebugEnabled) && (log.isDebugEnabled())) { log.debug(".start startTime==" + startTime); } stateManager.start(); Iterator<Map.Entry<String, JMSSubscription>> it = subscriptionMap.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, JMSSubscription> sub = it.next(); JMSSubscription destination = sub.getValue(); destination.setJMSOutputAdapter(this); EPDeployment deployment = compileDeploySubscription(spi, sub.getValue().getEventTypeName(), this.getClass().getSimpleName() + "-" + sub.getKey()); deployment.getStatements()[0].addListener(new UpdateListener() { public void update(EventBean[] newEvents, EventBean[] oldEvents, EPStatement statement, EPRuntime runtime) { if (newEvents == null) { return; } for (EventBean event : newEvents) { destination.process(event); } } }); } }
private static DeploymentInternal deploy(boolean recovery, String deploymentId, int statementIdFirstStatement, EPCompiled compiled, StatementNameRuntimeOption statementNameResolverRuntime, StatementUserObjectRuntimeOption userObjectResolverRuntime, StatementSubstitutionParameterOption substitutionParameterResolver, EPRuntimeSPI epRuntime) throws EPDeployException { // set variable local version epRuntime.getServicesContext().getVariableManagementService().setLocalVersion(); try { return deploySafe(recovery, deploymentId, statementIdFirstStatement, compiled, statementNameResolverRuntime, userObjectResolverRuntime, substitutionParameterResolver, epRuntime); } catch (EPDeployException ex) { throw ex; } catch (Throwable t) { throw new EPDeployException(t.getMessage(), t); } }