Exemple #1
0
        private void OnProcessExecutionEnd(UoeExecution obj)
        {
            // add compiled files to this list
            Monitor.Enter(_lock);
            try {
                if (obj is UoeExecutionCompile compilation)
                {
                    CompiledFiles.TryAddRange(compilation.CompiledFiles);
                }
            } catch (Exception e) {
                HandledExceptions.Add(new UoeExecutionException("Error when checking the compilation results.", e));
            } finally {
                Monitor.Exit(_lock);
            }

            // only do the rest when reaching the last process
            if (NumberOfProcessesRunning > 0)
            {
                return;
            }

            if (!HasBeenKilled)
            {
                PublishParallelCompilationResults();
            }
        }
        private ExceptionHandler BuildExceptionHandler(PlSqlParser.ExceptionHandlerContext context)
        {
            HandledExceptions handled;

            if (context.OTHERS() != null)
            {
                handled = HandledExceptions.Others;
            }
            else
            {
                var handledExceptions = context.id().Select(Name.Simple).ToArray();
                handled = new HandledExceptions(handledExceptions);
            }

            var handler = new ExceptionHandler(handled);

            // TODO: support labels
            var statements = context.seqOfStatements().statement().Select(Visit);

            foreach (var statement in statements)
            {
                handler.Statements.Add(statement);
            }

            return(handler);
        }
Exemple #3
0
 public override void KillProcess()
 {
     if (StartDateTime == null)
     {
         return;
     }
     if (!HasBeenKilled)
     {
         HasBeenKilled = true;
         // wait for the execution to start all the processes
         SpinWait.SpinUntil(() => Started, 10000);
         try {
             foreach (var proc in _processes)
             {
                 proc?.KillProcess();
             }
         } catch (Exception e) {
             HandledExceptions.Add(new UoeExecutionException("Error when killing compilation processes.", e));
         } finally {
             // wait for all the processes to actually exit correctly and publish their events
             SpinWait.SpinUntil(() => NumberOfProcessesRunning <= 0, 10000);
             PublishParallelCompilationResults();
         }
     }
 }
Exemple #4
0
        /// <summary>
        /// Get the results for each compiled files
        /// </summary>
        protected override void GetProcessResults()
        {
            base.GetProcessResults();

            // end of successful execution action
            if (!ExecutionFailed)
            {
                try {
                    Parallel.ForEach(CompiledFiles, file => {
                        file.ReadCompilationResults(Env.IoEncoding, _processStartDir);
                        file.ComputeRequiredDatabaseReferences(Env, AnalysisModeSimplifiedDatabaseReferences);
                    });

                    // set UoeExecutionCompilationStoppedException exception
                    for (int i = 0; i < HandledExceptions.Count; i++)
                    {
                        if (HandledExceptions[i] is UoeExecutionOpenedgeException oeException)
                        {
                            if (oeException.ErrorNumber == UoeConstants.StopOnCompilationReturnErrorCode)
                            {
                                HandledExceptions[i] = new UoeExecutionCompilationStoppedException {
                                    CompilationProblems = CompiledFiles.CopyWhere(f => f.CompilationProblems != null).SelectMany(f => f.CompilationProblems).Where(e => StopOnCompilationError ? e is UoeCompilationError : e is UoeCompilationWarning).ToList(),
                                    StopOnWarning       = StopOnCompilationWarning
                                };
                            }
                        }
                    }
                } catch (Exception e) {
                    HandledExceptions.Add(new UoeExecutionException("Error while reading the compilation results.", e));
                }
            }
        }
        protected override void HandleException(Exception exception)
        {
            if (!ShouldHandleExceptions)
            {
                throw exception;
            }

            HandledExceptions.Add(exception);
        }
Exemple #6
0
        protected override void HandleException(Exception exception)
        {
            if (!ShouldHandleExceptions)
            {
                ExceptionDispatchInfo.Capture(exception).Throw();
            }

            HandledExceptions.Add(exception);
            OnExceptionHandled?.Invoke();
        }
Exemple #7
0
 public override void Dispose()
 {
     try {
         foreach (var proc in _processes)
         {
             proc?.Dispose();
         }
     } catch (Exception e) {
         HandledExceptions.Add(new UoeExecutionException("Error when disposing of the compilation processes.", e));
     }
 }
Exemple #8
0
        /// <summary>
        /// Get the results
        /// </summary>
        protected override void GetProcessResults()
        {
            base.GetProcessResults();

            // end of successful execution action
            if (!ExecutionFailed)
            {
                try {
                    ReadExtractionResults();
                } catch (Exception e) {
                    HandledExceptions.Add(new UoeExecutionException("Error while reading the compilation results.", e));
                }
            }
        }
Exemple #9
0
 private void AssertNotHandled(HandledExceptions handled)
 {
     foreach (var handler in base.Items)
     {
         if (handler.Handled.IsForOthers &&
             handled.IsForOthers)
         {
             throw new ArgumentException("The OTHERS exception handler is already defined in the block.");
         }
         foreach (var exceptionName in handled.ExceptionNames)
         {
             if (handler.Handles(exceptionName))
             {
                 throw new ArgumentException(String.Format("Trying to add a handler for exception '{0}' that is already handled.", exceptionName));
             }
         }
     }
 }
Exemple #10
0
        private void PublishParallelCompilationResults()
        {
            Monitor.Enter(_lock);
            try {
                Ended             = true;
                ExecutionTimeSpan = TimeSpan.FromMilliseconds(DateTime.Now.Subtract(StartDateTime ?? DateTime.Now).TotalMilliseconds);
                HandledExceptions.Clear();
                HandledExceptions.AddRange(_processes.SelectMany(p => p.HandledExceptions).Where(e => !(e is UoeExecutionKilledException)));
                DatabaseConnectionFailed = _processes.Exists(p => p.DatabaseConnectionFailed);
                ExecutionFailed          = _processes.Exists(p => p.ExecutionFailed);

                // we clear all the killed exception because if one process fails, we kill the others
                // The only killed exception that matter is on the first process that failed with exceptions
                if (_firstProcessWithExceptions != null && _firstProcessWithExceptions.ExecutionHandledExceptions && _firstProcessWithExceptions.HandledExceptions.Any(e => e is UoeExecutionKilledException))
                {
                    HandledExceptions.Add(new UoeExecutionKilledException());
                }
            } finally {
                Monitor.Exit(_lock);
                PublishEndEvents();
            }
        }