private DeploymentResult DeployQuick(Module module, string moduleURI, string moduleArchive, Object userObject) { module.Uri = moduleURI; module.ArchiveName = moduleArchive; module.UserObject = userObject; GetDeploymentOrder(Collections.SingletonList(module), null); return(Deploy(module, null)); }
public DeploymentResult ParseDeploy(string buffer, string moduleURI, string moduleArchive, Object userObject) { using (_iLock.Acquire()) { Module module = EPLModuleUtil.ParseInternal(buffer, moduleURI); return(DeployQuick(module, moduleURI, moduleArchive, userObject)); } }
private void AddInternal(Module module, string deploymentId) { var desc = new DeploymentInformation( deploymentId, module, DateTimeEx.GetInstance(_timeZone), DateTimeEx.GetInstance(_timeZone), new DeploymentInformationItem[0], DeploymentState.UNDEPLOYED); _deploymentStateService.AddUpdateDeployment(desc); }
public DeploymentResult ReadDeploy(Stream stream, string moduleURI, string moduleArchive, Object userObject) { using (_iLock.Acquire()) { Module module = EPLModuleUtil.ReadInternal(stream, moduleURI); return(DeployQuick(module, moduleURI, moduleArchive, userObject)); } }
public DeploymentResult ReadDeploy(string resource, string moduleURI, string moduleArchive, Object userObject) { using (_iLock.Acquire()) { Module module = Read(resource); return(DeployQuick(module, moduleURI, moduleArchive, userObject)); } }
public DeploymentResult Deploy(Module module, DeploymentOptions options) { using (_iLock.Acquire()) { string deploymentId = _deploymentStateService.NextDeploymentId; return(DeployInternal(module, options, deploymentId, DateTimeEx.GetInstance(_timeZone))); } }
public string Add(Module module) { using (_iLock.Acquire()) { string deploymentId = _deploymentStateService.NextDeploymentId; AddInternal(module, deploymentId); return(deploymentId); } }
public void Add(Module module, string assignedDeploymentId) { using (_iLock.Acquire()) { if (_deploymentStateService.GetDeployment(assignedDeploymentId) != null) { throw new ArgumentException( "Assigned deployment id '" + assignedDeploymentId + "' is already in use"); } AddInternal(module, assignedDeploymentId); } }
public DeploymentResult Deploy(Module module, DeploymentOptions options, string assignedDeploymentId) { using (_iLock.Acquire()) { if (_deploymentStateService.GetDeployment(assignedDeploymentId) != null) { throw new ArgumentException( "Assigned deployment id '" + assignedDeploymentId + "' is already in use"); } return(DeployInternal(module, options, assignedDeploymentId, DateTimeEx.GetInstance(_timeZone))); } }
private DeploymentResult DeployInternal( Module module, DeploymentOptions options, string deploymentId, DateTimeEx addedDate) { if (options == null) { options = new DeploymentOptions(); } options.DeploymentLockStrategy.Acquire(_eventProcessingRwLock); try { return(DeployInternalLockTaken(module, options, deploymentId, addedDate)); } finally { options.DeploymentLockStrategy.Release(_eventProcessingRwLock); } }
private DeploymentActionException BuildException( string msg, Module module, List <DeploymentItemException> exceptions) { string message = msg; if (module.Name != null) { message += " in module '" + module.Name + "'"; } if (module.Uri != null) { message += " in module url '" + module.Uri + "'"; } if (exceptions.Count > 0) { message += " in expression '" + GetAbbreviated(exceptions[0].Expression) + "' : " + exceptions[0].Message; } return(new DeploymentActionException(message, exceptions)); }
private DeploymentResult DeployInternalLockTaken( Module module, DeploymentOptions options, string deploymentId, DateTimeEx addedDate) { if (Log.IsDebugEnabled) { Log.Debug("Deploying module " + module); } IList <string> imports; if (module.Imports != null) { foreach (string imported in module.Imports) { if (Log.IsDebugEnabled) { Log.Debug("Adding import " + imported); } _epService.Configuration.AddImport(imported); } imports = new List <string>(module.Imports); } else { imports = Collections.GetEmptyList <string>(); } if (options.IsCompile) { var exceptionsX = new List <DeploymentItemException>(); foreach (ModuleItem item in module.Items) { if (item.IsCommentOnly) { continue; } try { _epService.CompileEPL(item.Expression); } catch (Exception ex) { exceptionsX.Add(new DeploymentItemException(ex.Message, item.Expression, ex, item.LineNumber)); } } if (!exceptionsX.IsEmpty()) { throw BuildException("Compilation failed", module, exceptionsX); } } if (options.IsCompileOnly) { return(null); } var exceptions = new List <DeploymentItemException>(); var statementNames = new List <DeploymentInformationItem>(); var statements = new List <EPStatement>(); var eventTypesReferenced = new HashSet <string>(); foreach (ModuleItem item in module.Items) { if (item.IsCommentOnly) { continue; } string statementName = null; Object userObject = null; if (options.StatementNameResolver != null || options.StatementUserObjectResolver != null) { var ctx = new StatementDeploymentContext(item.Expression, module, item, deploymentId); statementName = options.StatementNameResolver != null ? options.StatementNameResolver.GetStatementName(ctx) : null; userObject = options.StatementUserObjectResolver != null ? options.StatementUserObjectResolver.GetUserObject(ctx) : null; } try { EPStatement stmt; if (options.IsolatedServiceProvider == null) { stmt = _epService.CreateEPL(item.Expression, statementName, userObject); } else { EPServiceProviderIsolated unit = _statementIsolationService.GetIsolationUnit(options.IsolatedServiceProvider, -1); stmt = unit.EPAdministrator.CreateEPL(item.Expression, statementName, userObject); } statementNames.Add(new DeploymentInformationItem(stmt.Name, stmt.Text)); statements.Add(stmt); string[] types = _statementEventTypeRef.GetTypesForStatementName(stmt.Name); if (types != null) { eventTypesReferenced.AddAll(types); } } catch (EPException ex) { exceptions.Add(new DeploymentItemException(ex.Message, item.Expression, ex, item.LineNumber)); if (options.IsFailFast) { break; } } } if (!exceptions.IsEmpty()) { if (options.IsRollbackOnFail) { Log.Debug("Rolling back intermediate statements for deployment"); foreach (EPStatement stmt in statements) { try { stmt.Dispose(); } catch (Exception ex) { Log.Debug("Failed to destroy created statement during rollback: " + ex.Message, ex); } } EPLModuleUtil.UndeployTypes( eventTypesReferenced, _statementEventTypeRef, _eventAdapterService, _filterService); } string text = "Deployment failed"; if (options.IsValidateOnly) { text = "Validation failed"; } throw BuildException(text, module, exceptions); } if (options.IsValidateOnly) { Log.Debug("Rolling back created statements for validate-only"); foreach (EPStatement stmt in statements) { try { stmt.Dispose(); } catch (Exception ex) { Log.Debug("Failed to destroy created statement during rollback: " + ex.Message, ex); } } EPLModuleUtil.UndeployTypes( eventTypesReferenced, _statementEventTypeRef, _eventAdapterService, _filterService); return(null); } DeploymentInformationItem[] deploymentInfoArr = statementNames.ToArray(); var desc = new DeploymentInformation( deploymentId, module, addedDate, DateTimeEx.GetInstance(_timeZone), deploymentInfoArr, DeploymentState.DEPLOYED); _deploymentStateService.AddUpdateDeployment(desc); if (Log.IsDebugEnabled) { Log.Debug("Module " + module + " was successfully deployed."); } return(new DeploymentResult(desc.DeploymentId, statements.AsReadOnlyList(), imports)); }