コード例 #1
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="eventAdapterService">is the event wrapper and type service</param>
 /// <param name="eventTypeIdGenerator">The event type id generator.</param>
 /// <param name="engineImportService">for imported aggregation functions and static functions</param>
 /// <param name="variableService">provides access to variable values</param>
 /// <param name="engineSettingsService">some engine settings are writable</param>
 /// <param name="valueAddEventService">Update event handling</param>
 /// <param name="metricReportingService">for metric reporting</param>
 /// <param name="statementEventTypeRef">statement to event type reference holding</param>
 /// <param name="statementVariableRef">statement to variable reference holding</param>
 /// <param name="plugInViews">The plug in views.</param>
 /// <param name="filterService">The filter service.</param>
 /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
 /// <param name="tableService">The table service.</param>
 public ConfigurationOperationsImpl(
     EventAdapterService eventAdapterService,
     EventTypeIdGenerator eventTypeIdGenerator,
     EngineImportService engineImportService,
     VariableService variableService,
     EngineSettingsService engineSettingsService,
     ValueAddEventService valueAddEventService,
     MetricReportingService metricReportingService,
     StatementEventTypeRef statementEventTypeRef,
     StatementVariableRef statementVariableRef,
     PluggableObjectCollection plugInViews,
     FilterService filterService,
     PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc,
     MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc,
     TableService tableService)
 {
     _eventAdapterService              = eventAdapterService;
     _eventTypeIdGenerator             = eventTypeIdGenerator;
     _engineImportService              = engineImportService;
     _variableService                  = variableService;
     _engineSettingsService            = engineSettingsService;
     _valueAddEventService             = valueAddEventService;
     _metricReportingService           = metricReportingService;
     _statementEventTypeRef            = statementEventTypeRef;
     _statementVariableRef             = statementVariableRef;
     _plugInViews                      = plugInViews;
     _filterService                    = filterService;
     _patternSubexpressionPoolSvc      = patternSubexpressionPoolSvc;
     _matchRecognizeStatePoolEngineSvc = matchRecognizeStatePoolEngineSvc;
     _tableService                     = tableService;
 }
