Package com.espertech.esper.util

Examples of com.espertech.esper.util.StopCallback


        EPStatementStopMethod stopStatementMethod;
        EPStatementDestroyMethod destroyStatementMethod;

        try {
            // add stop callback
            stopCallbacks.add(new StopCallback() {
                public void stop() {
                    services.getNamedWindowService().removeProcessor(windowName);
                    if (virtualDataWindowFactory != null) {
                        virtualDataWindowFactory.destroyNamedWindow();
                    }
View Full Code Here


        return false;
    }

    public static StopCallback getStopCallback(List<StopCallback> stopCallbacks, final AgentInstanceContext agentInstanceContext) {
        final StopCallback[] stopCallbackArr = stopCallbacks.toArray(new StopCallback[stopCallbacks.size()]);
        return new StopCallback() {
            public void stop() {
                StatementAgentInstanceUtil.stopSafe(agentInstanceContext.getTerminationCallbackRO(), stopCallbackArr, agentInstanceContext.getStatementContext());
            }
        };
    }
View Full Code Here

            // if using variables, register a callback on the change of the variable
            for (String variableName : parent.getVariableNames())
            {
                final VariableReader reader = agentInstanceContext.getStatementContext().getVariableService().getReader(variableName);
                agentInstanceContext.getStatementContext().getVariableService().registerCallback(reader.getVariableNumber(), this);
                agentInstanceContext.addTerminationCallback(new StopCallback() {
                    public void stop() {
                        agentInstanceContext.getStatementContext().getVariableService().unregisterCallback(reader.getVariableNumber(), OutputConditionExpression.this);
                    }
                });
            }
View Full Code Here

        final List<StopCallback> stopCallbacks = new ArrayList<StopCallback>();

        Map<ExprSubselectNode, SubSelectStrategyHolder> subselectStrategies;

        try {
            stopCallbacks.add(new StopCallback()
            {
                public void stop()
                {
                    services.getInternalEventRouter().removePreprocessing(streamEventType, desc);
                }
            });

            services.getInternalEventRouter().addPreprocessing(routerDesc, onExprView, agentInstanceContext.getAgentInstanceLock(), !subSelectStrategyCollection.getSubqueries().isEmpty());

            // start subselects
            subselectStrategies = EPStatementStartMethodHelperSubselect.startSubselects(services, subSelectStrategyCollection, agentInstanceContext, stopCallbacks);
        }
        catch (RuntimeException ex) {
            StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
            StatementAgentInstanceUtil.stopSafe(stopCallback, statementContext);
            throw ex;
        }

        log.debug(".start Statement start completed");
        StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
        return new StatementAgentInstanceFactoryUpdateResult(onExprView, stopCallback, agentInstanceContext, subselectStrategies);
    }
View Full Code Here

            if (isRecoveringResilient) {
                postLoadJoin = new StatementAgentInstancePostLoadSelect(streamViews, joinSetComposer, namedWindowTailViews, namedWindowPostloadFilters, namedWindowFilters, statementContext.getAnnotations(), agentInstanceContext);
            }
        }
        catch (RuntimeException ex) {
            StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
            StatementAgentInstanceUtil.stopSafe(stopCallback, statementContext);
            throw ex;
        }

        StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
        return new StatementAgentInstanceFactorySelectResult(finalView, stopCallback, agentInstanceContext, aggregationService, subselectStrategies, priorNodeStrategies, previousNodeStrategies, preloadList, patternRoots, postLoadJoin, topViews, eventStreamParentViewable);
    }
