public ProcessorOperationHandlerBase CreateHandler( ProcessorManagementService Svc, ProcessorOperation Operation) { switch (Operation.OperationType) { case ProcessorOperationType.Add: return(new ProcessorOperationAddHandler(Svc, Operation)); case ProcessorOperationType.Delete: return(new ProcessorOperationDeleteHandler(Svc, Operation)); case ProcessorOperationType.Pause: return(new ProcessorOperationStatusChangeHandler(Svc, Operation)); case ProcessorOperationType.Resume: return(new ProcessorOperationStatusChangeHandler(Svc, Operation)); case ProcessorOperationType.Stop: return(new ProcessorOperationStatusChangeHandler(Svc, Operation)); case ProcessorOperationType.DrainStop: return(new ProcessorOperationStatusChangeHandler(Svc, Operation)); case ProcessorOperationType.RuntimeStatusCheck: return(new ProcessorOperationStatusChangeHandler(Svc, Operation)); case ProcessorOperationType.Update: return(new ProcessorOperationUpdateHandler(Svc, Operation)); default: throw new InvalidOperationException("Can not identify Processor Operation"); } }
public ProcessorOperationHandlerBase CreateHandler( ProcessorManagementService Svc, ProcessorOperation Operation) { switch (Operation.OperationType) { case ProcessorOperationType.Add: return new ProcessorOperationAddHandler(Svc, Operation); case ProcessorOperationType.Delete: return new ProcessorOperationDeleteHandler(Svc, Operation); case ProcessorOperationType.Pause: return new ProcessorOperationStatusChangeHandler(Svc, Operation); case ProcessorOperationType.Resume: return new ProcessorOperationStatusChangeHandler(Svc, Operation); case ProcessorOperationType.Stop: return new ProcessorOperationStatusChangeHandler(Svc, Operation); case ProcessorOperationType.DrainStop: return new ProcessorOperationStatusChangeHandler(Svc, Operation); case ProcessorOperationType.RuntimeStatusCheck: return new ProcessorOperationStatusChangeHandler(Svc, Operation); case ProcessorOperationType.Update: return new ProcessorOperationUpdateHandler(Svc, Operation); default: throw new InvalidOperationException("Can not identify Processor Operation"); } }
public ProcessorOperationAddHandler( ProcessorManagementService svc, ProcessorOperation Opeartion) : base(svc, Opeartion) { }
public ProcessorOperationStatusChangeHandler( ProcessorManagementService svc, ProcessorOperation Operation) : base(svc, Operation) { }
public ProcessorOperationUpdateHandler( ProcessorManagementService svc, ProcessorOperation Operation) : base(svc, Operation) { }
public ProcessorOperationHandlerBase(ProcessorManagementService svc, ProcessorOperation Operation) { this.Svc = svc; this.processorOperation = Operation; }
protected override async Task RunAsync(CancellationToken cancellationToken) { this.SetProcessorAppInstanceDefaults(); // subscribe to configuration changes this.Context.CodePackageActivationContext.ConfigurationPackageModifiedEvent += this.CodePackageActivationContext_ConfigurationPackageModifiedEvent; this.ProcessorStateStore = await this.StateManager.GetOrAddAsync <IReliableDictionary <string, Processor> >(ProcessorDefinitionStateDictionaryName); this.ProcessorOperationsQueue = await this.StateManager.GetOrAddAsync <IReliableQueue <ProcessorOperation> >(OperationQueueName); this.ProcessorOperationFactory = new ProcessorOperationHandlerFactory(); ProcessorOperation processorOperation = null; // pump and execute ProcessorPperation from the queue while (!cancellationToken.IsCancellationRequested) { using (ITransaction tx = this.StateManager.CreateTransaction()) { try { ConditionalValue <ProcessorOperation> result = await this.ProcessorOperationsQueue.TryDequeueAsync( tx, TimeSpan.FromMilliseconds(1000), cancellationToken); if (result.HasValue) { processorOperation = result.Value; ProcessorOperationHandlerBase handler = this.ProcessorOperationFactory.CreateHandler(this, processorOperation); await handler.RunOperation(tx); await tx.CommitAsync(); } else { await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken); } } catch (TimeoutException toe) { ServiceEventSource.Current.Message( string.Format("Controller service encountered timeout in a work operations de-queue process {0} and will try again", toe.StackTrace)); } catch (AggregateException aex) { AggregateException ae = aex.Flatten(); string sError = string.Empty; if (null == processorOperation) { sError = string.Format( "Event Processor Management Service encountered an error processing Processor-Operation {0} {1} and will terminate replica", ae.GetCombinedExceptionMessage(), ae.GetCombinedExceptionStackTrace()); } else { sError = string.Format( "Event Processor Management Service encountered an error processing Processor-opeartion {0} against {1} Error {2} stack trace {3} and will terminate replica", processorOperation.OperationType.ToString(), processorOperation.ProcessorName, ae.GetCombinedExceptionMessage(), ae.GetCombinedExceptionStackTrace()); } ServiceEventSource.Current.ServiceMessage(this, sError); throw; } } } }