Пример #1
0
 public EPDeploymentServiceImpl(
     EPServicesContext services,
     EPRuntimeSPI runtime)
 {
     _services = services;
     _runtime  = runtime;
 }
Пример #2
0
        private static DeploymentInternal Deploy(
            bool recovery,
            string deploymentId,
            int statementIdFirstStatement,
            EPCompiled compiled,
            StatementNameRuntimeOption statementNameResolverRuntime,
            StatementUserObjectRuntimeOption userObjectResolverRuntime,
            StatementSubstitutionParameterOption substitutionParameterResolver,
            DeploymentClassLoaderOption deploymentClassLoaderOption,
            EPRuntimeSPI epRuntime)
        {
            // set variable local version
            epRuntime.ServicesContext.VariableManagementService.SetLocalVersion();

            try {
                return(DeploySafe(
                           recovery,
                           deploymentId,
                           statementIdFirstStatement,
                           compiled,
                           statementNameResolverRuntime,
                           userObjectResolverRuntime,
                           substitutionParameterResolver,
                           deploymentClassLoaderOption,
                           epRuntime));
            }
            catch (EPDeployException) {
                throw;
            }
            catch (Exception ex) {
                throw new EPDeployException(ex.Message, ex, -1);
            }
        }
Пример #3
0
 public StmtNamedWindowUpdateCallable(String threadName,
                                      EPServiceProvider engine,
                                      int numRepeats)
 {
     _engine     = (EPRuntimeSPI)engine.EPRuntime;
     _numRepeats = numRepeats;
     _threadName = threadName;
 }
Пример #4
0
 public void SetContext(
     EPStatementSPI epStatement,
     EPRuntimeSPI runtime)
 {
     _epStatement = epStatement;
     _runtime = runtime;
     _statementMetricHandle = epStatement.StatementContext.EpStatementHandle.MetricsHandle;
 }
Пример #5
0
        private void RunAssertionNextScheduledTime(EPServiceProvider epService)
        {
            EPRuntimeSPI runtimeSPI = (EPRuntimeSPI)epService.EPRuntime;

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            Assert.IsNull(epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new Object[0][]);

            EPStatement stmtOne = epService.EPAdministrator.CreateEPL("select * from pattern[timer:interval(2 sec)]");

            Assert.AreEqual(2000L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { stmtOne.Name, 2000L } });

            EPStatement stmtTwo = epService.EPAdministrator.CreateEPL("@Name('s2') select * from pattern[timer:interval(150 msec)]");

            Assert.AreEqual(150L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { "s2", 150L }, new object[] { stmtOne.Name, 2000L } });

            stmtTwo.Dispose();
            Assert.AreEqual(2000L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { stmtOne.Name, 2000L } });

            EPStatement stmtThree = epService.EPAdministrator.CreateEPL("select * from pattern[timer:interval(3 sec) and timer:interval(4 sec)]");

            Assert.AreEqual(2000L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { stmtOne.Name, 2000L }, new object[] { stmtThree.Name, 3000L } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(2500));
            Assert.AreEqual(3000L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { stmtThree.Name, 3000L } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(3500));
            Assert.AreEqual(4000L, (long)epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new object[][] { new object[] { stmtThree.Name, 4000L } });

            epService.EPRuntime.SendEvent(new CurrentTimeEvent(4500));
            Assert.AreEqual(null, epService.EPRuntime.NextScheduledTime);
            AssertSchedules(runtimeSPI.StatementNearestSchedules, new Object[0][]);

            // test isolated service
            EPServiceProviderIsolated isolated    = epService.GetEPServiceIsolated("I1");
            EPRuntimeIsolatedSPI      isolatedSPI = (EPRuntimeIsolatedSPI)isolated.EPRuntime;

            isolated.EPRuntime.SendEvent(new CurrentTimeEvent(0));
            Assert.IsNull(isolated.EPRuntime.NextScheduledTime);
            AssertSchedules(isolatedSPI.StatementNearestSchedules, new Object[0][]);

            EPStatement stmtFour = isolated.EPAdministrator.CreateEPL("select * from pattern[timer:interval(2 sec)]", null, null);

            Assert.AreEqual(2000L, (long)isolatedSPI.NextScheduledTime);
            AssertSchedules(isolatedSPI.StatementNearestSchedules, new object[][] { new object[] { stmtFour.Name, 2000L } });

            isolated.Dispose();
            epService.EPAdministrator.DestroyAllStatements();
        }
Пример #6
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="runtimeSPI">The runtime SPI.</param>
 /// <param name="services">engine services</param>
 /// <param name="configurationOperations">configuration snapshot</param>
 /// <param name="defaultStreamSelector">default stream selection</param>
 public EPAdministratorContext(EPRuntimeSPI runtimeSPI,
                               EPServicesContext services,
                               ConfigurationOperations configurationOperations,
                               SelectClauseStreamSelectorEnum defaultStreamSelector
                               )
 {
     RuntimeSPI = runtimeSPI;
     ConfigurationOperations = configurationOperations;
     DefaultStreamSelector   = defaultStreamSelector;
     Services = services;
 }
Пример #7
0
 public EPServiceEngine(
     IContainer container,
     EPServicesContext services,
     EPRuntimeSPI runtimeSPI,
     EPAdministratorSPI admin)
 {
     Container = container;
     Services  = services;
     Runtime   = runtimeSPI;
     Admin     = admin;
 }
Пример #8
0
        private static EPStatementSPI MakeStatement(
            UpdateDispatchView dispatchChildView,
            StatementContext statementContext,
            StatementResultServiceImpl statementResultService,
            EPRuntimeSPI epRuntime)
        {
            var epStatement =
                epRuntime.ServicesContext.EpStatementFactory.Statement(new EPStatementFactoryArgs(statementContext, dispatchChildView, statementResultService));
            var info = statementContext.StatementInformationals;

            statementResultService.SetSelectClause(info.SelectClauseTypes, info.SelectClauseColumnNames, info.IsForClauseDelivery, info.GroupDeliveryEval);
            statementResultService.SetContext(epStatement, epRuntime);
            return(epStatement);
        }