コード例 #2
0
        // Supplied after construction to avoid circular dependency

        /// <summary>
        /// Constructor - sets up new set of services.
        /// </summary>
        /// <param name="engineURI">is the engine URI</param>
        /// <param name="schedulingService">service to get time and schedule callbacks</param>
        /// <param name="eventAdapterService">service to resolve event types</param>
        /// <param name="engineImportService">is engine imported static func packages and aggregation functions</param>
        /// <param name="engineSettingsService">provides engine settings</param>
        /// <param name="databaseConfigService">service to resolve a database name to database connection factory and configs</param>
        /// <param name="plugInViews">resolves view namespace and name to view factory class</param>
        /// <param name="statementLockFactory">creates statement-level locks</param>
        /// <param name="eventProcessingRWLock">is the engine lock for statement management</param>
        /// <param name="extensionServicesContext">marker interface allows adding additional services</param>
        /// <param name="engineEnvContext">is engine environment/directory information for use with adapters and external env</param>
        /// <param name="statementContextFactory">is the factory to use to create statement context objects</param>
        /// <param name="plugInPatternObjects">resolves plug-in pattern objects</param>
        /// <param name="timerService">is the timer service</param>
        /// <param name="filterService">the filter service</param>
        /// <param name="streamFactoryService">is hooking up filters to streams</param>
        /// <param name="namedWindowMgmtService">The named window MGMT service.</param>
        /// <param name="namedWindowDispatchService">The named window dispatch service.</param>
        /// <param name="variableService">provides access to variable values</param>
        /// <param name="tableService">The table service.</param>
        /// <param name="timeSourceService">time source provider class</param>
        /// <param name="valueAddEventService">handles Update events</param>
        /// <param name="metricsReportingService">for metric reporting</param>
        /// <param name="statementEventTypeRef">statement to event type reference holding</param>
        /// <param name="statementVariableRef">statement to variabke reference holding</param>
        /// <param name="configSnapshot">configuration snapshot</param>
        /// <param name="threadingServiceImpl">engine-level threading services</param>
        /// <param name="internalEventRouter">routing of events</param>
        /// <param name="statementIsolationService">maintains isolation information per statement</param>
        /// <param name="schedulingMgmtService">schedule management for statements</param>
        /// <param name="deploymentStateService">The deployment state service.</param>
        /// <param name="exceptionHandlingService">The exception handling service.</param>
        /// <param name="patternNodeFactory">The pattern node factory.</param>
        /// <param name="eventTypeIdGenerator">The event type id generator.</param>
        /// <param name="statementMetadataFactory">The statement metadata factory.</param>
        /// <param name="contextManagementService">The context management service.</param>
        /// <param name="patternSubexpressionPoolSvc">The pattern subexpression pool SVC.</param>
        /// <param name="matchRecognizeStatePoolEngineSvc">The match recognize state pool engine SVC.</param>
        /// <param name="dataFlowService">The data flow service.</param>
        /// <param name="exprDeclaredService">The expr declared service.</param>
        /// <param name="contextControllerFactoryFactorySvc">The context controller factory factory SVC.</param>
        /// <param name="contextManagerFactoryService">The context manager factory service.</param>
        /// <param name="epStatementFactory">The ep statement factory.</param>
        /// <param name="regexHandlerFactory">The regex handler factory.</param>
        /// <param name="viewableActivatorFactory">The viewable activator factory.</param>
        /// <param name="filterNonPropertyRegisteryService">The filter non property registery service.</param>
        /// <param name="resultSetProcessorHelperFactory">The result set processor helper factory.</param>
        /// <param name="viewServicePreviousFactory">The view service previous factory.</param>
        /// <param name="eventTableIndexService">The event table index service.</param>
        /// <param name="epRuntimeIsolatedFactory">The ep runtime isolated factory.</param>
        /// <param name="filterBooleanExpressionFactory">The filter boolean expression factory.</param>
        /// <param name="dataCacheFactory">The data cache factory.</param>
        /// <param name="multiMatchHandlerFactory">The multi match handler factory.</param>
        /// <param name="namedWindowConsumerMgmtService">The named window consumer MGMT service.</param>
        /// <param name="aggregationFactoryFactory"></param>
        /// <param name="scriptingService">The scripting service.</param>
        public EPServicesContext(
            string engineURI,
            SchedulingServiceSPI schedulingService,
            EventAdapterService eventAdapterService,
            EngineImportService engineImportService,
            EngineSettingsService engineSettingsService,
            DatabaseConfigService databaseConfigService,
            PluggableObjectCollection plugInViews,
            StatementLockFactory statementLockFactory,
            IReaderWriterLock eventProcessingRWLock,
            EngineLevelExtensionServicesContext extensionServicesContext,
            Directory engineEnvContext,
            StatementContextFactory statementContextFactory,
            PluggableObjectCollection plugInPatternObjects,
            TimerService timerService,
            FilterServiceSPI filterService,
            StreamFactoryService streamFactoryService,
            NamedWindowMgmtService namedWindowMgmtService,
            NamedWindowDispatchService namedWindowDispatchService,
            VariableService variableService,
            TableService tableService,
            TimeSourceService timeSourceService,
            ValueAddEventService valueAddEventService,
            MetricReportingServiceSPI metricsReportingService,
            StatementEventTypeRef statementEventTypeRef,
            StatementVariableRef statementVariableRef,
            ConfigurationInformation configSnapshot,
            ThreadingService threadingServiceImpl,
            InternalEventRouterImpl internalEventRouter,
            StatementIsolationService statementIsolationService,
            SchedulingMgmtService schedulingMgmtService,
            DeploymentStateService deploymentStateService,
            ExceptionHandlingService exceptionHandlingService,
            PatternNodeFactory patternNodeFactory,
            EventTypeIdGenerator eventTypeIdGenerator,
            StatementMetadataFactory statementMetadataFactory,
            ContextManagementService contextManagementService,
            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc,
            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc,
            DataFlowService dataFlowService,
            ExprDeclaredService exprDeclaredService,
            ContextControllerFactoryFactorySvc contextControllerFactoryFactorySvc,
            ContextManagerFactoryService contextManagerFactoryService,
            EPStatementFactory epStatementFactory,
            RegexHandlerFactory regexHandlerFactory,
            ViewableActivatorFactory viewableActivatorFactory,
            FilterNonPropertyRegisteryService filterNonPropertyRegisteryService,
            ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
            ViewServicePreviousFactory viewServicePreviousFactory,
            EventTableIndexService eventTableIndexService,
            EPRuntimeIsolatedFactory epRuntimeIsolatedFactory,
            FilterBooleanExpressionFactory filterBooleanExpressionFactory,
            DataCacheFactory dataCacheFactory,
            MultiMatchHandlerFactory multiMatchHandlerFactory,
            NamedWindowConsumerMgmtService namedWindowConsumerMgmtService,
            AggregationFactoryFactory aggregationFactoryFactory,
            ScriptingService scriptingService)
        {
            EngineURI             = engineURI;
            SchedulingService     = schedulingService;
            EventAdapterService   = eventAdapterService;
            EngineImportService   = engineImportService;
            EngineSettingsService = engineSettingsService;
            DatabaseRefService    = databaseConfigService;
            FilterService         = filterService;
            TimerService          = timerService;
            DispatchService       = DispatchServiceProvider.NewService();
            ViewService           = ViewServiceProvider.NewService();
            StreamService         = streamFactoryService;
            PlugInViews           = plugInViews;
            StatementLockFactory  = statementLockFactory;
            EventProcessingRWLock = eventProcessingRWLock;
            EngineLevelExtensionServicesContext = extensionServicesContext;
            EngineEnvContext           = engineEnvContext;
            StatementContextFactory    = statementContextFactory;
            PlugInPatternObjects       = plugInPatternObjects;
            NamedWindowMgmtService     = namedWindowMgmtService;
            NamedWindowDispatchService = namedWindowDispatchService;
            VariableService            = variableService;
            TableService                     = tableService;
            TimeSource                       = timeSourceService;
            ValueAddEventService             = valueAddEventService;
            MetricsReportingService          = metricsReportingService;
            StatementEventTypeRefService     = statementEventTypeRef;
            ConfigSnapshot                   = configSnapshot;
            ThreadingService                 = threadingServiceImpl;
            InternalEventRouter              = internalEventRouter;
            StatementIsolationService        = statementIsolationService;
            SchedulingMgmtService            = schedulingMgmtService;
            StatementVariableRefService      = statementVariableRef;
            DeploymentStateService           = deploymentStateService;
            ExceptionHandlingService         = exceptionHandlingService;
            PatternNodeFactory               = patternNodeFactory;
            EventTypeIdGenerator             = eventTypeIdGenerator;
            StatementMetadataFactory         = statementMetadataFactory;
            ContextManagementService         = contextManagementService;
            PatternSubexpressionPoolSvc      = patternSubexpressionPoolSvc;
            MatchRecognizeStatePoolEngineSvc = matchRecognizeStatePoolEngineSvc;
            DataFlowService                  = dataFlowService;
            ExprDeclaredService              = exprDeclaredService;
            ExpressionResultCacheSharable    = new ExpressionResultCacheService(
                configSnapshot.EngineDefaults.ExecutionConfig.DeclaredExprValueCacheSize);
            ContextControllerFactoryFactorySvc = contextControllerFactoryFactorySvc;
            ContextManagerFactoryService       = contextManagerFactoryService;
            EpStatementFactory                = epStatementFactory;
            RegexHandlerFactory               = regexHandlerFactory;
            ViewableActivatorFactory          = viewableActivatorFactory;
            FilterNonPropertyRegisteryService = filterNonPropertyRegisteryService;
            ResultSetProcessorHelperFactory   = resultSetProcessorHelperFactory;
            ViewServicePreviousFactory        = viewServicePreviousFactory;
            EventTableIndexService            = eventTableIndexService;
            EpRuntimeIsolatedFactory          = epRuntimeIsolatedFactory;
            FilterBooleanExpressionFactory    = filterBooleanExpressionFactory;
            DataCacheFactory               = dataCacheFactory;
            MultiMatchHandlerFactory       = multiMatchHandlerFactory;
            NamedWindowConsumerMgmtService = namedWindowConsumerMgmtService;
            AggregationFactoryFactory      = aggregationFactoryFactory;
            ScriptingService               = scriptingService;
        }
