public static ISet <string> ResolveDependencies( int rolloutItemNumber, ModuleDependenciesRuntime moduleDependencies, EPServicesContext services) { ISet <string> dependencies = new HashSet <string>(); foreach (var publicEventType in moduleDependencies.PublicEventTypes) { if (services.EventTypeRepositoryBus.GetTypeByName(publicEventType) == null) { throw MakePreconditionExceptionPreconfigured(rolloutItemNumber, PathRegistryObjectType.EVENTTYPE, publicEventType); } } foreach (var publicVariable in moduleDependencies.PublicVariables) { if (services.ConfigSnapshot.Common.Variables.Get(publicVariable) == null) { throw MakePreconditionExceptionPreconfigured(rolloutItemNumber, PathRegistryObjectType.VARIABLE, publicVariable); } } foreach (var pathNamedWindow in moduleDependencies.PathNamedWindows) { var depIdNamedWindow = services.NamedWindowPathRegistry.GetDeploymentId(pathNamedWindow.Name, pathNamedWindow.ModuleName); if (depIdNamedWindow == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.NAMEDWINDOW, pathNamedWindow); } dependencies.Add(depIdNamedWindow); } foreach (var pathTable in moduleDependencies.PathTables) { var depIdTable = services.TablePathRegistry.GetDeploymentId(pathTable.Name, pathTable.ModuleName); if (depIdTable == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.TABLE, pathTable); } dependencies.Add(depIdTable); } foreach (var pathEventType in moduleDependencies.PathEventTypes) { var depIdEventType = services.EventTypePathRegistry.GetDeploymentId(pathEventType.Name, pathEventType.ModuleName); if (depIdEventType == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.EVENTTYPE, pathEventType); } dependencies.Add(depIdEventType); } foreach (var pathVariable in moduleDependencies.PathVariables) { var depIdVariable = services.VariablePathRegistry.GetDeploymentId(pathVariable.Name, pathVariable.ModuleName); if (depIdVariable == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.VARIABLE, pathVariable); } dependencies.Add(depIdVariable); } foreach (var pathContext in moduleDependencies.PathContexts) { var depIdContext = services.ContextPathRegistry.GetDeploymentId(pathContext.Name, pathContext.ModuleName); if (depIdContext == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.CONTEXT, pathContext); } dependencies.Add(depIdContext); } foreach (var pathExpression in moduleDependencies.PathExpressions) { var depIdExpression = services.ExprDeclaredPathRegistry.GetDeploymentId(pathExpression.Name, pathExpression.ModuleName); if (depIdExpression == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.EXPRDECL, pathExpression); } dependencies.Add(depIdExpression); } foreach (var pathScript in moduleDependencies.PathScripts) { var depIdExpression = services.ScriptPathRegistry.GetDeploymentId( new NameAndParamNum(pathScript.Name, pathScript.ParamNum), pathScript.ModuleName); if (depIdExpression == null) { throw MakePreconditionExceptionPath( rolloutItemNumber, PathRegistryObjectType.SCRIPT, new NameAndModule(pathScript.Name, pathScript.ModuleName)); } dependencies.Add(depIdExpression); } foreach (var index in moduleDependencies.PathIndexes) { string depIdIndex; if (index.IsNamedWindow) { var namedWindowName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathNamedWindows); var namedWindow = services.NamedWindowPathRegistry.GetWithModule(namedWindowName.Name, namedWindowName.ModuleName); depIdIndex = namedWindow.IndexMetadata.GetIndexDeploymentId(index.IndexName); } else { var tableName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathTables); var table = services.TablePathRegistry.GetWithModule(tableName.Name, tableName.ModuleName); depIdIndex = table.IndexMetadata.GetIndexDeploymentId(index.IndexName); } if (depIdIndex == null) { throw MakePreconditionExceptionPath( rolloutItemNumber, PathRegistryObjectType.INDEX, new NameAndModule(index.IndexName, index.IndexModuleName)); } dependencies.Add(depIdIndex); } foreach (var pathClass in moduleDependencies.PathClasses) { var depIdClass = services.ClassProvidedPathRegistry.GetDeploymentId(pathClass.Name, pathClass.ModuleName); if (depIdClass == null) { throw MakePreconditionExceptionPath(rolloutItemNumber, PathRegistryObjectType.CLASSPROVIDED, pathClass); } dependencies.Add(depIdClass); } return(dependencies); }
public static void Undeploy( string deploymentId, IDictionary <long, EventType> deploymentTypes, StatementContext[] reverted, ModuleProvider moduleProvider, EPServicesContext services) { foreach (var statement in reverted) { // remove any match-recognize counts services.RowRecogStatePoolEngineSvc?.RemoveStatement(new DeploymentIdNamePair(statement.DeploymentId, statement.StatementName)); var enumerator = statement.FinalizeCallbacks; while (enumerator.MoveNext()) { enumerator.Current.StatementDestroyed(statement); } try { if (statement.DestroyCallback != null) { statement.DestroyCallback.Destroy(new StatementDestroyServices(services.FilterService), statement); } else { statement.StatementAIFactoryProvider.Factory.StatementDestroy(statement); } } catch (Exception ex) { Log.Error("Exception encountered during stop: " + ex.Message, ex); } if (statement.ContextRuntimeDescriptor != null) { try { services.ContextManagementService.StoppedStatement( statement.ContextRuntimeDescriptor.ContextDeploymentId, statement.ContextName, statement.StatementId, statement.StatementName, statement.DeploymentId); } catch (Exception ex) { Log.Error("Exception encountered during stop: " + ex.Message, ex); } } services.EpServicesHA.ListenerRecoveryService.Remove(statement.StatementId); services.StatementLifecycleService.RemoveStatement(statement.StatementId); services.PatternSubexpressionPoolRuntimeSvc.RemoveStatement(statement.StatementId); services.FilterSharedBoolExprRepository.RemoveStatement(statement.StatementId); services.FilterSharedLookupableRepository.RemoveReferencesStatement(statement.StatementId); } var moduleDependencies = moduleProvider.ModuleDependencies; foreach (var namedWindow in moduleDependencies.PathNamedWindows) { services.NamedWindowPathRegistry.RemoveDependency(namedWindow.Name, namedWindow.ModuleName, deploymentId); } foreach (var table in moduleDependencies.PathTables) { services.TablePathRegistry.RemoveDependency(table.Name, table.ModuleName, deploymentId); } foreach (var variable in moduleDependencies.PathVariables) { services.VariablePathRegistry.RemoveDependency(variable.Name, variable.ModuleName, deploymentId); } foreach (var context in moduleDependencies.PathContexts) { services.ContextPathRegistry.RemoveDependency(context.Name, context.ModuleName, deploymentId); } foreach (var eventType in moduleDependencies.PathEventTypes) { services.EventTypePathRegistry.RemoveDependency(eventType.Name, eventType.ModuleName, deploymentId); } foreach (var exprDecl in moduleDependencies.PathExpressions) { services.ExprDeclaredPathRegistry.RemoveDependency(exprDecl.Name, exprDecl.ModuleName, deploymentId); } foreach (var script in moduleDependencies.PathScripts) { services.ScriptPathRegistry.RemoveDependency(new NameAndParamNum(script.Name, script.ParamNum), script.ModuleName, deploymentId); } foreach (var classDecl in moduleDependencies.PathClasses) { services.ClassProvidedPathRegistry.RemoveDependency(classDecl.Name, classDecl.ModuleName, deploymentId); } foreach (var index in moduleDependencies.PathIndexes) { EventTableIndexMetadata indexMetadata; if (index.IsNamedWindow) { var namedWindowName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathNamedWindows); var namedWindow = services.NamedWindowPathRegistry.GetWithModule(namedWindowName.Name, namedWindowName.ModuleName); indexMetadata = namedWindow.IndexMetadata; } else { var tableName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathTables); var table = services.TablePathRegistry.GetWithModule(tableName.Name, tableName.ModuleName); indexMetadata = table.IndexMetadata; } indexMetadata.RemoveIndexReference(index.IndexName, deploymentId); } DeleteFromEventTypeBus(services, deploymentTypes); DeleteFromPathRegistries(services, deploymentId); services.ClassLoaderParent.Remove(deploymentId); if (InstrumentationHelper.ENABLED) { var instrumentation = InstrumentationHelper.Get(); foreach (var ctx in reverted) { instrumentation.QaEngineManagementStmtStop( services.RuntimeURI, deploymentId, ctx.StatementId, ctx.StatementName, (string)ctx.StatementInformationals.Properties.Get(StatementProperty.EPL), services.SchedulingService.Time); } } }
public static void AddPathDependencies( string deploymentId, ModuleDependenciesRuntime moduleDependencies, EPServicesContext services) { foreach (var eventType in moduleDependencies.PathEventTypes) { services.EventTypePathRegistry.AddDependency(eventType.Name, eventType.ModuleName, deploymentId); } foreach (var namedWindow in moduleDependencies.PathNamedWindows) { services.NamedWindowPathRegistry.AddDependency(namedWindow.Name, namedWindow.ModuleName, deploymentId); } foreach (var table in moduleDependencies.PathTables) { services.TablePathRegistry.AddDependency(table.Name, table.ModuleName, deploymentId); } foreach (var variable in moduleDependencies.PathVariables) { services.VariablePathRegistry.AddDependency(variable.Name, variable.ModuleName, deploymentId); } foreach (var context in moduleDependencies.PathContexts) { services.ContextPathRegistry.AddDependency(context.Name, context.ModuleName, deploymentId); } foreach (var exprDecl in moduleDependencies.PathExpressions) { services.ExprDeclaredPathRegistry.AddDependency(exprDecl.Name, exprDecl.ModuleName, deploymentId); } foreach (var script in moduleDependencies.PathScripts) { services.ScriptPathRegistry.AddDependency(new NameAndParamNum(script.Name, script.ParamNum), script.ModuleName, deploymentId); } foreach (var classProvided in moduleDependencies.PathClasses) { services.ClassProvidedPathRegistry.AddDependency(classProvided.Name, classProvided.ModuleName, deploymentId); } foreach (var index in moduleDependencies.PathIndexes) { EventTableIndexMetadata indexMetadata; if (index.IsNamedWindow) { var namedWindowName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathNamedWindows); var namedWindow = services.NamedWindowPathRegistry.GetWithModule(namedWindowName.Name, namedWindowName.ModuleName); indexMetadata = namedWindow.IndexMetadata; } else { var tableName = NameAndModule.FindName(index.InfraName, moduleDependencies.PathTables); var table = services.TablePathRegistry.GetWithModule(tableName.Name, tableName.ModuleName); indexMetadata = table.IndexMetadata; } indexMetadata.AddIndexReference(index.IndexName, deploymentId); } }