Пример #9
0
        public void SetUp()
        {
            Configuration configuration = SupportConfigFactory.GetConfiguration();

            configuration.EngineDefaults.ViewResourcesConfig.IsShareViews       = false;
            configuration.EngineDefaults.ExecutionConfig.IsAllowIsolatedService = true;
            configuration.AddEventType("SupportBean", typeof(SupportBean).FullName);
            _epService = EPServiceProviderManager.GetDefaultProvider(configuration);
            _epService.Initialize();
            if (InstrumentationHelper.ENABLED)
            {
                InstrumentationHelper.StartTest(_epService, GetType(), GetType().FullName);
            }
            _runtimeSpi = (EPRuntimeSPI)_epService.EPRuntime;
            _listener   = new SupportUpdateListener();
        }
Пример #10
0
        internal static EPStatement[] DeployStatements(
            int rolloutItemNumber,
            IList <StatementLightweight> lightweights,
            bool recovery,
            DeployerModulePaths modulePaths,
            ModuleProviderCLPair provider,
            string deploymentId,
            EPRuntimeSPI epRuntime)
        {
            var statements = new EPStatement[lightweights.Count];
            var count      = 0;

            foreach (var lightweight in lightweights)
            {
                EPStatementSPI stmt;
                try {
                    stmt = DeployerHelperStatement.DeployStatement(recovery, lightweight, epRuntime);
                }
                catch (Exception ex) {
                    try {
                        ReverseDeployment(deploymentId, modulePaths.DeploymentTypes, lightweights, statements, provider, epRuntime.ServicesContext);
                    }
                    catch (Exception udex) {
                        log.Warn(udex.Message, udex);
                    }

                    throw new EPDeployException("Failed to deploy: " + ex.Message, ex, rolloutItemNumber);
                }

                statements[count++] = stmt;

                if (InstrumentationHelper.ENABLED)
                {
                    InstrumentationHelper.Get()
                    .QaEngineManagementStmtStarted(
                        epRuntime.URI,
                        deploymentId,
                        lightweight.StatementContext.StatementId,
                        stmt.Name,
                        (string)stmt.GetProperty(StatementProperty.EPL),
                        epRuntime.EventService.CurrentTime);
                }
            }

            return(statements);
        }
Пример #11
0
 public static DeploymentInternal DeployRecover(
     string deploymentId,
     int statementIdFirstStatement,
     EPCompiled compiled,
     StatementNameRuntimeOption statementNameResolverRuntime,
     StatementUserObjectRuntimeOption userObjectResolverRuntime,
     StatementSubstitutionParameterOption substitutionParameterResolver,
     DeploymentClassLoaderOption deploymentClassLoaderOption,
     EPRuntimeSPI epRuntime)
 {
     return(Deploy(
                true,
                deploymentId,
                statementIdFirstStatement,
                compiled,
                statementNameResolverRuntime,
                userObjectResolverRuntime,
                substitutionParameterResolver,
                deploymentClassLoaderOption,
                epRuntime));
 }