View Full Code Here

                                                         List<StopCallback> stopCallbacks,
                                                         StreamJoinAnalysisResult joinAnalysisResult)
    {
        final JoinSetComposerDesc joinSetComposerDesc = joinSetComposerPrototype.create(streamViews, false);

        stopCallbacks.add(new StopCallback(){
            public void stop()
            {
                joinSetComposerDesc.getJoinSetComposer().destroy();
            }
        });
View Full Code Here

            ViewServiceCreateResult createResult = services.getViewService().createViews(rootView, unmaterializedViewChain.getViewFactoryChain(), viewFactoryChainContext, false);
            topView = createResult.getTopViewable();
            finalView = createResult.getFinalViewable();

            // If this is a virtual data window implementation, bind it to the context for easy lookup
            StopCallback envStopCallback = null;
            if (finalView instanceof VirtualDWView) {
                final String objectName = "/virtualdw/" + windowName;
                final VirtualDWView virtualDWView = (VirtualDWView) finalView;
                try {
                    services.getEngineEnvContext().bind(objectName, virtualDWView.getVirtualDataWindow());
                }
                catch (NamingException e) {
                    throw new ViewProcessingException("Invalid name for adding to context:" + e.getMessage(), e);
                }
                envStopCallback = new StopCallback() {
                    public void stop() {
                        try {
                            virtualDWView.destroy();
                            services.getEngineEnvContext().unbind(objectName);
                        } catch (NamingException e) {}
                    }
                };
            }
            final StopCallback environmentStopCallback = envStopCallback;

            // create stop method using statement stream specs
            StopCallback allInOneStopMethod = new StopCallback()
            {
                public void stop()
                {
                    String windowName = statementSpec.getCreateWindowDesc().getWindowName();
                    NamedWindowProcessor processor = services.getNamedWindowService().getProcessor(windowName);
                    if (processor == null) {
                        log.warn("Named window processor by name '" + windowName + "' has not been found");
                    }
                    else {
                        NamedWindowProcessorInstance instance = processor.getProcessorInstance(agentInstanceContext);
                        if (instance != null && instance.getRootViewInstance().isVirtualDataWindow()) {
                            instance.getRootViewInstance().getVirtualDataWindow().handleStopWindow();
                        }
                        if (instance != null) {
                            processor.removeProcessorInstance(instance);
                        }
                    }
                    if (environmentStopCallback != null) {
                        environmentStopCallback.stop();
                    }
                }
            };
            stopCallbacks.add(allInOneStopMethod);

            // Attach tail view
            NamedWindowTailViewInstance tailView = processorInstance.getTailViewInstance();
            finalView.addView(tailView);
            finalView = tailView;

            // obtain result set processor
            ResultSetProcessor resultSetProcessor = EPStatementStartMethodHelperAssignExpr.getAssignResultSetProcessor(agentInstanceContext, resultSetProcessorPrototype);

            // Attach output view
            View outputView = outputProcessViewFactory.makeView(resultSetProcessor, agentInstanceContext);
            finalView.addView(outputView);
            finalView = outputView;

            // obtain post load
            postLoad = processorInstance.getPostLoad();

            // Handle insert case
            if (statementSpec.getCreateWindowDesc().isInsert() && !isRecoveringStatement)
            {
                String insertFromWindow = statementSpec.getCreateWindowDesc().getInsertFromWindow();
                NamedWindowProcessor namedWindowProcessor = services.getNamedWindowService().getProcessor(insertFromWindow);
                NamedWindowProcessorInstance sourceWindowInstances = namedWindowProcessor.getProcessorInstance(agentInstanceContext);
                List<EventBean> events = new ArrayList<EventBean>();
                if (statementSpec.getCreateWindowDesc().getInsertFilter() != null)
                {
                    EventBean[] eventsPerStream = new EventBean[1];
                    ExprEvaluator filter = statementSpec.getCreateWindowDesc().getInsertFilter().getExprEvaluator();
                    for (Iterator<EventBean> it = sourceWindowInstances.getTailViewInstance().iterator(); it.hasNext();)
                    {
                        EventBean candidate = it.next();
                        eventsPerStream[0] = candidate;
                        Boolean result = (Boolean) filter.evaluate(eventsPerStream, true, agentInstanceContext);
                        if ((result == null) || (!result))
                        {
                            continue;
                        }
                        events.add(candidate);
                    }
                }
                else
                {
                    for (Iterator<EventBean> it = sourceWindowInstances.getTailViewInstance().iterator(); it.hasNext();)
                    {
                        events.add(it.next());
                    }
                }
                if (events.size() > 0)
                {
                    EventType rootViewType = rootView.getEventType();
                    EventBean[] convertedEvents = services.getEventAdapterService().typeCast(events, rootViewType);
                    rootView.update(convertedEvents, null);
                }
            }
        }
        catch (RuntimeException ex) {
            StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
            StatementAgentInstanceUtil.stopSafe(stopCallback, statementContext);
            throw ex;
        }

        log.debug(".start Statement start completed");
        StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
        return new StatementAgentInstanceFactoryCreateWindowResult(finalView, stopCallback, agentInstanceContext, eventStreamParentViewable, postLoad, topView);
    }
View Full Code Here

                onExprView.addView(outputView);
                onExprView = outputView;
            }
        }
        catch (RuntimeException ex) {
            StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
            StatementAgentInstanceUtil.stopSafe(stopCallback, statementContext);
            throw ex;
        }

        log.debug(".start Statement start completed");
        StopCallback stopCallback = StatementAgentInstanceUtil.getStopCallback(stopCallbacks, agentInstanceContext);
        return new StatementAgentInstanceFactoryOnTriggerResult(onExprView, stopCallback, agentInstanceContext, aggregationService, subselectStrategies, optPatternRoot);
    }
View Full Code Here

        }
        else if (terminationCallbacks instanceof Collection) {
            ((Collection<StopCallback>) terminationCallbacks).add(callback);
        }
        else {
            StopCallback cb = (StopCallback) terminationCallbacks;
            HashSet<StopCallback> q = new HashSet<StopCallback>(2);
            q.add(cb);
            q.add(callback);
            terminationCallbacks = q;
        }
View Full Code Here

        // Without context - start here
        else {
            StatementAgentInstanceFactorySelectResult resultOfStart = selectDesc.getStatementAgentInstanceFactorySelect().newContext(defaultAgentInstanceContext, isRecoveringResilient);
            finalViewable = resultOfStart.getFinalView();
            final EPStatementStopMethod selectStop = selectDesc.getStopMethod();
            final StopCallback startResultStop = resultOfStart.getStopCallback();
            stopStatementMethod = new EPStatementStopMethod() {
                public void stop() {
                    StatementAgentInstanceUtil.stopSafe(startResultStop, statementContext);
                    selectStop.stop();
                }
View Full Code Here

TOP

Related Classes of com.espertech.esper.util.StopCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.