コード例 #3
0
        public EPServicesContext CreateServicesContext(
            IContainer container,
            EPServiceProvider epServiceProvider,
            ConfigurationInformation configSnapshot)
        {
            var lockManager        = container.LockManager();
            var rwLockManager      = container.RWLockManager();
            var threadLocalManager = container.ThreadLocalManager();
            var resourceManager    = container.ResourceManager();

            // Directory for binding resources
            var resourceDirectory = container.Resolve <Directory>();

            // Engine import service
            var engineImportService = MakeEngineImportService(
                container.Resolve <ClassLoaderProvider>(),
                configSnapshot,
                AggregationFactoryFactoryDefault.INSTANCE,
                epServiceProvider.URI);

            // Event Type Id Generation
            EventTypeIdGenerator eventTypeIdGenerator;

            if (configSnapshot.EngineDefaults.AlternativeContext == null ||
                configSnapshot.EngineDefaults.AlternativeContext.EventTypeIdGeneratorFactory == null)
            {
                eventTypeIdGenerator = new EventTypeIdGeneratorImpl();
            }
            else
            {
                var eventTypeIdGeneratorFactory = TypeHelper.Instantiate <EventTypeIdGeneratorFactory>(
                    configSnapshot.EngineDefaults.AlternativeContext.EventTypeIdGeneratorFactory,
                    engineImportService.GetClassForNameProvider());
                eventTypeIdGenerator = eventTypeIdGeneratorFactory.Create(
                    new EventTypeIdGeneratorContext(epServiceProvider.URI));
            }

            // Make services that depend on snapshot config entries
            EventAdapterAvroHandler avroHandler = EventAdapterAvroHandlerUnsupported.INSTANCE;

            if (configSnapshot.EngineDefaults.EventMeta.AvroSettings.IsEnableAvro)
            {
                try
                {
                    avroHandler = TypeHelper.Instantiate <EventAdapterAvroHandler>(
                        EventAdapterAvroHandlerConstants.HANDLER_IMPL, engineImportService.GetClassForNameProvider());
                }
                catch (Exception e)
                {
                    Log.Debug(
                        "Avro provider {0} not instantiated, not enabling Avro support: {1}",
                        EventAdapterAvroHandlerConstants.HANDLER_IMPL, e.Message);
                }
                try
                {
                    avroHandler.Init(configSnapshot.EngineDefaults.EventMeta.AvroSettings, engineImportService);
                }
                catch (Exception e)
                {
                    throw new ConfigurationException("Failed to initialize Esper-Avro: " + e.Message, e);
                }
            }

            var eventAdapterService = new EventAdapterServiceImpl(
                container,
                eventTypeIdGenerator,
                configSnapshot.EngineDefaults.EventMeta.AnonymousCacheSize,
                avroHandler,
                engineImportService);

            Init(eventAdapterService, configSnapshot, engineImportService, resourceManager);

            // New read-write lock for concurrent event processing
            var eventProcessingRwLock = rwLockManager.CreateLock(GetType());

            var timeSourceService     = MakeTimeSource(configSnapshot);
            var schedulingService     = SchedulingServiceProvider.NewService(timeSourceService, lockManager);
            var schedulingMgmtService = new SchedulingMgmtServiceImpl();
            var engineSettingsService = new EngineSettingsService(
                configSnapshot.EngineDefaults, configSnapshot.PlugInEventTypeResolutionURIs);
            var databaseConfigService = MakeDatabaseRefService(
                configSnapshot, schedulingService, schedulingMgmtService, engineImportService);

            var plugInViews = new PluggableObjectCollection();

            plugInViews.AddViews(
                configSnapshot.PlugInViews, configSnapshot.PlugInVirtualDataWindows, engineImportService);
            var plugInPatternObj = new PluggableObjectCollection();

            plugInPatternObj.AddPatternObjects(configSnapshot.PlugInPatternObjects, engineImportService);

            // exception handling
            var exceptionHandlingService = InitExceptionHandling(
                epServiceProvider.URI, configSnapshot.EngineDefaults.ExceptionHandling,
                configSnapshot.EngineDefaults.ConditionHandling, engineImportService);

            // Statement context factory
            Type systemVirtualDWViewFactory = null;

            if (configSnapshot.EngineDefaults.AlternativeContext.VirtualDataWindowViewFactory != null)
            {
                try
                {
                    systemVirtualDWViewFactory =
                        engineImportService.GetClassForNameProvider()
                        .ClassForName(configSnapshot.EngineDefaults.AlternativeContext.VirtualDataWindowViewFactory);
                    if (!TypeHelper.IsImplementsInterface(systemVirtualDWViewFactory, typeof(VirtualDataWindowFactory)))
                    {
                        throw new ConfigurationException(
                                  "Type " + systemVirtualDWViewFactory.Name + " does not implement the interface " +
                                  typeof(VirtualDataWindowFactory).Name);
                    }
                }
                catch (TypeLoadException)
                {
                    throw new ConfigurationException("Failed to look up class " + systemVirtualDWViewFactory);
                }
            }
            var statementContextFactory = new StatementContextFactoryDefault(
                plugInViews, plugInPatternObj, systemVirtualDWViewFactory);

            var msecTimerResolution = configSnapshot.EngineDefaults.Threading.InternalTimerMsecResolution;

            if (msecTimerResolution <= 0)
            {
                throw new ConfigurationException(
                          "Timer resolution configuration not set to a valid value, expecting a non-zero value");
            }
            var timerService = new TimerServiceImpl(epServiceProvider.URI, msecTimerResolution);

            var variableService = new VariableServiceImpl(
                container,
                configSnapshot.EngineDefaults.Variables.MsecVersionRelease,
                schedulingService,
                eventAdapterService,
                null);

            InitVariables(variableService, configSnapshot.Variables, engineImportService);

            var tableService = new TableServiceImpl(container);

            var statementLockFactory = new StatementLockFactoryImpl(
                rwLockManager,
                configSnapshot.EngineDefaults.Execution.IsFairlock,
                configSnapshot.EngineDefaults.Execution.IsDisableLocking
                );

            var streamFactoryService = StreamFactoryServiceProvider.NewService(
                epServiceProvider.URI, configSnapshot.EngineDefaults.ViewResources.IsShareViews);
            var filterService = FilterServiceProvider.NewService(
                lockManager,
                rwLockManager,
                configSnapshot.EngineDefaults.Execution.FilterServiceProfile,
                configSnapshot.EngineDefaults.Execution.IsAllowIsolatedService);
            var metricsReporting = new MetricReportingServiceImpl(
                configSnapshot.EngineDefaults.MetricsReporting,
                epServiceProvider.URI,
                rwLockManager);
            var namedWindowMgmtService = new NamedWindowMgmtServiceImpl(
                configSnapshot.EngineDefaults.Logging.IsEnableQueryPlan,
                metricsReporting);
            var namedWindowDispatchService = new NamedWindowDispatchServiceImpl(
                schedulingService, variableService, tableService,
                engineSettingsService.EngineSettings.Execution.IsPrioritized, eventProcessingRwLock,
                exceptionHandlingService, metricsReporting, threadLocalManager);

            var valueAddEventService = new ValueAddEventServiceImpl(lockManager);

            valueAddEventService.Init(
                configSnapshot.RevisionEventTypes, configSnapshot.VariantStreams, eventAdapterService,
                eventTypeIdGenerator);

            var statementEventTypeRef = new StatementEventTypeRefImpl(rwLockManager);
            var statementVariableRef  = new StatementVariableRefImpl(
                variableService, tableService, namedWindowMgmtService, rwLockManager);

            var threadingService = new ThreadingServiceImpl(configSnapshot.EngineDefaults.Threading);

            var internalEventRouterImpl = new InternalEventRouterImpl(epServiceProvider.URI);

            var statementIsolationService = new StatementIsolationServiceImpl();

            var deploymentStateService = new DeploymentStateServiceImpl(lockManager);

            StatementMetadataFactory stmtMetadataFactory;

            if (configSnapshot.EngineDefaults.AlternativeContext.StatementMetadataFactory == null)
            {
                stmtMetadataFactory = new StatementMetadataFactoryDefault();
            }
            else
            {
                stmtMetadataFactory = TypeHelper.Instantiate <StatementMetadataFactory>(
                    configSnapshot.EngineDefaults.AlternativeContext.StatementMetadataFactory,
                    engineImportService.GetClassForNameProvider());
            }

            var contextManagementService = new ContextManagementServiceImpl();

            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc = null;

            if (configSnapshot.EngineDefaults.Patterns.MaxSubexpressions != null)
            {
                patternSubexpressionPoolSvc =
                    new PatternSubexpressionPoolEngineSvc(
                        configSnapshot.EngineDefaults.Patterns.MaxSubexpressions.Value,
                        configSnapshot.EngineDefaults.Patterns.IsMaxSubexpressionPreventStart);
            }

            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc = null;

            if (configSnapshot.EngineDefaults.MatchRecognize.MaxStates != null)
            {
                matchRecognizeStatePoolEngineSvc =
                    new MatchRecognizeStatePoolEngineSvc(
                        configSnapshot.EngineDefaults.MatchRecognize.MaxStates.Value,
                        configSnapshot.EngineDefaults.MatchRecognize.IsMaxStatesPreventStart);
            }

            var scriptingService = new ScriptingServiceImpl();

            scriptingService.DiscoverEngines();

            // New services context

            var services = new EPServicesContext(
                container, epServiceProvider.URI,
                schedulingService,
                eventAdapterService,
                engineImportService,
                engineSettingsService,
                databaseConfigService,
                plugInViews,
                statementLockFactory,
                eventProcessingRwLock,
                null,
                resourceDirectory,
                statementContextFactory,
                plugInPatternObj,
                timerService,
                filterService,
                streamFactoryService,
                namedWindowMgmtService,
                namedWindowDispatchService,
                variableService,
                tableService,
                timeSourceService,
                valueAddEventService,
                metricsReporting,
                statementEventTypeRef,
                statementVariableRef,
                configSnapshot,
                threadingService,
                internalEventRouterImpl,
                statementIsolationService,
                schedulingMgmtService,
                deploymentStateService,
                exceptionHandlingService,
                new PatternNodeFactoryImpl(),
                eventTypeIdGenerator,
                stmtMetadataFactory,
                contextManagementService,
                patternSubexpressionPoolSvc,
                matchRecognizeStatePoolEngineSvc,
                new DataFlowServiceImpl(epServiceProvider, new DataFlowConfigurationStateServiceImpl(), lockManager),
                new ExprDeclaredServiceImpl(lockManager),
                new ContextControllerFactoryFactorySvcImpl(),
                new ContextManagerFactoryServiceImpl(),
                new EPStatementFactoryDefault(),
                new RegexHandlerFactoryDefault(container),
                new ViewableActivatorFactoryDefault(),
                new FilterNonPropertyRegisteryServiceImpl(),
                new ResultSetProcessorHelperFactoryImpl(),
                new ViewServicePreviousFactoryImpl(),
                new EventTableIndexServiceImpl(),
                new EPRuntimeIsolatedFactoryImpl(),
                new FilterBooleanExpressionFactoryImpl(),
                new DataCacheFactory(),
                new MultiMatchHandlerFactoryImpl(),
                NamedWindowConsumerMgmtServiceImpl.INSTANCE,
                AggregationFactoryFactoryDefault.INSTANCE,
                scriptingService
                );

            // Engine services subset available to statements
            statementContextFactory.StmtEngineServices = services;

            // Circular dependency
            var statementLifecycleSvc = new StatementLifecycleSvcImpl(epServiceProvider, services);

            services.StatementLifecycleSvc = statementLifecycleSvc;

            // Observers to statement events
            statementLifecycleSvc.LifecycleEvent += (s, theEvent) => metricsReporting.Observe(theEvent);

            // Circular dependency
            statementIsolationService.SetEpServicesContext(services);

            return(services);
        }