Пример #12
0
 public EPServicesContext(
     IContainer container,
     AggregationServiceFactoryService aggregationServiceFactoryService,
     BeanEventTypeFactoryPrivate beanEventTypeFactoryPrivate,
     BeanEventTypeStemService beanEventTypeStemService,
     ClassForNameProvider classForNameProvider,
     ParentClassLoader classLoaderParent,
     PathRegistry <string, ClassProvided> classProvidedPathRegistry,
     Configuration configSnapshot,
     ContextManagementService contextManagementService,
     PathRegistry <string, ContextMetaData> contextPathRegistry,
     ContextServiceFactory contextServiceFactory,
     EPDataFlowServiceImpl dataflowService,
     DataFlowFilterServiceAdapter dataFlowFilterServiceAdapter,
     DatabaseConfigServiceRuntime databaseConfigServiceRuntime,
     DeploymentLifecycleService deploymentLifecycleService,
     DispatchService dispatchService,
     RuntimeEnvContext runtimeEnvContext,
     RuntimeSettingsService runtimeSettingsService,
     string runtimeURI,
     ImportServiceRuntime importServiceRuntime,
     EPStatementFactory epStatementFactory,
     PathRegistry <string, ExpressionDeclItem> exprDeclaredPathRegistry,
     IReaderWriterLock eventProcessingRWLock,
     EPServicesHA epServicesHA,
     EPRuntimeSPI epRuntime,
     EventBeanService eventBeanService,
     EventBeanTypedEventFactory eventBeanTypedEventFactory,
     EPRenderEventServiceImpl eventRenderer,
     EventSerdeFactory eventSerdeFactory,
     EventTableIndexService eventTableIndexService,
     EventTypeAvroHandler eventTypeAvroHandler,
     EventTypeFactory eventTypeFactory,
     EventTypeIdResolver eventTypeIdResolver,
     PathRegistry <string, EventType> eventTypePathRegistry,
     EventTypeRepositoryImpl eventTypeRepositoryBus,
     EventTypeResolvingBeanFactory eventTypeResolvingBeanFactory,
     EventTypeSerdeRepository eventTypeSerdeRepository,
     ExceptionHandlingService exceptionHandlingService,
     ExpressionResultCacheService expressionResultCacheService,
     FilterBooleanExpressionFactory filterBooleanExpressionFactory,
     FilterServiceSPI filterService,
     FilterSharedBoolExprRepository filterSharedBoolExprRepository,
     FilterSharedLookupableRepository filterSharedLookupableRepository,
     HistoricalDataCacheFactory historicalDataCacheFactory,
     InternalEventRouterImpl internalEventRouter,
     MetricReportingService metricReportingService,
     MultiMatchHandlerFactory multiMatchHandlerFactory,
     NamedWindowConsumerManagementService namedWindowConsumerManagementService,
     NamedWindowDispatchService namedWindowDispatchService,
     NamedWindowFactoryService namedWindowFactoryService,
     NamedWindowManagementService namedWindowManagementService,
     PathRegistry <string, NamedWindowMetaData> namedWindowPathRegistry,
     PatternFactoryService patternFactoryService,
     PatternSubexpressionPoolRuntimeSvc patternSubexpressionPoolEngineSvc,
     ResultSetProcessorHelperFactory resultSetProcessorHelperFactory,
     RowRecogStateRepoFactory rowRecogStateRepoFactory,
     RowRecogStatePoolRuntimeSvc rowRecogStatePoolEngineSvc,
     SchedulingServiceSPI schedulingService,
     PathRegistry <NameAndParamNum, ExpressionScriptProvided> scriptPathRegistry,
     ScriptCompiler scriptCompiler,
     StageRecoveryService stageRecoveryService,
     StatementLifecycleService statementLifecycleService,
     StatementAgentInstanceLockFactory statementAgentInstanceLockFactory,
     StatementResourceHolderBuilder statementResourceHolderBuilder,
     TableExprEvaluatorContext tableExprEvaluatorContext,
     TableManagementService tableManagementService,
     PathRegistry <string, TableMetaData> tablePathRegistry,
     ThreadingService threadingService,
     TimeAbacus timeAbacus,
     TimeSourceService timeSourceService,
     TimerService timerService,
     VariableManagementService variableManagementService,
     PathRegistry <string, VariableMetaData> variablePathRegistry,
     ViewableActivatorFactory viewableActivatorFactory,
     ViewFactoryService viewFactoryService,
     ViewServicePreviousFactory viewServicePreviousFactory,
     XMLFragmentEventTypeFactory xmlFragmentEventTypeFactory)
 {
     _container = container;
     _aggregationServiceFactoryService = aggregationServiceFactoryService;
     _beanEventTypeFactoryPrivate      = beanEventTypeFactoryPrivate;
     _beanEventTypeStemService         = beanEventTypeStemService;
     _classForNameProvider             = classForNameProvider;
     _classLoaderParent            = classLoaderParent;
     _classProvidedPathRegistry    = classProvidedPathRegistry;
     _configSnapshot               = configSnapshot;
     _contextManagementService     = contextManagementService;
     _contextPathRegistry          = contextPathRegistry;
     _contextServiceFactory        = contextServiceFactory;
     _dataflowService              = dataflowService;
     _dataFlowFilterServiceAdapter = dataFlowFilterServiceAdapter;
     _databaseConfigServiceRuntime = databaseConfigServiceRuntime;
     _deploymentLifecycleService   = deploymentLifecycleService;
     _dispatchService              = dispatchService;
     _runtimeEnvContext            = runtimeEnvContext;
     _runtimeSettingsService       = runtimeSettingsService;
     _runtimeUri               = runtimeURI;
     _importServiceRuntime     = importServiceRuntime;
     _epStatementFactory       = epStatementFactory;
     _exprDeclaredPathRegistry = exprDeclaredPathRegistry;
     _eventProcessingRWLock    = eventProcessingRWLock;
     _epServicesHA             = epServicesHA;
     _epRuntime                            = epRuntime;
     _eventBeanService                     = eventBeanService;
     _eventBeanTypedEventFactory           = eventBeanTypedEventFactory;
     _eventRenderer                        = eventRenderer;
     _eventSerdeFactory                    = eventSerdeFactory;
     _eventTableIndexService               = eventTableIndexService;
     _eventTypeAvroHandler                 = eventTypeAvroHandler;
     _eventTypeFactory                     = eventTypeFactory;
     _eventTypeIdResolver                  = eventTypeIdResolver;
     _eventTypePathRegistry                = eventTypePathRegistry;
     _eventTypeRepositoryBus               = eventTypeRepositoryBus;
     _eventTypeResolvingBeanFactory        = eventTypeResolvingBeanFactory;
     _eventTypeSerdeRepository             = eventTypeSerdeRepository;
     _exceptionHandlingService             = exceptionHandlingService;
     _expressionResultCacheService         = expressionResultCacheService;
     _filterBooleanExpressionFactory       = filterBooleanExpressionFactory;
     _filterService                        = filterService;
     _filterSharedBoolExprRepository       = filterSharedBoolExprRepository;
     _filterSharedLookupableRepository     = filterSharedLookupableRepository;
     _historicalDataCacheFactory           = historicalDataCacheFactory;
     _internalEventRouter                  = internalEventRouter;
     _metricReportingService               = metricReportingService;
     _multiMatchHandlerFactory             = multiMatchHandlerFactory;
     _namedWindowConsumerManagementService = namedWindowConsumerManagementService;
     _namedWindowDispatchService           = namedWindowDispatchService;
     _namedWindowFactoryService            = namedWindowFactoryService;
     _namedWindowManagementService         = namedWindowManagementService;
     _namedWindowPathRegistry              = namedWindowPathRegistry;
     _patternFactoryService                = patternFactoryService;
     _patternSubexpressionPoolEngineSvc    = patternSubexpressionPoolEngineSvc;
     _resultSetProcessorHelperFactory      = resultSetProcessorHelperFactory;
     _rowRecogStateRepoFactory             = rowRecogStateRepoFactory;
     _rowRecogStatePoolEngineSvc           = rowRecogStatePoolEngineSvc;
     _schedulingService                    = schedulingService;
     _scriptPathRegistry                   = scriptPathRegistry;
     _stageRecoveryService                 = stageRecoveryService;
     _statementLifecycleService            = statementLifecycleService;
     _statementAgentInstanceLockFactory    = statementAgentInstanceLockFactory;
     _statementResourceHolderBuilder       = statementResourceHolderBuilder;
     _tableExprEvaluatorContext            = tableExprEvaluatorContext;
     _tableManagementService               = tableManagementService;
     _tablePathRegistry                    = tablePathRegistry;
     _threadingService                     = threadingService;
     _timeAbacus                           = timeAbacus;
     _timeSourceService                    = timeSourceService;
     _timerService                         = timerService;
     _variableManagementService            = variableManagementService;
     _variablePathRegistry                 = variablePathRegistry;
     _viewableActivatorFactory             = viewableActivatorFactory;
     _viewFactoryService                   = viewFactoryService;
     _viewServicePreviousFactory           = viewServicePreviousFactory;
     _xmlFragmentEventTypeFactory          = xmlFragmentEventTypeFactory;
     _scriptCompiler                       = scriptCompiler;
 }
