Ejemplo n.º 1
0
 private void TraverseContextPartitions(
     DeploymentInternal deployment,
     Consumer <StatementResourceHolder> consumer)
 {
     foreach (EPStatement statement in deployment.Statements)
     {
         EPStatementSPI spi = (EPStatementSPI)statement;
         if (spi.StatementContext.ContextName == null)
         {
             StatementResourceHolder holder = spi.StatementContext.StatementCPCacheService.MakeOrGetEntryCanNull(-1, spi.StatementContext);
             consumer.Invoke(holder);
         }
         else
         {
             ContextRuntimeDescriptor contextDesc    = spi.StatementContext.ContextRuntimeDescriptor;
             ContextManager           contextManager = _servicesContext.ContextManagementService.GetContextManager(
                 contextDesc.ContextDeploymentId,
                 contextDesc.ContextName);
             ICollection <int> agentInstanceIds = contextManager.Realization.GetAgentInstanceIds(ContextPartitionSelectorAll.INSTANCE);
             foreach (int agentInstanceId in agentInstanceIds)
             {
                 StatementResourceHolder holder =
                     spi.StatementContext.StatementCPCacheService.MakeOrGetEntryCanNull(agentInstanceId, spi.StatementContext);
                 consumer.Invoke(holder);
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void Stage(ICollection <string> deploymentIdsProvided)
        {
            lock (this) {
                CheckDestroyed();
                ISet <string> deploymentIds = CheckArgument(deploymentIdsProvided);
                if (deploymentIds.IsEmpty())
                {
                    return;
                }

                CheckDeploymentIdsExist(deploymentIds, _servicesContext.DeploymentLifecycleService);
                ValidateDependencyPreconditions(deploymentIds, _servicesContext, _servicesContext.DeploymentLifecycleService);

                ISet <int> statementIds = new HashSet <int>();
                foreach (string deploymentId in deploymentIds)
                {
                    DeploymentInternal deployment = _servicesContext.DeploymentLifecycleService.GetDeploymentById(deploymentId);
                    TraverseContextPartitions(deployment, ProcessStage);
                    TraverseStatements(deployment, statementContext => UpdateStatement(statementContext, _stageSpecificServices), statementIds);
                    MovePath(deployment, _servicesContext, _stageSpecificServices);
                    _servicesContext.DeploymentLifecycleService.RemoveDeployment(deploymentId);
                    _stageSpecificServices.DeploymentLifecycleService.AddDeployment(deploymentId, deployment);
                    _servicesContext.StageRecoveryService.DeploymentSetStage(deploymentId, _stageUri);
                }

                _servicesContext.SchedulingServiceSPI.Transfer(statementIds, _stageSpecificServices.SchedulingServiceSPI);
            }
        }
Ejemplo n.º 3
0
 private void TraverseStatements(
     DeploymentInternal deployment,
     Consumer <StatementContext> consumer,
     ISet <int> statementIds)
 {
     foreach (EPStatement statement in deployment.Statements)
     {
         EPStatementSPI spi = (EPStatementSPI)statement;
         consumer.Invoke(spi.StatementContext);
         statementIds.Add(spi.StatementId);
     }
 }
Ejemplo n.º 4
0
 private void CheckDeploymentIdsExist(
     ISet <string> deploymentIds,
     DeploymentLifecycleService deploymentLifecycleService)
 {
     foreach (string deploymentId in deploymentIds)
     {
         DeploymentInternal deployment = deploymentLifecycleService.GetDeploymentById(deploymentId);
         if (deployment == null)
         {
             throw new EPStageException("Deployment '" + deploymentId + "' was not found");
         }
     }
 }
Ejemplo n.º 5
0
 public static void MovePath(
     DeploymentInternal deployment,
     EPServicesPath from,
     EPServicesPath to)
 {
     var moduleName = deployment.ModuleProvider.ModuleName;
     HandleProvided(deployment.DeploymentId, deployment.PathNamedWindows, from.NamedWindowPathRegistry, moduleName, to.NamedWindowPathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathTables, from.TablePathRegistry, moduleName, to.TablePathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathContexts, from.ContextPathRegistry, moduleName, to.ContextPathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathVariables, from.VariablePathRegistry, moduleName, to.VariablePathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathEventTypes, from.EventTypePathRegistry, moduleName, to.EventTypePathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathExprDecls, from.ExprDeclaredPathRegistry, moduleName, to.ExprDeclaredPathRegistry);
     HandleProvided(deployment.DeploymentId, deployment.PathScripts, from.ScriptPathRegistry, moduleName, to.ScriptPathRegistry);
 }
        public void AddDeployment(
            string deploymentId,
            DeploymentInternal deployment)
        {
            var existing = DeploymentMap.Get(deploymentId);
            if (existing != null)
            {
                throw new IllegalStateException("Deployment already exists by name '" + deploymentId + "'");
            }

            var crc = CRC32Util.ComputeCRC32(deploymentId);
            existing = deploymentsByCRC.Get(crc);
            if (existing != null)
            {
                throw new IllegalStateException("Deployment already exists by same-value crc");
            }

            DeploymentMap.Put(deploymentId, deployment);
            deploymentsByCRC.Put(crc, deployment);
        }
Ejemplo n.º 7
0
        public void RecoverDeployment(
            string stageUri,
            DeploymentInternal deployment)
        {
            string deploymentId = deployment.DeploymentId;

            _services.DeploymentLifecycleService.RemoveDeployment(deploymentId);
            _stages.Get(stageUri).StageSpecificServices.DeploymentLifecycleService.AddDeployment(deploymentId, deployment);

            StageSpecificServices stageSpecificServices = _stages.Get(stageUri).EventServiceSPI.SpecificServices;

            foreach (EPStatement statement in deployment.Statements)
            {
                EPStatementSPI spi = (EPStatementSPI)statement;
                UpdateStatement(spi.StatementContext, stageSpecificServices);

                if (Equals(spi.GetProperty(StatementProperty.STATEMENTTYPE), StatementType.UPDATE))
                {
                    _services.InternalEventRouter.MovePreprocessing(spi.StatementContext, stageSpecificServices.InternalEventRouter);
                }
            }
        }