Refine search
throw new IllegalArgumentException("The sub sessionizer referenced by EPL " + sessionizerName + " not configured."); statement.addListener(new SubSessionizerListener(sessionizerName, context)); statement.addListener(new UpdateTTLListener(context, maxTTL)); statement.addListener(new DecorateEventListener(context)); statement.addListener(new AppendStateListener(context, (String) getAnnotationValue(part, "name", null), (String) getAnnotationValue(part, "colname", null), (Boolean) getAnnotationValue(part, "unique", true), statement.addListener(new SessionStateListener(context)); statement.addListener(new SessionMetadataListener(context)); statement.addListener(new SessionCounterListener((String) part.getAttributes().get(0).getValue(), context)); String field = (String) getAnnotationValue(part, "colname", null); Boolean auditValue = (Boolean) getAnnotationValue(part, "audit", false); statement.addListener(new SessionizerCounterListener(prefix, field, auditValue, esperCounter)); statement.addListener(ext.createUpdateListener(context, part, model));
@Override public void onDelete(Trigger object) { log.debug("Destroying EPSstatement:{}",epStatement.getName()); epService.getEPAdministrator().getStatement(epStatement.getName()).destroy(); } }
/** * Removes all statements and listeners from the esper engine, */ public void removeFromEngine() { for (EPStatement epst : this.epStatements.values()) { if (logger.isDebugEnabled()) logger.debug("Removing statement: \n\t" + epst.getText()); epst.removeAllListeners(); epst.destroy(); } /* destroy this complete engine - its independent */ this.epService.destroy(); }
/** * Sets the native Esper statement. Typically created by an Esper Template. * * @param epStatement * the underlying native Esper statement * @see org.opencredo.esper.EsperTemplate */ void setEPStatement(EPStatement epStatement) { this.epStatement = epStatement; if (this.subscriber != null) { epStatement.setSubscriber(this.subscriber); } else { for (UpdateListener listener : listeners) { epStatement.addListener(listener); } } }
/** * initializes the counting listeners */ private synchronized void initializeCountingListeners() { // for every statement in the map EPStatement epStatement; CountingListener cListener; for (String statement : this.countingListeners.keySet()) { cListener = this.countingListeners.get(statement); // register statement at engine epStatement = this.epService.getEPAdministrator().createEPL( statement); // register listener at esper statement epStatement.addListener(cListener); // store epStatements this.epStatements.put(statement, epStatement); } }
@Override public void prepare(@SuppressWarnings("rawtypes") Map conf, TopologyContext context, OutputCollector collector) { this.collector = collector; Configuration configuration = new Configuration(); setupEventTypes(context, configuration); this.esperSink = EPServiceProviderManager.getProvider(this.toString(), configuration); this.esperSink.initialize(); this.runtime = esperSink.getEPRuntime(); this.admin = esperSink.getEPAdministrator(); for (String stmt : statements) { EPStatement statement = admin.createEPL(stmt); statement.addListener(this); } }
private static void enableMetrics() { EPStatement engineMetrics = epService.getEPAdministrator().createEPL("select * from com.espertech.esper.client.metric.EngineMetric"); engineMetrics.addListener(new UpdateListener() { engineMetrics.start(); EPStatement statementMetrics = epService.getEPAdministrator().createEPL("select * from com.espertech.esper.client.metric.StatementMetric"); statementMetrics.addListener(new UpdateListener() {
/** * EPL to monitor the average temperature every 10 seconds. Will call listener on every event. */ private void createTemperatureMonitorExpression() { LOG.debug("create Timed Average Monitor"); monitorEventStatement = epService.getEPAdministrator().createEPL(monitorEventSubscriber.getStatement()); monitorEventStatement.setSubscriber(monitorEventSubscriber); }
public void recreateEpl(int eplId, Epl epl) { EPStatement epStatement = eplStateMap.get(eplId); if(epStatement != null && !epStatement.isDestroyed()) { epStatement.removeAllListeners(); epStatement.destroy(); } String eplSql = epl.getEplSql(); String[] eplSqls = eplSql.trim().split(";"); for(int i = 0; i < eplSqls.length; i++) { if(!StringUtils.isBlank(eplSqls[i])) { if(i == eplSqls.length - 1) { epStatement = this.admin.createEPL(eplSqls[i].trim()); LOG.info("Add statistic epl : " + eplSql); if(epStatement != null) eplStateMap.put(epl.getId(), epStatement); } else { admin.createEPL(eplSqls[i].trim()); } } } epStatement.addListener(new StatisticListener(epl, collector)); LOG.info("Recreate statistic epl : " + eplSql); }
@Override public void discard() { LOG.info("Removing existing statements"); for(EPStatement epStatement : epStatements) { epService.getEPAdministrator().getStatement(epStatement.getName()).removeAllListeners(); epService.getEPAdministrator().getStatement(epStatement.getName()).stop(); epService.getEPAdministrator().getStatement(epStatement.getName()).destroy(); } epStatements.clear(); for(String eventName : eventTypeNames) { try { epService.getEPAdministrator().getConfiguration().removeEventType(eventName, false); } catch (ConfigurationException ce) { LOG.error("Event type used in another statement which is still running, skipping..."); } } queue.interrupt(); }
@Override public void feedTriggers(TriggerList triggerList) { log.debug("TriggerListEPE:{}", triggerList); List<String> conditions = new ArrayList<>(); for (Trigger t : triggerList.getTriggers()) { conditions.add(t.getTriggerCondition()); } log.debug("conditions:{}", conditions); List<EPStatement> epStatements = new ArrayList<>(); subscriber = new Subscriber(); for (String theCondition : conditions) { epStatement = epService.getEPAdministrator().createEPL(subscriber.getStatement(theCondition)); epStatement.setSubscriber(subscriber); epStatements.add(epStatement); log.debug("statement:{}", epStatement.getText()); } }
public EPLManager addEpls() { this.allEpls = DBUtils.qetAllEpls(null); Collection<Epl> epls = allEpls.values(); EPStatement state = null; String eplSql = null; for(Epl epl : epls) { eplSql = epl.getEplSql(); String[] eplSqls = eplSql.trim().split(";"); for(int i = 0; i < eplSqls.length; i++) { if(!StringUtils.isBlank(eplSqls[i])) { if(i == eplSqls.length - 1) { LOG.info("Add statistic epl : " + eplSql + ", name: " + epl.getEplName()); state = this.admin.createEPL(eplSqls[i].trim()); state.addListener(new StatisticListener(epl, collector)); LOG.info("Add statistic epl : " + eplSql + ", name: " + epl.getEplName()); if(state != null) eplStateMap.put(epl.getId(), state); } else { admin.createEPL(eplSqls[i].trim()); } } } } return this; }
public Consumer(EPServiceProvider epsp) { EPStatement statement = epsp.getEPAdministrator().createEPL(input); statement.setSubscriber(this); } public void update(A event) { System.out.println("Consumer received event!"); }
@Override protected void doStart() throws Exception { statement.addListener(this); }
public void recreateSchema(int eplId, Schema schema) { EPStatement schemaState = schemaStateMap.get(eplId); if(schemaState != null) schemaState.destroy(); String schemaSql = schema.getCreateSchemaSql(); schemaState = this.admin.createEPL(schemaSql); if(schemaState != null) schemaStateMap.put(schema.getId(), schemaState); LOG.info("Recreate Schema : " + schemaSql); }
private void registerStatements(List<String> statements, SpOutputCollector collector, T params) { toEpStatement(statements); queue = new StatementAwareQueue(getWriter(collector, params), 500000); queue.start(); for(EPStatement epStatement : epStatements) { LOG.info("Registering statement " +epStatement.getText()); if (epStatement.getText().startsWith("select")) { epStatement.addListener(listenerSendingTo(queue)); } epStatement.start(); } }
private void processAnnotations(EPStatement statement) throws Exception { Annotation[] annotations = statement.getAnnotations(); for (Annotation annotation : annotations) { if (annotation instanceof Subscriber) { Subscriber subscriber = (Subscriber) annotation; Object obj = getSubscriber(subscriber.className()); statement.setSubscriber(obj); } else if (annotation instanceof Listeners) { Listeners listeners = (Listeners) annotation; for (String className : listeners.classNames()) { Class<?> cl = Class.forName(className); Object obj = cl.newInstance(); if (obj instanceof StatementAwareUpdateListener) { statement.addListener((StatementAwareUpdateListener) obj); } else { statement.addListener((UpdateListener) obj); } } } } }
public void destory(Object id, String type) { if ("method".equals(type) && id != null) { Method md = this.allMethods.get(id); if(md != null) this.configuration.removeImport(md.getMethodName()); LOG.info("Remove Method : " + md.getMethodName()); } else if ("epl".equals(type)) { if(eplStateMap.containsKey(id) && !eplStateMap.get(id).isDestroyed()) { eplStateMap.get(id).destroy(); LOG.info("Destroy Method : " + eplStateMap.get(id).getText()); eplStateMap.remove(id); } } else if ("db".equals(type)) { if(this.configuration.getDatabaseReferences().containsKey(id)) { this.configuration.getDatabaseReferences().remove(id); LOG.info("Remove Data Source : " + this.configuration.getDatabaseReferences().get(id)); } } else if ("schema".equals(type)) { if(schemaStateMap.containsKey(id)) { List<EPStatement> epStatementList = schemaStateMap.get(id); for(EPStatement ePStatement: epStatementList) { if(!ePStatement.isDestroyed()) { LOG.info("Destroy Data Schema : " + schemaStateMap.get(id)); ePStatement.destroy(); } } } schemaStateMap.remove(id); } }
@Override protected void doStart() throws Exception { super.doStart(); if (statement.isDestroyed()) { // statement is destroyed! re-init it! statement = endpoint.createStatement(getRoute().getId()); } if(endpoint.isListen()) { statement.addListener(this); } else { log.debug("Start esper consumer eql='"+endpoint.getEndpointConfiguration().getParameter("eql")+"' without listener!"); } }