Пример #13
0
        public EPServicesContext CreateServicesContext(
            EPRuntimeSPI epRuntime,
            Configuration configs)
        {
            var container = epRuntime.Container;
            var runtimeEnvContext = new RuntimeEnvContext();
            var eventProcessingRWLock = epRuntime.Container.RWLockManager().CreateLock("EventProcLock");
            var deploymentLifecycleService = new DeploymentLifecycleServiceImpl(-1);

            var runtimeSettingsService = MakeRuntimeSettingsService(configs);

            var scriptCompiler = new ScriptCompilerImpl(container, configs.Common);
            
            var timeAbacus = TimeAbacusFactory.Make(configs.Common.TimeSource.TimeUnit);
            var timeZone = configs.Runtime.Expression.TimeZone ?? TimeZoneInfo.Utc;
            var importServiceRuntime = new ImportServiceRuntime(
                container,
                configs.Common.TransientConfiguration, timeAbacus,
                configs.Common.EventTypeAutoNameNamespaces, timeZone,
                configs.Common.MethodInvocationReferences,
                configs.Common.Imports,
                configs.Common.AnnotationImports);

            var epServicesHA = InitHA(epRuntime.URI, configs, runtimeEnvContext, eventProcessingRWLock, runtimeSettingsService);

            var eventTypeAvroHandler = MakeEventTypeAvroHandler(
                importServiceRuntime, configs.Common.EventMeta.AvroSettings, epServicesHA.RuntimeExtensionServices);
            var resolvedBeanEventTypes = BeanEventTypeRepoUtil.ResolveBeanEventTypes(configs.Common.EventTypeNames, importServiceRuntime);
            var eventBeanTypedEventFactory = MakeEventBeanTypedEventFactory(eventTypeAvroHandler);
            var beanEventTypeStemService =
                BeanEventTypeRepoUtil.MakeBeanEventTypeStemService(configs, resolvedBeanEventTypes, eventBeanTypedEventFactory);
            var eventTypeRepositoryPreconfigured = new EventTypeRepositoryImpl(false);
            var eventTypeFactory = MakeEventTypeFactory(
                epServicesHA.RuntimeExtensionServices, eventTypeRepositoryPreconfigured, deploymentLifecycleService, eventBeanTypedEventFactory);
            var beanEventTypeFactoryPrivate = new BeanEventTypeFactoryPrivate(eventBeanTypedEventFactory, eventTypeFactory, beanEventTypeStemService);
            
            EventTypeRepositoryBeanTypeUtil.BuildBeanTypes(
                beanEventTypeStemService,
                eventTypeRepositoryPreconfigured,
                resolvedBeanEventTypes,
                beanEventTypeFactoryPrivate,
                configs.Common.EventTypesBean);
            EventTypeRepositoryMapTypeUtil.BuildMapTypes(
                eventTypeRepositoryPreconfigured,
                configs.Common.MapTypeConfigurations,
                configs.Common.EventTypesMapEvents,
                configs.Common.EventTypesNestableMapEvents,
                beanEventTypeFactoryPrivate,
                importServiceRuntime);
            EventTypeRepositoryOATypeUtil.BuildOATypes(
                eventTypeRepositoryPreconfigured,
                configs.Common.ObjectArrayTypeConfigurations,
                configs.Common.EventTypesNestableObjectArrayEvents,
                beanEventTypeFactoryPrivate, 
                importServiceRuntime);
            
            var xmlFragmentEventTypeFactory = new XMLFragmentEventTypeFactory(beanEventTypeFactoryPrivate, null, eventTypeRepositoryPreconfigured);
            
            EventTypeRepositoryXMLTypeUtil.BuildXMLTypes(
                eventTypeRepositoryPreconfigured,
                configs.Common.EventTypesXMLDOM,
                beanEventTypeFactoryPrivate,
                xmlFragmentEventTypeFactory,
                container.ResourceManager());
                //importServiceRuntime
            EventTypeRepositoryAvroTypeUtil.BuildAvroTypes(
                eventTypeRepositoryPreconfigured, configs.Common.EventTypesAvro, eventTypeAvroHandler,
                beanEventTypeFactoryPrivate.EventBeanTypedEventFactory);
            EventTypeRepositoryVariantStreamUtil.BuildVariantStreams(
                eventTypeRepositoryPreconfigured, configs.Common.VariantStreams, eventTypeFactory);

            var eventTypeResolvingBeanFactory = MakeEventTypeResolvingBeanFactory(eventTypeRepositoryPreconfigured, eventTypeAvroHandler);

            var viewableActivatorFactory = InitViewableActivatorFactory();

            var statementLifecycleService = new StatementLifecycleServiceImpl();

            EventTypeIdResolver eventTypeIdResolver = new ProxyEventTypeIdResolver {
                ProcGetTypeById = (
                    eventTypeIdPublic,
                    eventTypeIdProtected) => {
                    if (eventTypeIdProtected == -1) {
                        return eventTypeRepositoryPreconfigured.GetTypeById(eventTypeIdPublic);
                    }

                    var deployerResult = deploymentLifecycleService.GetDeploymentByCRC(eventTypeIdPublic);
                    return deployerResult.DeploymentTypes.Get(eventTypeIdProtected);
                }
            };
            var filterSharedBoolExprRepository = MakeFilterSharedBoolExprRepository();
            var filterSharedLookupableRepository = MakeFilterSharedLookupableRepository();
            var filterServiceSPI = MakeFilterService(
                epServicesHA.RuntimeExtensionServices, eventTypeRepositoryPreconfigured, statementLifecycleService, runtimeSettingsService,
                eventTypeIdResolver, filterSharedLookupableRepository);
            var filterBooleanExpressionFactory = MakeFilterBooleanExpressionFactory(statementLifecycleService);

            var statementResourceHolderBuilder = MakeStatementResourceHolderBuilder();

            var aggregationServiceFactoryService = MakeAggregationServiceFactoryService(epServicesHA.RuntimeExtensionServices);

            var viewFactoryService = MakeViewFactoryService();
            var patternFactoryService = MakePatternFactoryService();

            var exceptionHandlingService = InitExceptionHandling(
                epRuntime.URI, configs.Runtime.ExceptionHandling, configs.Runtime.ConditionHandling, ClassForNameProviderDefault.INSTANCE);

            var timeSourceService = MakeTimeSource(configs);
            var schedulingService = MakeSchedulingService(
                epServicesHA,
                timeSourceService,
                epServicesHA.RuntimeExtensionServices,
                runtimeSettingsService,
                statementLifecycleService,
                importServiceRuntime.TimeZone.Id);

            var internalEventRouter = new InternalEventRouterImpl(eventBeanTypedEventFactory);

            var multiMatchHandlerFactory = MakeMultiMatchHandlerFactory(configs);

            var dispatchService = new DispatchService();
            var contextServiceFactory = MakeContextServiceFactory(epServicesHA.RuntimeExtensionServices);
            ContextManagementService contextManagementService = new ContextManagementServiceImpl();

            var viewServicePreviousFactory = MakeViewServicePreviousFactory(epServicesHA.RuntimeExtensionServices);

            var epStatementFactory = MakeEPStatementFactory();

            var msecTimerResolution = configs.Runtime.Threading.InternalTimerMsecResolution;
            if (msecTimerResolution <= 0) {
                throw new ConfigurationException("Timer resolution configuration not set to a valid value, expecting a non-zero value");
            }

            TimerService timerService = new TimerServiceImpl(epRuntime.URI, msecTimerResolution);
            StatementAgentInstanceLockFactory statementAgentInstanceLockFactory = new StatementAgentInstanceLockFactoryImpl(
                configs.Runtime.Execution.IsFairlock, configs.Runtime.Execution.IsDisableLocking);

            var eventTableIndexService = MakeEventTableIndexService(epServicesHA.RuntimeExtensionServices);
            var expressionResultCacheSharable = new ExpressionResultCacheService(
                configs.Runtime.Execution.DeclaredExprValueCacheSize,
                epRuntime.Container.ThreadLocalManager());

            var resultSetProcessorHelperFactory = MakeResultSetProcessorHelperFactory(epServicesHA.RuntimeExtensionServices);

            var variableRepositoryPreconfigured = new VariableRepositoryPreconfigured();
            VariableUtil.ConfigureVariables(
                variableRepositoryPreconfigured, configs.Common.Variables, importServiceRuntime, eventBeanTypedEventFactory,
                eventTypeRepositoryPreconfigured, beanEventTypeFactoryPrivate);
            var variableManagementService = MakeVariableManagementService(
                configs, schedulingService, eventBeanTypedEventFactory, runtimeSettingsService, epServicesHA);
            foreach (var publicVariable in variableRepositoryPreconfigured.Metadata) {
                variableManagementService.AddVariable(null, publicVariable.Value, null, null);
                variableManagementService.AllocateVariableState(
                    null, publicVariable.Key, DEFAULT_AGENT_INSTANCE_ID, false, null, eventBeanTypedEventFactory);
            }

            var variablePathRegistry = new PathRegistry<string, VariableMetaData>(PathRegistryObjectType.VARIABLE);

            var tableExprEvaluatorContext = new TableExprEvaluatorContext(
                epRuntime.Container.ThreadLocalManager());
            var tableManagementService = MakeTableManagementService(epServicesHA.RuntimeExtensionServices, tableExprEvaluatorContext);
            var tablePathRegistry = new PathRegistry<string, TableMetaData>(PathRegistryObjectType.TABLE);

            var metricsReporting = new MetricReportingServiceImpl(
                configs.Runtime.MetricsReporting, epRuntime.URI, container.RWLockManager());

            var namedWindowFactoryService = MakeNamedWindowFactoryService();
            var namedWindowDispatchService = MakeNamedWindowDispatchService(
                schedulingService, configs, eventProcessingRWLock, exceptionHandlingService, variableManagementService, tableManagementService,
                metricsReporting);
            NamedWindowManagementService namedWindowManagementService = new NamedWindowManagementServiceImpl();
            var namedWindowConsumerManagementService = MakeNamedWindowConsumerManagementService(namedWindowManagementService);

            var pathNamedWindowRegistry = new PathRegistry<string, NamedWindowMetaData>(PathRegistryObjectType.NAMEDWINDOW);
            var eventTypePathRegistry = new PathRegistry<string, EventType>(PathRegistryObjectType.EVENTTYPE);
            var pathContextRegistry = new PathRegistry<string, ContextMetaData>(PathRegistryObjectType.CONTEXT);
            EventBeanService eventBeanService = new EventBeanServiceImpl(
                eventTypeRepositoryPreconfigured, eventTypePathRegistry, eventBeanTypedEventFactory);

            PatternSubexpressionPoolRuntimeSvc patternSubexpressionPoolSvc;
            if (configs.Runtime.Patterns.MaxSubexpressions != null) {
                patternSubexpressionPoolSvc = new PatternSubexpressionPoolRuntimeSvcImpl(
                    configs.Runtime.Patterns.MaxSubexpressions.Value,
                    configs.Runtime.Patterns.IsMaxSubexpressionPreventStart);
            }
            else {
                patternSubexpressionPoolSvc = PatternSubexpressionPoolRuntimeSvcNoOp.INSTANCE;
            }

            var exprDeclaredPathRegistry = new PathRegistry<string, ExpressionDeclItem>(PathRegistryObjectType.EXPRDECL);
            var scriptPathRegistry = new PathRegistry<NameAndParamNum, ExpressionScriptProvided>(PathRegistryObjectType.SCRIPT);

            RowRecogStatePoolRuntimeSvc rowRecogStatePoolEngineSvc = null;
            if (configs.Runtime.MatchRecognize.MaxStates != null) {
                rowRecogStatePoolEngineSvc = new RowRecogStatePoolRuntimeSvc(
                    configs.Runtime.MatchRecognize.MaxStates.Value,
                    configs.Runtime.MatchRecognize.IsMaxStatesPreventStart);
            }

            var rowRecogStateRepoFactory = MakeRowRecogStateRepoFactory();

            DatabaseConfigServiceRuntime databaseConfigServiceRuntime =
                new DatabaseConfigServiceImpl(
                    container,
                    configs.Common.DatabaseReferences,
                    importServiceRuntime);
            var historicalDataCacheFactory = MakeHistoricalDataCacheFactory(epServicesHA.RuntimeExtensionServices);

            var dataflowService = new EPDataFlowServiceImpl(container);
            var dataFlowFilterServiceAdapter = MakeDataFlowFilterServiceAdapter();

            var threadingService = MakeThreadingService(configs);
            var eventRenderer = new EPRenderEventServiceImpl();

            var eventSerdeFactory = MakeEventSerdeFactory(epServicesHA.RuntimeExtensionServices);
            var eventTypeSerdeRepository = MakeEventTypeSerdeRepository(eventTypeRepositoryPreconfigured, eventTypePathRegistry);
            var classLoaderParent = new ParentClassLoader(importServiceRuntime.ClassLoader);

            var stageRecoveryService = MakeStageRecoveryService(epServicesHA);

            var classProvidedPathRegistry = new PathRegistry<string, ClassProvided>(PathRegistryObjectType.CLASSPROVIDED);

            return new EPServicesContext(
                container,
                aggregationServiceFactoryService,
                beanEventTypeFactoryPrivate,
                beanEventTypeStemService,
                ClassForNameProviderDefault.INSTANCE,
                classLoaderParent,
                classProvidedPathRegistry,
                configs,
                contextManagementService,
                pathContextRegistry,
                contextServiceFactory,
                dataflowService,
                dataFlowFilterServiceAdapter,
                databaseConfigServiceRuntime,
                deploymentLifecycleService,
                dispatchService,
                runtimeEnvContext,
                runtimeSettingsService,
                epRuntime.URI,
                importServiceRuntime,
                epStatementFactory,
                exprDeclaredPathRegistry,
                eventProcessingRWLock,
                epServicesHA,
                epRuntime,
                eventBeanService,
                eventBeanTypedEventFactory,
                eventRenderer,
                eventSerdeFactory,
                eventTableIndexService,
                eventTypeAvroHandler,
                eventTypeFactory,
                eventTypeIdResolver,
                eventTypePathRegistry,
                eventTypeRepositoryPreconfigured,
                eventTypeResolvingBeanFactory,
                eventTypeSerdeRepository,
                exceptionHandlingService,
                expressionResultCacheSharable,
                filterBooleanExpressionFactory,
                filterServiceSPI,
                filterSharedBoolExprRepository,
                filterSharedLookupableRepository,
                historicalDataCacheFactory,
                internalEventRouter,
                metricsReporting,
                multiMatchHandlerFactory,
                namedWindowConsumerManagementService,
                namedWindowDispatchService,
                namedWindowFactoryService,
                namedWindowManagementService,
                pathNamedWindowRegistry,
                patternFactoryService,
                patternSubexpressionPoolSvc,
                resultSetProcessorHelperFactory,
                rowRecogStateRepoFactory,
                rowRecogStatePoolEngineSvc,
                schedulingService,
                scriptPathRegistry,
                scriptCompiler,
                stageRecoveryService,
                statementLifecycleService,
                statementAgentInstanceLockFactory,
                statementResourceHolderBuilder,
                tableExprEvaluatorContext,
                tableManagementService,
                tablePathRegistry,
                threadingService,
                timeAbacus,
                timeSourceService,
                timerService,
                variableManagementService,
                variablePathRegistry,
                viewableActivatorFactory,
                viewFactoryService,
                viewServicePreviousFactory,
                xmlFragmentEventTypeFactory);
        }
