Ejemplo n.º 1
0
 private string GetEndPointFromContext(IFailedContext context)
 {
     if (context == null || context.EvaluatorDescriptor == null || context.EvaluatorDescriptor.NodeDescriptor == null)
     {
         return(null);
     }
     return(context.EvaluatorDescriptor.NodeDescriptor.HostName);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a mock IFailedContext
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        private static IFailedContext CreateMockFailedContext(int id)
        {
            IFailedContext mockFailedContext = Substitute.For <IFailedContext>();

            mockFailedContext.Id.Returns(ContextIdPrefix + id);
            mockFailedContext.EvaluatorId.Returns(EvaluatorIdPrefix + ContextIdPrefix + id);
            return(mockFailedContext);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Specifies what to do if Failed Context is received.
 /// An exception is thrown if tasks are not completed.
 /// </summary>
 /// <param name="value"></param>
 public void OnNext(IFailedContext value)
 {
     if (AreIMRUTasksCompleted())
     {
         Logger.Log(Level.Info,
                    string.Format("Context with Id: {0} failed but IMRU task is completed. So ignoring.", value.Id));
         return;
     }
     Exceptions.Throw(new Exception(string.Format("Data Loading Context with Id: {0} failed", value.Id)), Logger);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// IFailedContext handler. It specifies what to do if Failed Context is received.
        /// If we get all completed tasks then ignore the failure otherwise throw exception
        /// Fault tolerant would be similar to FailedEvaluator.
        /// </summary>
        /// <param name="failedContext"></param>
        public void OnNext(IFailedContext failedContext)
        {
            lock (_lock)
            {
                if (_taskManager.AreAllTasksCompleted())
                {
                    Logger.Log(Level.Info, "Context with Id: {0} failed but IMRU tasks are completed. So ignoring.", failedContext.Id);
                    return;
                }

                var msg = string.Format("Context with Id: {0} failed with Evaluator id: {1}", failedContext.Id, failedContext.EvaluatorId);
                Exceptions.Throw(new Exception(msg), Logger);
            }
        }
            /// <summary>
            /// This will be ContextId1.
            /// It will submit a Task to the parent of Context with ContextId1.
            /// </summary>
            public void OnNext(IFailedContext value)
            {
                Assert.Equal(ContextId1, value.Id);
                Assert.True(value.ParentContext.IsPresent());
                Assert.Equal(ContextId0, value.ParentContext.Value.Id);

                // TODO[JIRA REEF-1468]: Validate that Exception is properly serialized.
                Logger.Log(Level.Info, FailedContextReceived);

                value.ParentContext.Value.SubmitTask(
                    TaskConfiguration.ConfigurationModule
                    .Set(TaskConfiguration.Identifier, TaskId)
                    .Set(TaskConfiguration.Task, GenericType <NullTask> .Class)
                    .Build());
            }
            /// <summary>
            /// Only Context2 is expected as the FailedContext.
            /// Context0 should trigger a FailedEvaluator directly.
            /// Submit a Task on to the parent of Context2 (Context1) and make sure
            /// that it runs to completion.
            /// </summary>
            public void OnNext(IFailedContext value)
            {
                Assert.Equal(Context2, value.Id);
                Assert.True(value.ParentContext.IsPresent(), "Expected " + Context2 + " to have parent of " + Context1);

                if (value.ParentContext.IsPresent())
                {
                    // Submit Task on the good Context, i.e. the FailedContext's parent.
                    Assert.Equal(Context1, value.ParentContext.Value.Id);
                    value.ParentContext.Value.SubmitTask(
                        TaskConfiguration.ConfigurationModule
                        .Set(TaskConfiguration.Identifier, TaskId)
                        .Set(TaskConfiguration.Task, GenericType <ServiceConstructorExceptionTestTask> .Class)
                        .Build());
                }

                Logger.Log(Level.Info, FailedContextReceived);
            }
Ejemplo n.º 7
0
 public void OnNext(IFailedContext value)
 {
     throw new Exception("Did not expect Failed Context.");
 }
Ejemplo n.º 8
0
 public void OnNext(IFailedContext context)
 {
     Log.Log(Level.Warning, "Context failed: " + context.Id);
     CheckMsgOrder(context);
 }
Ejemplo n.º 9
0
 public async Task DispatchFailedContextEvent(IFailedContext failedContextEvent)
 {
     await DispatchAsync(_failedContextDispatcher, failedContextEvent);
 }
 public void OnNext(IFailedContext value)
 {
     throw new Exception("The Driver does not expect a Failed Context message.");
 }
Ejemplo n.º 11
0
 public void OnNext(IFailedContext value)
 {
     throw new Exception(UnexpectedFailedContext);
 }