コード例 #4
0
        public EPServicesContext CreateServicesContext(EPServiceProvider epServiceProvider, ConfigurationInformation configSnapshot)
        {
            // Directory for binding resources
            var resourceDirectory = new SimpleServiceDirectory();

            EventTypeIdGenerator eventTypeIdGenerator;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig == null || configSnapshot.EngineDefaults.AlternativeContextConfig.EventTypeIdGeneratorFactory == null)
            {
                eventTypeIdGenerator = new EventTypeIdGeneratorImpl();
            }
            else
            {
                var eventTypeIdGeneratorFactory = TypeHelper.Instantiate <EventTypeIdGeneratorFactory>(
                    configSnapshot.EngineDefaults.AlternativeContextConfig.EventTypeIdGeneratorFactory);
                eventTypeIdGenerator = eventTypeIdGeneratorFactory.Create(new EventTypeIdGeneratorContext(epServiceProvider.URI));
            }

            // Make services that depend on snapshot config entries
            var eventAdapterService = new EventAdapterServiceImpl(eventTypeIdGenerator, configSnapshot.EngineDefaults.EventMetaConfig.AnonymousCacheSize);

            Init(eventAdapterService, configSnapshot);

            // New read-write lock for concurrent event processing
            var eventProcessingRwLock = ReaderWriterLockManager.CreateLock(
                MethodBase.GetCurrentMethod().DeclaringType);

            var timeSourceService     = MakeTimeSource(configSnapshot);
            var schedulingService     = SchedulingServiceProvider.NewService(timeSourceService);
            var schedulingMgmtService = new SchedulingMgmtServiceImpl();
            var engineImportService   = MakeEngineImportService(configSnapshot);
            var engineSettingsService = new EngineSettingsService(configSnapshot.EngineDefaults, configSnapshot.PlugInEventTypeResolutionURIs);
            var databaseConfigService = MakeDatabaseRefService(configSnapshot, schedulingService, schedulingMgmtService);

            var plugInViews = new PluggableObjectCollection();

            plugInViews.AddViews(configSnapshot.PlugInViews, configSnapshot.PlugInVirtualDataWindows);
            var plugInPatternObj = new PluggableObjectCollection();

            plugInPatternObj.AddPatternObjects(configSnapshot.PlugInPatternObjects);

            // exception handling
            ExceptionHandlingService exceptionHandlingService = InitExceptionHandling(
                epServiceProvider.URI,
                configSnapshot.EngineDefaults.ExceptionHandlingConfig,
                configSnapshot.EngineDefaults.ConditionHandlingConfig);

            // Statement context factory
            Type systemVirtualDWViewFactory = null;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig.VirtualDataWindowViewFactory != null)
            {
                try {
                    systemVirtualDWViewFactory = TypeHelper.ResolveType(configSnapshot.EngineDefaults.AlternativeContextConfig.VirtualDataWindowViewFactory);
                    if (!systemVirtualDWViewFactory.IsImplementsInterface(typeof(VirtualDataWindowFactory)))
                    {
                        throw new ConfigurationException("Class " + systemVirtualDWViewFactory.Name + " does not implement the interface " + typeof(VirtualDataWindowFactory).FullName);
                    }
                }
                catch (TypeLoadException e) {
                    throw new ConfigurationException("Failed to look up class " + systemVirtualDWViewFactory);
                }
            }
            StatementContextFactory statementContextFactory = new StatementContextFactoryDefault(plugInViews, plugInPatternObj, systemVirtualDWViewFactory);

            long msecTimerResolution = configSnapshot.EngineDefaults.ThreadingConfig.InternalTimerMsecResolution;

            if (msecTimerResolution <= 0)
            {
                throw new ConfigurationException("Timer resolution configuration not set to a valid value, expecting a non-zero value");
            }
            var timerService = new TimerServiceImpl(epServiceProvider.URI, msecTimerResolution);

            var variableService = new VariableServiceImpl(configSnapshot.EngineDefaults.VariablesConfig.MsecVersionRelease, schedulingService, eventAdapterService, null);

            InitVariables(variableService, configSnapshot.Variables, engineImportService);

            var tableService = new TableServiceImpl();

            var statementLockFactory = new StatementLockFactoryImpl(configSnapshot.EngineDefaults.ExecutionConfig.IsFairlock, configSnapshot.EngineDefaults.ExecutionConfig.IsDisableLocking);
            var streamFactoryService = StreamFactoryServiceProvider.NewService(
                epServiceProvider.URI,
                configSnapshot.EngineDefaults.ViewResourcesConfig.IsShareViews);

            var filterService = FilterServiceProvider.NewService(
                configSnapshot.EngineDefaults.ExecutionConfig.FilterServiceProfile,
                configSnapshot.EngineDefaults.ExecutionConfig.IsAllowIsolatedService);

            var metricsReporting   = new MetricReportingServiceImpl(configSnapshot.EngineDefaults.MetricsReportingConfig, epServiceProvider.URI);
            var namedWindowService = new NamedWindowServiceImpl(
                schedulingService,
                variableService,
                tableService,
                engineSettingsService.EngineSettings.ExecutionConfig.IsPrioritized,
                eventProcessingRwLock,
                exceptionHandlingService,
                configSnapshot.EngineDefaults.LoggingConfig.IsEnableQueryPlan,
                metricsReporting);

            var valueAddEventService = new ValueAddEventServiceImpl();

            valueAddEventService.Init(configSnapshot.RevisionEventTypes, configSnapshot.VariantStreams, eventAdapterService, eventTypeIdGenerator);

            var statementEventTypeRef = new StatementEventTypeRefImpl();
            var statementVariableRef  = new StatementVariableRefImpl(variableService, tableService);

            var threadingService = new ThreadingServiceImpl(
                configSnapshot.EngineDefaults.ThreadingConfig);

            var internalEventRouterImpl = new InternalEventRouterImpl();

            var statementIsolationService = new StatementIsolationServiceImpl();

            DeploymentStateService deploymentStateService = new DeploymentStateServiceImpl();

            StatementMetadataFactory stmtMetadataFactory;

            if (configSnapshot.EngineDefaults.AlternativeContextConfig.StatementMetadataFactory == null)
            {
                stmtMetadataFactory = new StatementMetadataFactoryDefault();
            }
            else
            {
                stmtMetadataFactory = TypeHelper.Instantiate <StatementMetadataFactory>(configSnapshot.EngineDefaults.AlternativeContextConfig.StatementMetadataFactory);
            }

            ContextManagementService contextManagementService = new ContextManagementServiceImpl();

            SchedulableAgentInstanceDirectory schedulableAgentInstanceDirectory = null;     // not required for Non-HA.

            PatternSubexpressionPoolEngineSvc patternSubexpressionPoolSvc = null;

            if (configSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions != null)
            {
                patternSubexpressionPoolSvc = new PatternSubexpressionPoolEngineSvc(
                    configSnapshot.EngineDefaults.PatternsConfig.MaxSubexpressions.GetValueOrDefault(),
                    configSnapshot.EngineDefaults.PatternsConfig.IsMaxSubexpressionPreventStart);
            }

            MatchRecognizeStatePoolEngineSvc matchRecognizeStatePoolEngineSvc = null;

            if (configSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates != null)
            {
                matchRecognizeStatePoolEngineSvc = new MatchRecognizeStatePoolEngineSvc(
                    configSnapshot.EngineDefaults.MatchRecognizeConfig.MaxStates.Value,
                    configSnapshot.EngineDefaults.MatchRecognizeConfig.IsMaxStatesPreventStart);
            }

            var scriptingService = new ScriptingServiceImpl();

            scriptingService.DiscoverEngines();

            // New services context
            EPServicesContext services = new EPServicesContext(
                epServiceProvider.URI, schedulingService,
                eventAdapterService, engineImportService, engineSettingsService, databaseConfigService, plugInViews,
                statementLockFactory, eventProcessingRwLock, null, resourceDirectory, statementContextFactory,
                plugInPatternObj, timerService, filterService, streamFactoryService,
                namedWindowService, variableService, tableService, timeSourceService, valueAddEventService, metricsReporting, statementEventTypeRef,
                statementVariableRef, configSnapshot, threadingService, internalEventRouterImpl, statementIsolationService, schedulingMgmtService,
                deploymentStateService, exceptionHandlingService, new PatternNodeFactoryImpl(), eventTypeIdGenerator, stmtMetadataFactory,
                contextManagementService, schedulableAgentInstanceDirectory, patternSubexpressionPoolSvc, matchRecognizeStatePoolEngineSvc,
                new DataFlowServiceImpl(epServiceProvider, new DataFlowConfigurationStateServiceImpl()),
                new ExprDeclaredServiceImpl(),
                new ContextControllerFactoryFactorySvcImpl(),
                new ContextManagerFactoryServiceImpl(),
                new EPStatementFactoryDefault(),
                new RegexHandlerFactoryDefault(),
                new ViewableActivatorFactoryDefault(),
                scriptingService
                );

            // Engine services subset available to statements
            statementContextFactory.StmtEngineServices = services;

            // Circular dependency
            var statementLifecycleSvc = new StatementLifecycleSvcImpl(epServiceProvider, services);

            services.StatementLifecycleSvc = statementLifecycleSvc;

            // Observers to statement events
            statementLifecycleSvc.LifecycleEvent += (s, theEvent) => metricsReporting.Observe(theEvent);

            // Circular dependency
            statementIsolationService.ServicesContext = services;

            return(services);
        }
コード例 #5
0
 public MatchRecognizeStatePoolStmtSvc(MatchRecognizeStatePoolEngineSvc engineSvc, MatchRecognizeStatePoolStmtHandler stmtHandler)
 {
     _engineSvc   = engineSvc;
     _stmtHandler = stmtHandler;
 }