private static EvaluatorException CreateEvaluatorException(EvaluatorInfo eval) { var failureInfo = eval.Failure; var errorBytes = failureInfo.Exception.Data.ToByteArray(); if (errorBytes == null || errorBytes.Length == 0) { Logger.Log(Level.Error, "Exception without object details: {0}", failureInfo.Exception.Message); return(new EvaluatorException( eval.EvaluatorId, failureInfo.Exception.Message, string.Join(";", failureInfo.Exception.StackTrace))); } // When the Exception originates from the C# side. Exception inner; try { inner = (Exception)ByteUtilities.DeserializeFromBinaryFormat(errorBytes); } catch (SerializationException se) { inner = NonSerializableEvaluatorException.UnableToDeserialize( "Exception from Evaluator was not able to be deserialized, returning a NonSerializableEvaluatorException.", se); } return(new EvaluatorException(eval.EvaluatorId, inner.Message, inner)); }
private BridgeFailedContext CreateFailedContextAndForget(EvaluatorInfo info, string contextId) { lock (_lock) { var evaluatorId = info.EvaluatorId; if (_activeContexts.TryGetValue(contextId, out BridgeActiveContext activeContext)) { _activeContexts.Remove(contextId); var parentContext = activeContext.ParentId.IsPresent() ? _activeContexts[activeContext.ParentId.Value] : null; return(new BridgeFailedContext(contextId, evaluatorId, activeContext.EvaluatorDescriptor, Optional <IActiveContext> .OfNullable(parentContext))); } else { return(new BridgeFailedContext(contextId, evaluatorId, CreateEvaluatorDescriptor(info.DescriptorInfo), Optional <IActiveContext> .Empty())); } } }
public override async Task <Void> DriverRestartFailedEvaluatorHandler(EvaluatorInfo request, ServerCallContext context) { try { await _driverBridge.DispatchDriverRestartFailedEvaluatorEvent(CreateFailedEvaluator(request)); } catch (Exception ex) { _bridgeClock.Dispose(ex); } return(Void); }
public override async Task <Void> FailedEvaluatorHandler(EvaluatorInfo info, ServerCallContext context) { try { Logger.Log(Level.Info, "Failed evaluator id {0}", info.EvaluatorId); await _driverBridge.DispatchFailedEvaluatorEvent(CreateFailedEvaluator(info)); } catch (Exception ex) { _bridgeClock.Dispose(ex); } return(Void); }
public override async Task <Void> CompletedEvaluatorHandler(EvaluatorInfo request, ServerCallContext context) { try { Logger.Log(Level.Info, "Completed evaluator id {0}", request.EvaluatorId); await _driverBridge.DispatchCompletedEvaluatorEvent(new BridgeCompletedEvaluator(request.EvaluatorId)); } catch (Exception ex) { _bridgeClock.Dispose(ex); } return(Void); }
// Evaluator handlers public override async Task <Void> AllocatedEvaluatorHandler(EvaluatorInfo request, ServerCallContext context) { try { Logger.Log(Level.Info, "Allocated evaluator id {0}", request.EvaluatorId); var evaluatorDescriptor = CreateEvaluatorDescriptor(request.DescriptorInfo); await _driverBridge.DispatchAllocatedEvaluatorEventAsync( new BridgeAllocatedEvaluator(request.EvaluatorId, _driverServiceClient, evaluatorDescriptor)); } catch (Exception ex) { _bridgeClock.Dispose(ex); } return(Void); }
static EvaluatorInfo GetEvaluatorInfo(string expr, IEnumerable <string> argNames) { EvaluatorInfo evaluatorInfo; lock (s_evaluators) { if (!s_evaluators.TryGetValue(expr, out evaluatorInfo)) { evaluatorInfo = new EvaluatorInfo(); evaluatorInfo.Parameters = new List <ParameterExpression>(); evaluatorInfo.RootExpression = CreateExpr(evaluatorInfo.Parameters, s_tokenRegex.Matches(expr).Cast <Match>().ToArray()); s_evaluators.Add(expr, evaluatorInfo); } } if (evaluatorInfo.Parameters.Select(p => p.Name).Except(argNames).Any()) { throw new ArgumentException("Expression uses arguments other than the specified", "expr"); } return(evaluatorInfo); }
private BridgeFailedEvaluator CreateFailedEvaluator(EvaluatorInfo info) { try { var failedContexts = info.Failure.FailedContexts.Select(contextId => CreateFailedContextAndForget(info, contextId)).Cast <IFailedContext>().ToList(); var failedTask = string.IsNullOrEmpty(info.Failure.FailedTaskId) ? Optional <IFailedTask> .Empty() : Optional <IFailedTask> .Of(CreateFailedTaskAndForget(info.Failure.FailedTaskId, info.Failure.Exception, Optional <IActiveContext> .Empty())); return(new BridgeFailedEvaluator( info.EvaluatorId, CreateEvaluatorException(info), failedContexts, failedTask)); } catch (Exception ex) { Logger.Log(Level.Error, "could not create failed evaluator", ex); throw; } }
public DictionaryEvaluator(string name, IDictionary <string, string> propertyValues) { Info = new EvaluatorInfo(name); _propertyValues = propertyValues; }
public DictionaryEvaluator() { Info = new EvaluatorInfo("dict"); _propertyValues = new Dictionary <string, string>(); }