public EPDeployment Deploy( EPCompiled compiled, DeploymentOptions options) { using (_services.Container.EnterContextualReflection()) { if (options == null) { options = new DeploymentOptions(); } ValidateRuntimeAlive(); CheckManifest(-1, compiled.Manifest); DeploymentInternal deployerResult; using (GetDeploymentLock(options)) { var statementIdRecovery = _services.EpServicesHA.StatementIdRecoveryService; var currentStatementId = statementIdRecovery.CurrentStatementId; if (currentStatementId == null) { currentStatementId = 1; } var deploymentId = DeployerHelperResolver.DetermineDeploymentIdCheckExists( -1, options, _runtime.ServicesContext.DeploymentLifecycleService); deployerResult = Deployer.DeployFresh( deploymentId, currentStatementId.Value, compiled, options.StatementNameRuntime, options.StatementUserObjectRuntime, options.StatementSubstitutionParameter, options.DeploymentClassLoaderOption, _runtime); statementIdRecovery.CurrentStatementId = currentStatementId + deployerResult.Statements.Length; // dispatch event DispatchOnDeploymentEvent(deployerResult, -1); } return(MakeDeployment(deployerResult)); } }
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)); }