contextstackingtest
Project: http://git-wip-us.apache.org/repos/asf/reef/repo Commit: http://git-wip-us.apache.org/repos/asf/reef/commit/ead50ea6 Tree: http://git-wip-us.apache.org/repos/asf/reef/tree/ead50ea6 Diff: http://git-wip-us.apache.org/repos/asf/reef/diff/ead50ea6 Branch: refs/heads/contextcheck Commit: ead50ea6dcc341e024b7614d61cf268a7d5836b3 Parents: 62168b2 Author: Dhruv <[email protected]> Authored: Thu Mar 24 18:19:45 2016 -0700 Committer: Dhruv <[email protected]> Committed: Thu Mar 24 18:19:45 2016 -0700 ---------------------------------------------------------------------- .../Functional/ContextStacking/ContextInput.cs | 2 +- .../ContextStacking/ContextStackingDriver.cs | 16 +++++++++++++++- .../Functional/ContextStacking/ContextStart.cs | 2 +- .../ContextStacking/TestContextStacking.cs | 5 +++-- 4 files changed, 20 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/reef/blob/ead50ea6/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextInput.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextInput.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextInput.cs index d6b6876..842afeb 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextInput.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextInput.cs @@ -25,7 +25,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking Logger.Log(Level.Info, string.Format("Entering context input constructor with counter {0}", s_staticCounter)); if (s_staticCounter == 2) { - throw new Exception("Entered the constructor twice"); + Logger.Log(Level.Info, "Entered the context input constructor twice"); } } http://git-wip-us.apache.org/repos/asf/reef/blob/ead50ea6/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStackingDriver.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStackingDriver.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStackingDriver.cs index a3c5c6f..139e77f 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStackingDriver.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStackingDriver.cs @@ -40,7 +40,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking public class ContextStackingDriver : IObserver<IAllocatedEvaluator>, IObserver<IActiveContext>, - IObserver<IDriverStarted> + IObserver<IDriverStarted>, IObserver<IClosedContext> { public const int NumberOfEvaluator = 1; private static readonly Logger Logger = Logger.GetLogger(typeof(ContextStackingDriver)); @@ -81,6 +81,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking if (context.Id.Equals("Stage2")) { Logger.Log(Level.Info, "Activated both contexts. Exiting"); + Logger.Log(Level.Info, string.Format("Disposing context: {0}", context.Id)); context.Dispose(); } else @@ -90,6 +91,19 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking } } + public void OnNext(IClosedContext context) + { + if (context.ParentContext != null) + { + Logger.Log(Level.Info, string.Format("Disposing context: {0}", context.ParentContext.Id)); + context.ParentContext.Dispose(); + } + else + { + Logger.Log(Level.Info, "Closed all contexts"); + } + } + public void OnNext(IDriverStarted value) { var request = http://git-wip-us.apache.org/repos/asf/reef/blob/ead50ea6/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStart.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStart.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStart.cs index f601816..1a6b9d7 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStart.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/ContextStart.cs @@ -21,7 +21,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking Logger.Log(Level.Info, string.Format("Entering context start constructor with counter {0}", s_counter)); if (s_counter == 2) { - throw new Exception("Entered the constructor twice"); + Logger.Log(Level.Info, "Entered the context start constructor twice"); } } http://git-wip-us.apache.org/repos/asf/reef/blob/ead50ea6/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/TestContextStacking.cs ---------------------------------------------------------------------- diff --git a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/TestContextStacking.cs b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/TestContextStacking.cs index 363bc58..29afb64 100644 --- a/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/TestContextStacking.cs +++ b/lang/cs/Org.Apache.REEF.Tests/Functional/ContextStacking/TestContextStacking.cs @@ -52,7 +52,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking string testFolder = DefaultRuntimeFolder + Guid.NewGuid(); CleanUp(testFolder); TestRun(DriverConfigurations(), typeof(ContextStackingDriver), 1, "simpleHandler", "local", testFolder); - ValidateSuccessForLocalRuntime(1, testFolder: testFolder); + ValidateSuccessForLocalRuntime(2, testFolder: testFolder); var messages = new List<string>(); messages.Add("Activated both contexts. Exiting"); @@ -60,7 +60,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking var messages2 = new List<string>(); messages.Add("Entering context input constructor with counter 1"); - messages.Add("Entering context start constructor with counter 1"); + messages.Add("Entering context start constructor with counter 2"); ValidateMessageSuccessfullyLogged(messages2, "Node-*", EvaluatorStdout, testFolder, 0); CleanUp(testFolder); @@ -73,6 +73,7 @@ namespace Org.Apache.REEF.Tests.Functional.ContextStacking .Set(DriverConfiguration.OnEvaluatorAllocated, GenericType<ContextStackingDriver>.Class) .Set(DriverConfiguration.OnContextActive, GenericType<ContextStackingDriver>.Class) .Set(DriverConfiguration.CustomTraceListeners, GenericType<DefaultCustomTraceListener>.Class) + .Set(DriverConfiguration.OnContextClosed, GenericType<ContextStackingDriver>.Class) .Set(DriverConfiguration.CustomTraceLevel, Level.Info.ToString()) .Build();