Пример #14
0
        private static EPStatementSPI DeployStatement(
            bool recovery,
            StatementLightweight lightweight,
            EPRuntimeSPI epRuntime)
        {
            // statement-create: safe operation for registering things
            var statementAgentInstanceFactory = lightweight.StatementContext.StatementAIFactoryProvider.Factory;

            statementAgentInstanceFactory.StatementCreate(lightweight.StatementContext);

            // add statement
            var stmt = MakeStatement(
                lightweight.StatementContext.UpdateDispatchView,
                lightweight.StatementContext,
                (StatementResultServiceImpl)lightweight.StatementResultService,
                epRuntime);

            // add statement to globals
            epRuntime.ServicesContext.StatementLifecycleService.AddStatement(stmt);             // it is now available for lookup

            Viewable finalView;
            StatementDestroyCallback statementDestroyCallback;
            ICollection <StatementAgentInstancePreload> preloads = null;
            var contextName = lightweight.StatementInformationals.OptionalContextName;

            if (contextName == null)
            {
                var result = StartStatementNoContext(lightweight, recovery, epRuntime.ServicesContext);
                finalView = result.FinalView;
                preloads  = result.PreloadList;
                var createContextStmt = result is StatementAgentInstanceFactoryCreateContextResult;
                statementDestroyCallback = new ProxyStatementDestroyCallback()
                {
                    ProcDestroy = (
                        destroyServices,
                        statementContext) => {
                        // All statements other that create-context: get the agent-instance-context and stop
                        // Create-context statements already got destroyed when the last statement associated to context was removed.
                        if (!createContextStmt)
                        {
                            var holder = statementContext.StatementCPCacheService.MakeOrGetEntryCanNull(-1, statementContext);
                            holder.AgentInstanceStopCallback.Stop(new AgentInstanceStopServices(holder.AgentInstanceContext));
                        }

                        // Invoke statement-destroy
                        statementAgentInstanceFactory.StatementDestroy(lightweight.StatementContext);
                    },
                };

                // assign
                StatementAIFactoryAssignments assignments = new StatementAIFactoryAssignmentsImpl(
                    result.OptionalAggegationService,
                    result.PriorStrategies,
                    result.PreviousGetterStrategies,
                    result.SubselectStrategies,
                    result.TableAccessStrategies,
                    result.RowRecogPreviousStrategy);
                lightweight.StatementContext.StatementAIFactoryProvider.Assign(assignments);
            }
            else
            {
                var contextModuleName           = lightweight.StatementInformationals.OptionalContextModuleName;
                var statementAIResourceRegistry = lightweight.StatementContext.StatementAIResourceRegistry;

                var contextVisibility   = lightweight.StatementInformationals.OptionalContextVisibility;
                var contextDeploymentId = ContextDeployTimeResolver.ResolveContextDeploymentId(
                    contextModuleName,
                    contextVisibility,
                    contextName,
                    lightweight.StatementContext.DeploymentId,
                    lightweight.StatementContext.PathContextRegistry);

                var contextMergeView = lightweight.StatementInformationals.StatementType.IsOnTriggerInfra()
                                        ? new ContextMergeViewForwarding(null)
                                        : new ContextMergeView(null);
                finalView = contextMergeView;
                var statement = new ContextControllerStatementDesc(lightweight, contextMergeView);

                // assignments before add-statement, since add-statement creates context partitions which may preload
                lightweight.StatementContext.StatementAIFactoryProvider.Assign(new StatementAIFactoryAssignmentContext(statementAIResourceRegistry));

                // add statement
                epRuntime.ServicesContext.ContextManagementService.AddStatement(contextDeploymentId, contextName, statement, recovery);
                statementDestroyCallback = new ProxyStatementDestroyCallback()
                {
                    ProcDestroy = (
                        destroyServices,
                        statementContext) => {
                        var ctx = statement.Lightweight.StatementContext;
                        epRuntime.ServicesContext.ContextManagementService.StoppedStatement(
                            contextDeploymentId,
                            contextName,
                            ctx.StatementId,
                            ctx.StatementName,
                            ctx.DeploymentId);
                        statementAgentInstanceFactory.StatementDestroy(lightweight.StatementContext);
                    },
                };
            }

            // make dispatch view
            finalView.Child = lightweight.StatementContext.UpdateDispatchView;

            // assign parent view
            stmt.StatementContext.DestroyCallback = statementDestroyCallback;
            stmt.ParentView = finalView;

            // execute preloads
            if (preloads != null)
            {
                foreach (var preload in preloads)
                {
                    preload.ExecutePreload();
                }
            }

            return(stmt);
        }
