Repository: reef
Updated Branches:
  refs/heads/master c371affbc -> 1f22f2d94


[REEF-1294] Consider race condition in Evaluator.SetRuntimeHandlers

This addressed the issue by
  * Remove the use of InjectedRuntimeStartHandlers and 
InjectedRuntimeStopHandlers.
  * Inject EvaluatorRuntime properly via creating a configuration for it.

JIRA:
  [REEF-1294](https://issues.apache.org/jira/browse/REEF-1294)

Pull Request:
  This closes #953


Project: http://git-wip-us.apache.org/repos/asf/reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/1f22f2d9
Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/1f22f2d9
Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/1f22f2d9

Branch: refs/heads/master
Commit: 1f22f2d94b8bd947b98b4087b214c306351d4a3a
Parents: c371aff
Author: Andrew Chung <[email protected]>
Authored: Tue Apr 12 14:33:16 2016 -0700
Committer: Markus Weimer <[email protected]>
Committed: Thu Apr 14 18:30:20 2016 -0700

----------------------------------------------------------------------
 lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs  | 22 ++++++--------------
 .../Time/Runtime/RuntimeClock.cs                | 12 -----------
 2 files changed, 6 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/reef/blob/1f22f2d9/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs 
b/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
index 4f37c72..2222bd8 100644
--- a/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
+++ b/lang/cs/Org.Apache.REEF.Evaluator/Evaluator.cs
@@ -27,10 +27,10 @@ using Org.Apache.REEF.Common.Runtime.Evaluator.Utils;
 using Org.Apache.REEF.Driver.Bridge;
 using Org.Apache.REEF.Tang.Annotations;
 using Org.Apache.REEF.Tang.Formats;
-using Org.Apache.REEF.Tang.Implementations.InjectionPlan;
 using Org.Apache.REEF.Tang.Implementations.Tang;
 using Org.Apache.REEF.Tang.Interface;
 using Org.Apache.REEF.Utilities.Logging;
+using Org.Apache.REEF.Wake.Time;
 using Org.Apache.REEF.Wake.Time.Runtime;
 using Org.Apache.REEF.Wake.Time.Runtime.Event;
 
@@ -44,13 +44,11 @@ namespace Org.Apache.REEF.Evaluator
         [Inject]
         private Evaluator(
             RuntimeClock clock,
-            EvaluatorRuntime evaluatorRuntime,
             CustomTraceListeners customTraceListeners,
             CustomTraceLevel customTraceLevel)
         {
             _clock = clock;
             SetCustomTraceListeners(customTraceListeners, customTraceLevel);
-            SetRuntimeHandlers(evaluatorRuntime, clock);
         }
 
         private void Run()
@@ -81,8 +79,11 @@ namespace Org.Apache.REEF.Evaluator
                 var fullEvaluatorConfiguration = 
ReadEvaluatorConfiguration(args[0]);
                 var injector = 
TangFactory.GetTang().NewInjector(fullEvaluatorConfiguration);
                 var serializer = 
injector.GetInstance<AvroConfigurationSerializer>();
-                var rootEvaluatorConfiguration =
-                    
serializer.FromString(injector.GetNamedInstance<EvaluatorConfiguration, 
string>());
+                var rootEvaluatorConfiguration = 
+                    
TangFactory.GetTang().NewConfigurationBuilder(serializer.FromString(injector.GetNamedInstance<EvaluatorConfiguration,
 string>()))
+                        .BindSetEntry<IClock.RuntimeStartHandler, 
EvaluatorRuntime, IObserver<RuntimeStart>>()
+                        .BindSetEntry<IClock.RuntimeStopHandler, 
EvaluatorRuntime, IObserver<RuntimeStop>>()
+                        .Build();
                 var evaluator = 
injector.ForkInjector(rootEvaluatorConfiguration).GetInstance<Evaluator>();
 
                 evaluator.Run();
@@ -166,17 +167,6 @@ namespace Org.Apache.REEF.Evaluator
             Fail((Exception)e.ExceptionObject);
         }
 
-        // set the handlers for runtimeclock manually
-        // we only need runtimestart and runtimestop handlers now
-        private static void SetRuntimeHandlers(EvaluatorRuntime 
evaluatorRuntime, RuntimeClock clock)
-        {
-            ISet<IObserver<RuntimeStart>> runtimeStarts = new 
HashSet<IObserver<RuntimeStart>> { evaluatorRuntime };
-            clock.InjectedRuntimeStartHandler = new 
InjectionFutureImpl<ISet<IObserver<RuntimeStart>>>(runtimeStarts);
-
-            ISet<IObserver<RuntimeStop>> runtimeStops = new 
HashSet<IObserver<RuntimeStop>> { evaluatorRuntime };
-            clock.InjectedRuntimeStopHandler = new 
InjectionFutureImpl<ISet<IObserver<RuntimeStop>>>(runtimeStops);
-        }
-
         private static void Fail(Exception ex)
         {
             var message = "Unhandled exception caught in Evaluator. Current 
files in the working directory: " +

http://git-wip-us.apache.org/repos/asf/reef/blob/1f22f2d9/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs 
b/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs
index ae198fb..672c857 100644
--- a/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs
+++ b/lang/cs/Org.Apache.REEF.Wake/Time/Runtime/RuntimeClock.cs
@@ -81,18 +81,6 @@ namespace Org.Apache.REEF.Wake.Time.Runtime
             }
         }
 
-        public IInjectionFuture<ISet<IObserver<RuntimeStart>>> 
InjectedRuntimeStartHandler
-        {
-            get { return _runtimeStartHandler; }
-            set { _runtimeStartHandler = value; }
-        }
-
-        public IInjectionFuture<ISet<IObserver<RuntimeStop>>> 
InjectedRuntimeStopHandler
-        {
-            get { return _runtimeStopHandler; }
-            set { _runtimeStopHandler = value; }
-        }
-
         /// <summary>
         /// Schedule a TimerEvent at the given future offset
         /// </summary>

Reply via email to