private UndeploymentResult UndeployRemoveInternal( DeploymentInformation info, UndeploymentOptions undeploymentOptions) { var reverted = new DeploymentInformationItem[info.Items.Length]; for (int i = 0; i < info.Items.Length; i++) { reverted[i] = info.Items[info.Items.Length - 1 - i]; } var revertedStatements = new List <DeploymentInformationItem>(); if (undeploymentOptions.IsDestroyStatements) { var referencedTypes = new HashSet <string>(); Exception firstExceptionEncountered = null; foreach (DeploymentInformationItem item in reverted) { EPStatement statement = _epService.GetStatement(item.StatementName); if (statement == null) { Log.Debug("Deployment id '" + info.DeploymentId + "' statement name '" + item + "' not found"); continue; } referencedTypes.AddAll(_statementEventTypeRef.GetTypesForStatementName(statement.Name)); if (statement.IsDisposed) { continue; } try { statement.Dispose(); } catch (Exception ex) { Log.Warn("Unexpected exception destroying statement: " + ex.Message, ex); if (firstExceptionEncountered == null) { firstExceptionEncountered = ex; } } revertedStatements.Add(item); } EPLModuleUtil.UndeployTypes( referencedTypes, _statementEventTypeRef, _eventAdapterService, _filterService); revertedStatements.Reverse(); if (firstExceptionEncountered != null && _undeployRethrowPolicy == ConfigurationEngineDefaults.UndeployRethrowPolicy.RETHROW_FIRST) { throw firstExceptionEncountered; } } return(new UndeploymentResult(info.DeploymentId, revertedStatements)); }
public Module Read(Stream stream, String uri) { if (Log.IsDebugEnabled) { Log.Debug("Reading module from input stream"); } return(EPLModuleUtil.ReadInternal(stream, uri)); }
public DeploymentResult ParseDeploy(String buffer, String moduleURI, String moduleArchive, Object userObject) { using (_iLock.Acquire()) { var module = EPLModuleUtil.ParseInternal(buffer, moduleURI); return(DeployQuick(module, moduleURI, moduleArchive, userObject)); } }
public DeploymentResult ReadDeploy(Stream stream, String moduleURI, String moduleArchive, Object userObject) { using (_iLock.Acquire()) { var module = EPLModuleUtil.ReadInternal(stream, moduleURI); return(DeployQuick(module, moduleURI, moduleArchive, userObject)); } }
public Module Read(String resource) { if (Log.IsDebugEnabled) { Log.Debug("Reading resource '" + resource + "'"); } return(EPLModuleUtil.ReadResource(resource)); }
public Module Read(string resource) { if (Log.IsDebugEnabled) { Log.Debug("Reading resource '" + resource + "'"); } return(EPLModuleUtil.ReadResource(resource, _eventAdapterService.EngineImportService)); }
public Module Read(FileInfo file) { var absolutePath = Path.GetFullPath(file.Name); Log.Debug("Reading resource '{0}'", absolutePath); using (var stream = File.OpenRead(absolutePath)) { return(EPLModuleUtil.ReadInternal(stream, absolutePath)); } }
public Module Read(Uri url) { Log.Debug("Reading resource from url: {0}", url); using (var webClient = new WebClient()) { using (var stream = webClient.OpenRead(url)) { return(EPLModuleUtil.ReadInternal(stream, url.ToString())); } } }
public void TestParse() { var testdata = new[] { new Object[] { "/* Comment One */ select * from A;\n" + "/* Comment Two */ select * from B ;\n", new [] { new EPLModuleParseItem("/* Comment One */ select * from A", 1, 0, 33), new EPLModuleParseItem("/* Comment Two */ select * from B", 2, 34, 73) }, }, new Object[] { "select /* Comment One\n\r; */ *, ';', \";\" from A order by x;; ;\n\n \n;\n" + "/* Comment Two */ select * from B ;\n", new [] { new EPLModuleParseItem("select /* Comment One\n\r; */ *, ';', \";\" from A order by x", 1, 0, 57), new EPLModuleParseItem("/* Comment Two */ select * from B", 6, 63, 102) }, } }; for (int i = 0; i < testdata.Length; i++) { var input = (String)testdata[i][0]; var expected = (EPLModuleParseItem[])testdata[i][1]; var result = EPLModuleUtil.Parse(input); Assert.AreEqual(expected.Length, result.Count); for (int j = 0; j < expected.Length; j++) { String message = "failed at item " + i + " and segment " + j; Assert.That(result[j].Expression, Is.EqualTo(expected[j].Expression), message); Assert.That(result[j].LineNum, Is.EqualTo(expected[j].LineNum), message); Assert.That(result[j].StartChar, Is.EqualTo(expected[j].StartChar), message); Assert.That(result[j].EndChar, Is.EqualTo(expected[j].EndChar), message); } } }
public Module Parse(String eplModuleText) { return(EPLModuleUtil.ParseInternal(eplModuleText, null)); }
private DeploymentResult DeployInternal(Module module, DeploymentOptions options, String deploymentId, DateTimeOffset addedDate) { if (options == null) { options = new DeploymentOptions(); } if (Log.IsDebugEnabled) { Log.Debug("Deploying module " + module); } IList <String> imports; if (module.Imports != null) { foreach (var 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 itemExceptions = new List <DeploymentItemException>(); foreach (var item in module.Items) { if (item.IsCommentOnly) { continue; } try { _epService.CompileEPL(item.Expression); } catch (Exception ex) { itemExceptions.Add(new DeploymentItemException(ex.Message, item.Expression, ex, item.LineNumber)); } } if (itemExceptions.IsNotEmpty()) { throw BuildException("Compilation failed", module, itemExceptions); } } 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 (var 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 (_optionalStatementIdGenerator == null) { if (options.IsolatedServiceProvider == null) { stmt = _epService.CreateEPL(item.Expression, statementName, userObject); } else { var unit = _statementIsolationService.GetIsolationUnit(options.IsolatedServiceProvider, -1); stmt = unit.EPAdministrator.CreateEPL(item.Expression, statementName, userObject); } } else { var statementId = _optionalStatementIdGenerator.Invoke(); if (options.IsolatedServiceProvider == null) { stmt = _epService.CreateEPLStatementId(item.Expression, statementName, userObject, statementId); } else { var unit = _statementIsolationService.GetIsolationUnit(options.IsolatedServiceProvider, -1); var spi = (EPAdministratorIsolatedSPI)unit.EPAdministrator; stmt = spi.CreateEPLStatementId(item.Expression, statementName, userObject, statementId); } } statementNames.Add(new DeploymentInformationItem(stmt.Name, stmt.Text)); statements.Add(stmt); ICollection <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.IsNotEmpty()) { if (options.IsRollbackOnFail) { Log.Debug("Rolling back intermediate statements for deployment"); foreach (var 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); } var 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 (var 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); } var deploymentInfoArr = statementNames.ToArray(); var desc = new DeploymentInformation(deploymentId, module, addedDate.TranslateTo(_timeZone), DateTime.Now, deploymentInfoArr, DeploymentState.DEPLOYED); _deploymentStateService.AddUpdateDeployment(desc); if (Log.IsDebugEnabled) { Log.Debug("Module " + module + " was successfully deployed."); } return(new DeploymentResult(desc.DeploymentId, statements.AsReadOnlyList(), imports)); }