Пример #15
0
 public EPServiceEngine(EPServicesContext services, EPRuntimeSPI runtimeSPI, EPAdministratorSPI admin)
 {
     Services = services;
     Runtime  = runtimeSPI;
     Admin    = admin;
 }
Пример #16
0
 public StmtNamedWindowQueryCallable(String threadKey, EPServiceProvider engine, int numRepeats)
 {
     _engine     = (EPRuntimeSPI)engine.EPRuntime;
     _numRepeats = numRepeats;
     _threadKey  = threadKey;
 }
 public StmtNamedWindowMergeCallable(EPServiceProvider engine, int numEvents)
 {
     this._engine    = (EPRuntimeSPI)engine.EPRuntime;
     this._numEvents = numEvents;
 }
Пример #18
0
        private static DeploymentInternal DeploySafe(
            bool recovery,
            string deploymentId,
            int statementIdFirstStatement,
            EPCompiled compiled,
            StatementNameRuntimeOption statementNameResolverRuntime,
            StatementUserObjectRuntimeOption userObjectResolverRuntime,
            StatementSubstitutionParameterOption substitutionParameterResolver,
            DeploymentClassLoaderOption deploymentClassLoaderOption,
            EPRuntimeSPI epRuntime)
        {
            var services = epRuntime.ServicesContext;
            var deploymentClassLoader = DeployerHelperResolver.GetClassLoader(-1, deploymentClassLoaderOption, services);
            var moduleProvider        = ModuleProviderUtil.Analyze(compiled, deploymentClassLoader, services.ClassProvidedPathRegistry);

            if (moduleProvider.ClassLoader is ClassProvidedImportClassLoader)
            {
                ((ClassProvidedImportClassLoader)moduleProvider.ClassLoader).Imported = moduleProvider.ModuleProvider.ModuleDependencies.PathClasses;
            }

            var moduleName = moduleProvider.ModuleProvider.ModuleName;

            // resolve external dependencies
            var moduleDependencies       = moduleProvider.ModuleProvider.ModuleDependencies;
            var deploymentIdDependencies = ResolveDependencies(-1, moduleDependencies, services);

            // initialize EPL objects defined by module
            var moduleEPLObjects = InitializeEPLObjects(moduleProvider, deploymentId, services);

            // determine staged EPL object overlap
            ValidateStagedEPLObjects(moduleEPLObjects, moduleProvider.ModuleProvider.ModuleName, -1, epRuntime.StageService);

            // add EPL objects defined by module to path
            var modulePaths = UpdatePath(-1, moduleEPLObjects, moduleName, deploymentId, services);

            // obtain statement lightweights
            var stmtLightweights = InitializeStatements(
                -1,
                recovery,
                moduleEPLObjects,
                modulePaths,
                moduleName,
                moduleProvider,
                deploymentId,
                statementIdFirstStatement,
                userObjectResolverRuntime,
                statementNameResolverRuntime,
                substitutionParameterResolver,
                services);

            // start statements depending on context association
            var statements = DeployStatements(
                -1, stmtLightweights.Lightweights, recovery, modulePaths, moduleProvider, deploymentId, epRuntime);

            // add dependencies
            AddPathDependencies(deploymentId, moduleDependencies, services);

            // keep statement and deployment
            var deployed = DeploymentInternal.From(
                deploymentId,
                statements,
                deploymentIdDependencies,
                modulePaths,
                moduleEPLObjects,
                moduleProvider);

            services.DeploymentLifecycleService.AddDeployment(deploymentId, deployed);

            // register for recovery
            if (!recovery)
            {
                var recoveryInformation = GetRecoveryInformation(deployed);
                services.DeploymentRecoveryService.Add(
                    deploymentId,
                    statementIdFirstStatement,
                    compiled,
                    recoveryInformation.StatementUserObjectsRuntime,
                    recoveryInformation.StatementNamesWhenProvidedByAPI,
                    stmtLightweights.SubstitutionParameters);
            }

            return(deployed);
        }
 public EPRuntimeStatementSelectionSPI(EPRuntimeSPI runtimeSPI)
 {
     _runtimeSPI       = runtimeSPI;
     _statementRowType = new EPRuntimeBeanAnonymousTypeService(runtimeSPI.Container)
                         .MakeBeanEventTypeAnonymous(typeof(StatementRow));
 }
