public DataFlowOpInitializeResult Initialize(DataFlowOpInitializateContext context) { if (context.OutputPorts.Count != 1) { throw new ArgumentException("EPStatementSource operator requires one output stream but produces " + context.OutputPorts.Count + " streams"); } if (_statementName == null && _statementFilter == null) { throw new EPException("Failed to find required 'StatementName' or 'statementFilter' parameter"); } if (_statementName != null && _statementFilter != null) { throw new EPException("Both 'StatementName' or 'statementFilter' parameters were provided, only either one is expected"); } DataFlowOpOutputPort portZero = context.OutputPorts[0]; if (portZero != null && portZero.OptionalDeclaredType != null && portZero.OptionalDeclaredType.IsWildcard) { _submitEventBean = true; } _statementLifecycleSvc = context.ServicesContext.StatementLifecycleSvc; return(null); }
/// <summary> /// Ctor. /// </summary> /// <param name="expressionNoAnnotations">expression text witout annotations</param> /// <param name="isPattern">is true to indicate this is a pure pattern expression</param> /// <param name="dispatchService">for dispatching events to listeners to the statement</param> /// <param name="statementLifecycleSvc">handles lifecycle transitions for the statement</param> /// <param name="timeLastStateChange">the timestamp the statement was created and started</param> /// <param name="isBlockingDispatch">is true if the dispatch to listeners should block to preserve event generation order</param> /// <param name="isSpinBlockingDispatch">true to use spin locks blocking to deliver results, as locks are usually uncontended</param> /// <param name="msecBlockingTimeout">is the max number of milliseconds of block time</param> /// <param name="timeSourceService">time source provider</param> /// <param name="statementMetadata">statement metadata</param> /// <param name="userObject">the application define user object associated to each statement, if supplied</param> /// <param name="statementContext">the statement service context</param> /// <param name="isFailed">indicator to start in failed state</param> /// <param name="nameProvided">true to indicate a statement name has been provided and is not a system-generated name</param> public EPStatementImpl( String expressionNoAnnotations, bool isPattern, DispatchService dispatchService, StatementLifecycleSvc statementLifecycleSvc, long timeLastStateChange, bool isBlockingDispatch, bool isSpinBlockingDispatch, long msecBlockingTimeout, TimeSourceService timeSourceService, StatementMetadata statementMetadata, Object userObject, StatementContext statementContext, bool isFailed, bool nameProvided) { _statementLifecycleSvc = statementLifecycleSvc; _statementListenerSet = new EPStatementListenerSet(); IsPattern = isPattern; ExpressionNoAnnotations = expressionNoAnnotations; StatementContext = statementContext; IsNameProvided = nameProvided; if (isBlockingDispatch) { if (isSpinBlockingDispatch) { _dispatchChildView = new UpdateDispatchViewBlockingSpin( statementContext.StatementResultService, dispatchService, msecBlockingTimeout, timeSourceService, statementContext.ThreadLocalManager); } else { _dispatchChildView = new UpdateDispatchViewBlockingWait( statementContext.StatementResultService, dispatchService, msecBlockingTimeout, statementContext.ThreadLocalManager); } } else { _dispatchChildView = new UpdateDispatchViewNonBlocking( statementContext.StatementResultService, dispatchService, statementContext.ThreadLocalManager); } State = !isFailed ? EPStatementState.STOPPED : EPStatementState.FAILED; TimeLastStateChange = timeLastStateChange; StatementMetadata = statementMetadata; UserObject = userObject; statementContext.StatementResultService.SetUpdateListeners(_statementListenerSet, false); }
public void Dispose() { if (State == EPStatementState.DESTROYED) { throw new IllegalStateException("Statement already destroyed"); } _statementLifecycleSvc.Destroy(StatementContext.StatementId); _parentView = null; EventType = null; _dispatchChildView = null; _statementLifecycleSvc = null; }
/// <summary> /// Ctor. /// </summary> /// <param name="statementName">Name of the statement.</param> /// <param name="statementLifecycleSvc">handles persistence for statements</param> /// <param name="metricReportingService">for metrics reporting</param> /// <param name="threadingService">for outbound threading</param> public StatementResultServiceImpl(String statementName, StatementLifecycleSvc statementLifecycleSvc, MetricReportingServiceSPI metricReportingService, ThreadingService threadingService) { Log.Debug(".ctor"); _isDebugEnabled = ExecutionPathDebugLog.IsEnabled && Log.IsDebugEnabled; _statementName = statementName; _statementLifecycleSvc = statementLifecycleSvc; _metricReportingService = metricReportingService; _statementOutputHooks = metricReportingService != null ? metricReportingService.StatementOutputHooks : new List <StatementResultListener>(); _threadingService = threadingService; }
/// <summary> /// Ctor. /// </summary> /// <param name="statementName">Name of the statement.</param> /// <param name="statementLifecycleSvc">handles persistence for statements</param> /// <param name="metricReportingService">for metrics reporting</param> /// <param name="threadingService">for outbound threading</param> /// <param name="threadLocalManager">The thread local manager.</param> public StatementResultServiceImpl( String statementName, StatementLifecycleSvc statementLifecycleSvc, MetricReportingServiceSPI metricReportingService, ThreadingService threadingService, IThreadLocalManager threadLocalManager) { Log.Debug(".ctor"); _threadLocalManager = threadLocalManager; _lastResults = threadLocalManager.Create(() => new LinkedList <UniformPair <EventBean[]> >()); _isDebugEnabled = ExecutionPathDebugLog.IsEnabled && Log.IsDebugEnabled; _statementName = statementName; _statementLifecycleSvc = statementLifecycleSvc; _metricReportingService = metricReportingService; _statementOutputHooks = metricReportingService != null ? metricReportingService.StatementOutputHooks : new List <StatementResultListener>(); _threadingService = threadingService; }
/// <summary>Dispose services. </summary> public void Dispose() { if (ScriptingService != null) { ScriptingService.Dispose(); } if (ExprDeclaredService != null) { ExprDeclaredService.Dispose(); } if (DataFlowService != null) { DataFlowService.Dispose(); } if (VariableService != null) { VariableService.Dispose(); } if (MetricsReportingService != null) { MetricsReportingService.Dispose(); } if (ThreadingService != null) { ThreadingService.Dispose(); } if (StatementLifecycleSvc != null) { StatementLifecycleSvc.Dispose(); } if (FilterService != null) { FilterService.Dispose(); } if (SchedulingService != null) { SchedulingService.Dispose(); } if (SchedulingMgmtService != null) { SchedulingMgmtService.Dispose(); } if (StreamService != null) { StreamService.Destroy(); } if (NamedWindowMgmtService != null) { NamedWindowMgmtService.Dispose(); } if (NamedWindowDispatchService != null) { NamedWindowDispatchService.Dispose(); } if (EngineLevelExtensionServicesContext != null) { EngineLevelExtensionServicesContext.Dispose(); } if (StatementIsolationService != null) { StatementIsolationService.Dispose(); } if (DeploymentStateService != null) { DeploymentStateService.Dispose(); } }
/// <summary>Sets the service dealing with starting and stopping statements. </summary> /// <param name="statementLifecycleSvc">statement lifycycle svc</param> public void SetStatementLifecycleSvc(StatementLifecycleSvc statementLifecycleSvc) { StatementLifecycleSvc = statementLifecycleSvc; }