Пример #20
0
        public static DeployerRolloutDeploymentResult Rollout(
            int currentStatementId,
            ICollection <EPDeploymentRolloutCompiled> itemsProvided,
            EPRuntimeSPI runtime)
        {
            var items = itemsProvided.ToArray();

            // per-deployment: determine deployment id
            var deploymentIds   = new string[items.Length];
            var deploymentIdSet = new HashSet <string>();

            for (var i = 0; i < items.Length; i++)
            {
                deploymentIds[i] = DeployerHelperResolver.DetermineDeploymentIdCheckExists(
                    i,
                    items[i].Options,
                    runtime.ServicesContext.DeploymentLifecycleService);
                if (!deploymentIdSet.Add(deploymentIds[i]))
                {
                    throw new EPDeployException("Deployment id '" + deploymentIds[i] + "' occurs multiple times in the rollout", i);
                }
            }

            // per-deployment: obtain module providers
            var moduleProviders = new ModuleProviderCLPair[items.Length];

            for (var i = 0; i < items.Length; i++)
            {
                var classLoader = DeployerHelperResolver.GetClassLoader(i, items[i].Options.DeploymentClassLoaderOption, runtime.ServicesContext);
                try {
                    moduleProviders[i] = ModuleProviderUtil.Analyze(items[i].Compiled, classLoader, runtime.ServicesContext.ClassProvidedPathRegistry);
                }
                catch (Exception) {
                    RolloutCleanClassloader(deploymentIds, runtime.ServicesContext);
                }
            }

            // per-deployment: check dependencies and initialize EPL objects
            var inits = new DeployerRolloutInitResult[items.Length];

            for (var i = 0; i < items.Length; i++)
            {
                try {
                    inits[i] = ResolveDependenciesInitEPLObjects(i, deploymentIds[i], moduleProviders[i], runtime.ServicesContext, runtime.StageService);
                }
                catch (EPDeployException) {
                    RolloutCleanPathAndTypes(inits, deploymentIds, runtime.ServicesContext);
                    throw;
                }
                catch (Exception ex) {
                    RolloutCleanPathAndTypes(inits, deploymentIds, runtime.ServicesContext);
                    throw new EPDeployException(ex.Message, ex, i);
                }
            }

            // per-deployment - obtain statement lightweights
            var stmtLightweights = new DeployerModuleStatementLightweights[items.Length];
            var numStatements    = 0;

            for (var i = 0; i < items.Length; i++)
            {
                var statementIdStart = currentStatementId + numStatements;
                try {
                    stmtLightweights[i] = InitializeStatements(
                        i,
                        false,
                        inits[i].ModuleEPLObjects,
                        inits[i].ModulePaths,
                        inits[i].ModuleName,
                        moduleProviders[i],
                        deploymentIds[i],
                        statementIdStart,
                        items[i].Options.StatementUserObjectRuntime,
                        items[i].Options.StatementNameRuntime,
                        items[i].Options.StatementSubstitutionParameter,
                        runtime.ServicesContext);
                }
                catch (EPDeployException ex) {
                    RolloutCleanLightweights(stmtLightweights, inits, deploymentIds, moduleProviders, runtime.ServicesContext);
                    throw ex;
                }
                catch (Exception ex) {
                    RolloutCleanLightweights(stmtLightweights, inits, deploymentIds, moduleProviders, runtime.ServicesContext);
                    throw new EPDeployException(ex.Message, ex, i);
                }

                numStatements += stmtLightweights[i].Lightweights.Count;
            }

            // per-deployment: start statements depending on context association
            var statements = new EPStatement[items.Length][];

            for (var i = 0; i < items.Length; i++)
            {
                try {
                    statements[i] = DeployerHelperStatement.DeployStatements(
                        i,
                        stmtLightweights[i].Lightweights,
                        false,
                        inits[i].ModulePaths,
                        moduleProviders[i],
                        deploymentIds[i],
                        runtime);
                }
                catch (EPDeployException ex) {
                    RolloutCleanStatements(statements, stmtLightweights, inits, deploymentIds, moduleProviders, runtime.ServicesContext);
                    throw ex;
                }
                catch (Exception t) {
                    RolloutCleanStatements(statements, stmtLightweights, inits, deploymentIds, moduleProviders, runtime.ServicesContext);
                    throw new EPDeployException(t.Message, t, i);
                }
            }

            // per-deployment: add paths dependency information and add deployment
            var deployments = new DeploymentInternal[items.Length];

            for (var i = 0; i < items.Length; i++)
            {
                try {
                    // add dependencies
                    AddPathDependencies(deploymentIds[i], moduleProviders[i].ModuleProvider.ModuleDependencies, runtime.ServicesContext);

                    // keep statement and deployment
                    deployments[i] = DeploymentInternal.From(
                        deploymentIds[i],
                        statements[i],
                        inits[i].DeploymentIdDependencies,
                        inits[i].ModulePaths,
                        inits[i].ModuleEPLObjects,
                        moduleProviders[i]);
                    runtime.ServicesContext.DeploymentLifecycleService.AddDeployment(deploymentIds[i], deployments[i]);

                    // register for recovery
                    DeploymentRecoveryInformation recoveryInformation = GetRecoveryInformation(deployments[i]);
                    runtime.ServicesContext.DeploymentRecoveryService.Add(
                        deploymentIds[i],
                        stmtLightweights[i].StatementIdFirstStatement,
                        items[i].Compiled,
                        recoveryInformation.StatementUserObjectsRuntime,
                        recoveryInformation.StatementNamesWhenProvidedByAPI,
                        stmtLightweights[i].SubstitutionParameters);
                }
                catch (Exception t) {
                    RolloutCleanStatements(statements, stmtLightweights, inits, deploymentIds, moduleProviders, runtime.ServicesContext);
                    throw new EPDeployException(t.Message, t, i);
                }
            }

            return(new DeployerRolloutDeploymentResult(numStatements, deployments));
        }