Repository: incubator-reef
Updated Branches:
refs/heads/master 92806d0df -> e1a386025
[REEF-540] DriverRestartHandler is not bound correctly to its C# equivalent
This addressed the issue by
* Adding InterOp functions for restart-related (DriverRestarted,
DriverRestartCompleted) operations.
* Adding missing restart configurations to DriverConfiguration and
DriverBridgeConfiguration.
* Calling the restart handler on driver restart instead of calling the
start handler.
JIRA:
[REEF-540](https://issues.apache.org/jira/browse/REEF-540)
Pull Request:
This closes #354
Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/e1a38602
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/e1a38602
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/e1a38602
Branch: refs/heads/master
Commit: e1a3860250c2cd2e621e65362f6718294b041422
Parents: 92806d0
Author: Andrew Chung <[email protected]>
Authored: Fri Aug 7 17:30:52 2015 -0700
Committer: Markus Weimer <[email protected]>
Committed: Mon Aug 17 10:08:30 2015 -0700
----------------------------------------------------------------------
.../cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp | 63 +++++++----
.../ClrClient2JavaClientCuratedParameters.cs | 28 +----
.../Bridge/ClrSystemHandlerWrapper.cs | 31 ++++--
.../Bridge/DriverBridge.cs | 76 +++++++++-----
.../Bridge/DriverBridgeConfiguration.cs | 18 ++--
.../Bridge/DriverBridgeConfigurationOptions.cs | 9 +-
.../Bridge/DriverRestartHandlerWrapper.cs | 60 -----------
.../Bridge/Events/DriverRestartCompleted.cs | 41 ++++++++
lang/cs/Org.Apache.REEF.Driver/Constants.cs | 104 +++++++++++++++++--
.../DefaultDriverRestartCompletedHandler.cs | 55 ++++++++++
.../DriverConfiguration.cs | 19 ++--
.../IDriverRestartCompleted.cs | 31 ++++++
.../Org.Apache.REEF.Driver.csproj | 4 +-
.../AllHandlers.cs | 2 +-
.../HelloRestartHandler.cs | 7 +-
.../apache/reef/javabridge/NativeInterop.java | 18 ++--
.../reef/javabridge/generic/JobDriver.java | 14 +--
17 files changed, 397 insertions(+), 183 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp
b/lang/cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp
index 3571f86..e2f1523 100644
--- a/lang/cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp
+++ b/lang/cs/Org.Apache.REEF.Bridge/JavaClrBridge.cpp
@@ -103,14 +103,9 @@ JNIEXPORT jlongArray JNICALL
Java_org_apache_reef_javabridge_NativeInterop_callC
(JNIEnv * env, jclass jclassx, jstring dateTimeString, jstring httpServerPort,
jobject jevaluatorRequestorBridge) {
try {
ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_callClrSystemOnStartHandler");
- const wchar_t* charConfig = UnicodeCppStringFromJavaString (env,
dateTimeString);
- int lenConfig = env->GetStringLength(dateTimeString);
- String^ strConfig = Marshal::PtrToStringUni((IntPtr)(unsigned short*)
charConfig, lenConfig);
DateTime dt = DateTime::Now;
- const wchar_t* charPort = UnicodeCppStringFromJavaString (env,
httpServerPort);
- int lenPort = env->GetStringLength(httpServerPort);
- String^ strPort = Marshal::PtrToStringUni((IntPtr)(unsigned short*)
charPort, lenPort);
+ String^ strPort = ManagedStringFromJavaString(env, httpServerPort);
EvaluatorRequestorClr2Java^ evaluatorRequestorBridge = gcnew
EvaluatorRequestorClr2Java(env, jevaluatorRequestorBridge);
array<unsigned long long>^ handlers =
ClrSystemHandlerWrapper::Call_ClrSystemStartHandler_OnStart(dt, strPort,
evaluatorRequestorBridge);
@@ -436,22 +431,29 @@ JNIEXPORT void JNICALL
Java_org_apache_reef_javabridge_NativeInterop_clrSystemCo
}
}
+
/*
- * Class: org_apache_reef_javabridge_NativeInterop
- * Method: clrSystemDriverRestartHandlerOnNext
- * Signature: (J)V
- */
-JNIEXPORT void JNICALL
Java_org_apache_reef_javabridge_NativeInterop_clrSystemDriverRestartHandlerOnNext
-(JNIEnv *env , jclass cls, jlong handler) {
-
ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_clrSystemDriverRestartHandlerOnNext");
- try {
- ClrSystemHandlerWrapper::Call_ClrSystemDriverRestart_OnNext(handler);
- }
- catch (System::Exception^ ex) {
- String^ errorMessage = "Exception in Call_ClrSystemContextMessage_OnNext";
- ManagedLog::LOGGER->LogError(errorMessage, ex);
- // we do not call back to Java for exception in .NET restart handler
- }
+* Class: org_apache_reef_javabridge_NativeInterop
+* Method: callClrSystemOnRestartHandlerOnNext
+* Signature:
(Ljava/lang/String;Ljava/lang/String;Lorg/apache/reef/javabridge/EvaluatorRequestorBridge;)[J
+*/
+JNIEXPORT jlongArray JNICALL
Java_org_apache_reef_javabridge_NativeInterop_callClrSystemOnRestartHandlerOnNext
+(JNIEnv * env, jclass jclassx, jstring dateTimeString, jstring httpServerPort,
jobject jevaluatorRequestorBridge)
+{
+ try {
+
ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_callClrSystemOnStartHandler");
+ DateTime dt = DateTime::Now;
+ String^ strPort = ManagedStringFromJavaString(env,
httpServerPort);
+
+ EvaluatorRequestorClr2Java^ evaluatorRequestorBridge = gcnew
EvaluatorRequestorClr2Java(env, jevaluatorRequestorBridge);
+ array<unsigned long long>^ handlers =
ClrSystemHandlerWrapper::Call_ClrSystemRestartHandler_OnRestart(dt, strPort,
evaluatorRequestorBridge);
+ return JavaLongArrayFromManagedLongArray(env, handlers);
+ }
+ catch (System::Exception^ ex) {
+ // we cannot get error back to java here since we don't have an
object to call back (although we ideally should...)
+ ManagedLog::LOGGER->LogError("Exceptions in
Java_org_apache_reef_javabridge_NativeInterop_callClrSystemOnStartHandler", ex);
+ return NULL;
+ }
}
/*
@@ -490,4 +492,21 @@ JNIEXPORT void JNICALL
Java_org_apache_reef_javabridge_NativeInterop_clrSystemDr
ManagedLog::LOGGER->LogError(errorMessage, ex);
runningTaskBridge -> OnError(errorMessage);
}
-}
\ No newline at end of file
+}
+
+/*
+* Class: org_apache_reef_javabridge_NativeInterop
+* Method: clrSystemDriverRestartCompletedHandlerOnNext
+* Signature: (J)V
+*/
+JNIEXPORT void JNICALL
Java_org_apache_reef_javabridge_NativeInterop_clrSystemDriverRestartCompletedHandlerOnNext
+(JNIEnv * env, jclass cls, jlong handler) {
+
ManagedLog::LOGGER->Log("+Java_org_apache_reef_javabridge_NativeInterop_clrSystemDriverRestartCompletedHandlerOnNext");
+ try {
+
ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartCompleted_OnNext(handler);
+ }
+ catch (System::Exception^ ex) {
+ String^ errorMessage = "Exception in
Call_ClrSystemDriverRestartRunningTask_OnNext";
+ ManagedLog::LOGGER->LogError(errorMessage, ex);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Client/Common/ClrClient2JavaClientCuratedParameters.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Client/Common/ClrClient2JavaClientCuratedParameters.cs
b/lang/cs/Org.Apache.REEF.Client/Common/ClrClient2JavaClientCuratedParameters.cs
index 473e223..9b5cd9a 100644
---
a/lang/cs/Org.Apache.REEF.Client/Common/ClrClient2JavaClientCuratedParameters.cs
+++
b/lang/cs/Org.Apache.REEF.Client/Common/ClrClient2JavaClientCuratedParameters.cs
@@ -18,6 +18,8 @@
*/
using System;
+using System.Collections.Generic;
+using System.Linq;
using Org.Apache.REEF.Driver;
using Org.Apache.REEF.Driver.Bridge;
using Org.Apache.REEF.Tang.Annotations;
@@ -47,36 +49,14 @@ namespace Org.Apache.REEF.Client.Common
[Parameter(typeof(TcpPortRangeTryCount))] int tcpPortRangeTryCount,
[Parameter(typeof(TcpPortRangeSeed))] int tcpPortRangeSeed,
[Parameter(typeof(DriverBridgeConfigurationOptions.MaxApplicationSubmissions))]
int maxApplicationSubmissions,
-
[Parameter(typeof(DriverBridgeConfigurationOptions.DriverRestartedHandler))]
IObserver<IDriverRestarted> restartHandler)
- : this(tcpPortRangeStart, tcpPortRangeCount, tcpPortRangeTryCount,
tcpPortRangeSeed, maxApplicationSubmissions, true)
- {
- }
-
- [Inject]
- private ClrClient2JavaClientCuratedParameters(
- [Parameter(typeof(TcpPortRangeStart))] int tcpPortRangeStart,
- [Parameter(typeof(TcpPortRangeCount))] int tcpPortRangeCount,
- [Parameter(typeof(TcpPortRangeTryCount))] int tcpPortRangeTryCount,
- [Parameter(typeof(TcpPortRangeSeed))] int tcpPortRangeSeed,
-
[Parameter(typeof(DriverBridgeConfigurationOptions.MaxApplicationSubmissions))]
int maxApplicationSubmissions)
- : this(tcpPortRangeStart, tcpPortRangeCount, tcpPortRangeTryCount,
tcpPortRangeSeed, maxApplicationSubmissions, false)
- {
- }
-
- private ClrClient2JavaClientCuratedParameters(
- int tcpPortRangeStart,
- int tcpPortRangeCount,
- int tcpPortRangeTryCount,
- int tcpPortRangeSeed,
- int maxApplicationSubmissions,
- bool enableRestart)
+
[Parameter(typeof(DriverBridgeConfigurationOptions.DriverRestartedHandlers))]
ISet<IObserver<IDriverRestarted>> restartHandlers)
{
TcpPortRangeStart = tcpPortRangeStart;
TcpPortRangeCount = tcpPortRangeCount;
TcpPortRangeTryCount = tcpPortRangeTryCount;
TcpPortRangeSeed = tcpPortRangeSeed;
MaxApplicationSubmissions = maxApplicationSubmissions;
- EnableRestart = enableRestart;
+ EnableRestart = restartHandlers.Any();
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandlerWrapper.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandlerWrapper.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandlerWrapper.cs
index c6e07c6..03e2746 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandlerWrapper.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/ClrSystemHandlerWrapper.cs
@@ -18,13 +18,9 @@
*/
using System;
-using System.CodeDom;
using System.Globalization;
-using System.IO;
using System.Runtime.InteropServices;
-using Org.Apache.REEF.Common;
using Org.Apache.REEF.Common.Context;
-using Org.Apache.REEF.Common.Files;
using Org.Apache.REEF.Driver.Bridge.Clr2java;
using Org.Apache.REEF.Driver.Bridge.Events;
using Org.Apache.REEF.Driver.Context;
@@ -32,7 +28,6 @@ using Org.Apache.REEF.Driver.Evaluator;
using Org.Apache.REEF.Driver.Task;
using Org.Apache.REEF.Utilities.Diagnostics;
using Org.Apache.REEF.Utilities.Logging;
-using Org.Apache.REEF.Wake.Time.Event;
using ContextMessage = Org.Apache.REEF.Driver.Bridge.Events.ContextMessage;
namespace Org.Apache.REEF.Driver.Bridge
@@ -215,16 +210,17 @@ namespace Org.Apache.REEF.Driver.Bridge
}
}
- public static void Call_ClrSystemDriverRestart_OnNext(ulong handle)
+ public static void Call_ClrSystemDriverRestartCompleted_OnNext(ulong
handle)
{
- using
(LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestart_OnNext"))
+ using
(LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemDriverRestartCompleted_OnNext"))
{
GCHandle gc = GCHandle.FromIntPtr((IntPtr)handle);
- ClrSystemHandler<StartTime> obj =
(ClrSystemHandler<StartTime>)gc.Target;
- obj.OnNext(new StartTime(DateTime.Now.Ticks));
+ ClrSystemHandler<IDriverRestartCompleted> obj =
(ClrSystemHandler<IDriverRestartCompleted>)gc.Target;
+ obj.OnNext(new DriverRestartCompleted(DateTime.Now));
}
}
+
//Deprecate, remove after both Java and C# code gets checked in
public static ulong[] Call_ClrSystemStartHandler_OnStart(
DateTime startTime,
@@ -256,6 +252,23 @@ namespace Org.Apache.REEF.Driver.Bridge
}
}
+ public static ulong[] Call_ClrSystemRestartHandler_OnRestart(
+ DateTime startTime,
+ string httpServerPort,
+ IEvaluatorRequestorClr2Java evaluatorRequestorClr2Java)
+ {
+ IEvaluatorRequestor evaluatorRequestor = new
EvaluatorRequestor(evaluatorRequestorClr2Java);
+ using
(LOGGER.LogFunction("ClrSystemHandlerWrapper::Call_ClrSystemRestartHandler_OnRestart"))
+ {
+ LOGGER.Log(Level.Info, "*** Restart time is " + startTime);
+ LOGGER.Log(Level.Info, "*** httpServerPort: " +
httpServerPort);
+ var handlers = GetHandlers(httpServerPort, evaluatorRequestor);
+ _driverBridge.RestartHandlerOnNext(startTime);
+
+ return handlers;
+ }
+ }
+
private static ulong[] GetHandlers(string httpServerPortNumber,
IEvaluatorRequestor evaluatorRequestor)
{
var injector =
BridgeConfigurationProvider.GetBridgeInjector(evaluatorRequestor);
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridge.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridge.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridge.cs
index 2596c42..d7e9c9e 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridge.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridge.cs
@@ -53,6 +53,8 @@ namespace Org.Apache.REEF.Driver.Bridge
private static ClrSystemHandler<IRunningTask>
_driverRestartRunningTaskSubscriber;
+ private static ClrSystemHandler<IDriverRestartCompleted>
_driverRestartCompletedSubscriber;
+
private static ClrSystemHandler<ISuspendedTask>
_suspendedTaskSubscriber;
private static ClrSystemHandler<IFailedEvaluator>
_failedEvaluatorSubscriber;
@@ -69,11 +71,11 @@ namespace Org.Apache.REEF.Driver.Bridge
private static ClrSystemHandler<IContextMessage>
_contextMessageSubscriber;
- private static ClrSystemHandler<StartTime> _driverRestartSubscriber;
+ private static ClrSystemHandler<IDriverRestarted>
_driverRestartedSubscriber;
private readonly ISet<IObserver<IDriverStarted>> _driverStartHandlers;
- private readonly IObserver<StartTime> _legacyDriverRestartHandler;
+ private readonly ISet<IObserver<IDriverRestarted>>
_driverRestartedHandlers;
private readonly ISet<IObserver<IEvaluatorRequestor>>
_evaluatorRequestHandlers;
@@ -93,6 +95,8 @@ namespace Org.Apache.REEF.Driver.Bridge
private readonly ISet<IObserver<IRunningTask>>
_driverRestartRunningTaskHandlers;
+ private readonly ISet<IObserver<IDriverRestartCompleted>>
_driverRestartCompletedHandlers;
+
private readonly ISet<IObserver<IFailedEvaluator>>
_failedEvaluatorHandlers;
private readonly ISet<IObserver<ICompletedEvaluator>>
_completedEvaluatorHandlers;
@@ -112,8 +116,7 @@ namespace Org.Apache.REEF.Driver.Bridge
[Inject]
public DriverBridge(
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverStartedHandlers))]
ISet<IObserver<IDriverStarted>> driverStartHandlers,
- [Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartHandler))]
IObserver<StartTime> legacyDriverRestartHandler,
- [Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartedHandler))]
IObserver<IDriverRestarted> driverRestartedHandler,
+ [Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartedHandlers))]
ISet<IObserver<IDriverRestarted>> driverRestartedHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.EvaluatorRequestHandlers))]
ISet<IObserver<IEvaluatorRequestor>> evaluatorRequestHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.AllocatedEvaluatorHandlers))]
ISet<IObserver<IAllocatedEvaluator>> allocatedEvaluatorHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.ActiveContextHandlers))]
ISet<IObserver<IActiveContext>> activeContextHandlers,
@@ -129,6 +132,7 @@ namespace Org.Apache.REEF.Driver.Bridge
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.ContextMessageHandlers))]
ISet<IObserver<IContextMessage>> contextMessageHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers))]
ISet<IObserver<IActiveContext>> driverRestartActiveContextHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartRunningTaskHandlers))]
ISet<IObserver<IRunningTask>> driverRestartRunningTaskHandlers,
+ [Parameter(Value =
typeof(DriverBridgeConfigurationOptions.DriverRestartCompletedHandlers))]
ISet<IObserver<IDriverRestartCompleted>> driverRestartCompletedHandlers,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.TraceListenersSet))]
ISet<TraceListener> traceListeners,
[Parameter(Value = typeof(EvaluatorConfigurationProviders))]
ISet<IConfigurationProvider> configurationProviders,
[Parameter(Value =
typeof(DriverBridgeConfigurationOptions.TraceLevel))] string traceLevel,
@@ -165,9 +169,10 @@ namespace Org.Apache.REEF.Driver.Bridge
_closedContextHandlers = closedContextHandlers;
_failedContextHandlers = failedContextHandlers;
_contextMessageHandlers = contextMessageHandlers;
- _legacyDriverRestartHandler = new
DriverRestartHandlerWrapper(legacyDriverRestartHandler, driverRestartedHandler);
+ _driverRestartedHandlers = driverRestartedHandlers;
_driverRestartActiveContextHandlers =
driverRestartActiveContextHandlers;
_driverRestartRunningTaskHandlers =
driverRestartRunningTaskHandlers;
+ _driverRestartCompletedHandlers = driverRestartCompletedHandlers;
_httpServerHandler = httpServerHandler;
_configurationProviders = configurationProviders;
@@ -184,25 +189,21 @@ namespace Org.Apache.REEF.Driver.Bridge
_closedContextSubscriber = new ClrSystemHandler<IClosedContext>();
_failedContextSubscriber = new ClrSystemHandler<IFailedContext>();
_contextMessageSubscriber = new
ClrSystemHandler<IContextMessage>();
- _driverRestartSubscriber = new ClrSystemHandler<StartTime>();
+ _driverRestartedSubscriber = new
ClrSystemHandler<IDriverRestarted>();
_driverRestartActiveContextSubscriber = new
ClrSystemHandler<IActiveContext>();
_driverRestartRunningTaskSubscriber = new
ClrSystemHandler<IRunningTask>();
+ _driverRestartCompletedSubscriber = new
ClrSystemHandler<IDriverRestartCompleted>();
}
public ulong[] Subscribe()
{
ulong[] handlers = Enumerable.Repeat(Constants.NullHandler,
Constants.HandlersNumber).ToArray();
- // subscribe to StartTime event for driver restart
- _driverRestartSubscriber.Subscribe(_legacyDriverRestartHandler);
- _logger.Log(Level.Info, "subscribed to Driver restart handler: " +
_legacyDriverRestartHandler);
- handlers[Constants.Handlers[Constants.DriverRestartHandler]] =
ClrHandlerHelper.CreateHandler(_driverRestartSubscriber);
-
// subscribe to Allocated Evaluator
foreach (var handler in _allocatedEvaluatorHandlers)
{
_allocatedEvaluatorSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IAllocatedEvaluator
handler: " + handler);
+ _logger.Log(Level.Verbose, "subscribed to IAllocatedEvaluator
handler: " + handler);
}
handlers[Constants.Handlers[Constants.AllocatedEvaluatorHandler]]
= ClrHandlerHelper.CreateHandler(_allocatedEvaluatorSubscriber);
@@ -210,7 +211,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _taskMessageHandlers)
{
_taskMessageSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to ITaskMessage handler: "
+ handler);
+ _logger.Log(Level.Verbose, "subscribed to ITaskMessage
handler: " + handler);
}
handlers[Constants.Handlers[Constants.TaskMessageHandler]] =
ClrHandlerHelper.CreateHandler(_taskMessageSubscriber);
@@ -218,7 +219,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _activeContextHandlers)
{
_activeContextSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IActiveContext handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to IActiveContext
handler: " + handler);
}
handlers[Constants.Handlers[Constants.ActiveContextHandler]] =
ClrHandlerHelper.CreateHandler(_activeContextSubscriber);
@@ -226,7 +227,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _failedTaskHandlers)
{
_failedTaskSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IFailedTask handler: "
+ handler);
+ _logger.Log(Level.Verbose, "subscribed to IFailedTask handler:
" + handler);
}
handlers[Constants.Handlers[Constants.FailedTaskHandler]] =
ClrHandlerHelper.CreateHandler(_failedTaskSubscriber);
@@ -234,7 +235,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _runningTaskHandlers)
{
_runningTaskSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IRunningask handler: "
+ handler);
+ _logger.Log(Level.Verbose, "subscribed to IRunningask handler:
" + handler);
}
handlers[Constants.Handlers[Constants.RunningTaskHandler]] =
ClrHandlerHelper.CreateHandler(_runningTaskSubscriber);
@@ -242,7 +243,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _completedTaskHandlers)
{
_completedTaskSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to ICompletedTask handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to ICompletedTask
handler: " + handler);
}
handlers[Constants.Handlers[Constants.CompletedTaskHandler]] =
ClrHandlerHelper.CreateHandler(_completedTaskSubscriber);
@@ -250,7 +251,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _suspendedTaskHandlers)
{
_suspendedTaskSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to ISuspendedTask handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to ISuspendedTask
handler: " + handler);
}
handlers[Constants.Handlers[Constants.SuspendedTaskHandler]] =
ClrHandlerHelper.CreateHandler(_suspendedTaskSubscriber);
@@ -258,7 +259,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _failedEvaluatorHandlers)
{
_failedEvaluatorSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IFailedEvaluator
handler: " + handler);
+ _logger.Log(Level.Verbose, "subscribed to IFailedEvaluator
handler: " + handler);
}
handlers[Constants.Handlers[Constants.FailedEvaluatorHandler]] =
ClrHandlerHelper.CreateHandler(_failedEvaluatorSubscriber);
@@ -266,7 +267,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _completedEvaluatorHandlers)
{
_completedEvaluatorSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to ICompletedEvaluator
handler: " + handler);
+ _logger.Log(Level.Verbose, "subscribed to ICompletedEvaluator
handler: " + handler);
}
handlers[Constants.Handlers[Constants.CompletedEvaluatorHandler]]
= ClrHandlerHelper.CreateHandler(_completedEvaluatorSubscriber);
@@ -274,7 +275,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _closedContextHandlers)
{
_closedContextSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IClosedContext handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to IClosedContext
handler: " + handler);
}
handlers[Constants.Handlers[Constants.ClosedContextHandler]] =
ClrHandlerHelper.CreateHandler(_closedContextSubscriber);
@@ -282,7 +283,7 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _failedContextHandlers)
{
_failedContextSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IFailedContext handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to IFailedContext
handler: " + handler);
}
handlers[Constants.Handlers[Constants.FailedContextHandler]] =
ClrHandlerHelper.CreateHandler(_failedContextSubscriber);
@@ -290,15 +291,15 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _contextMessageHandlers)
{
_contextMessageSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to IContextMesage handler:
" + handler);
+ _logger.Log(Level.Verbose, "subscribed to IContextMesage
handler: " + handler);
}
handlers[Constants.Handlers[Constants.ContextMessageHandler]] =
ClrHandlerHelper.CreateHandler(_contextMessageSubscriber);
-
+
// subscribe to Active Context received during driver restart
foreach (var handler in _driverRestartActiveContextHandlers)
{
_driverRestartActiveContextSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to handler for
IActiveContext received during driver restart: " + handler);
+ _logger.Log(Level.Verbose, "subscribed to handler for
IActiveContext received during driver restart: " + handler);
}
handlers[Constants.Handlers[Constants.DriverRestartActiveContextHandler]] =
ClrHandlerHelper.CreateHandler(_driverRestartActiveContextSubscriber);
@@ -306,13 +307,21 @@ namespace Org.Apache.REEF.Driver.Bridge
foreach (var handler in _driverRestartRunningTaskHandlers)
{
_driverRestartRunningTaskSubscriber.Subscribe(handler);
- _logger.Log(Level.Info, "subscribed to handler for
IRunningTask received during driver restart: " + handler);
+ _logger.Log(Level.Verbose, "subscribed to handler for
IRunningTask received during driver restart: " + handler);
}
handlers[Constants.Handlers[Constants.DriverRestartRunningTaskHandler]] =
ClrHandlerHelper.CreateHandler(_driverRestartRunningTaskSubscriber);
+ // subscribe to Restart Completed received during driver restart
+ foreach (var handler in _driverRestartCompletedHandlers)
+ {
+ _driverRestartCompletedSubscriber.Subscribe(handler);
+ _logger.Log(Level.Verbose, "subscribed to handler for
IRestartCompleted received during driver restart: " + handler);
+ }
+
handlers[Constants.Handlers[Constants.DriverRestartCompletedHandler]] =
ClrHandlerHelper.CreateHandler(_driverRestartCompletedSubscriber);
+
// subscribe to Http message
_httpServerEventSubscriber.Subscribe(_httpServerHandler);
- _logger.Log(Level.Info, "subscribed to IHttpMessage handler :" +
_httpServerHandler);
+ _logger.Log(Level.Verbose, "subscribed to IHttpMessage handler :"
+ _httpServerHandler);
handlers[Constants.Handlers[Constants.HttpServerHandler]] =
ClrHandlerHelper.CreateHandler(_httpServerEventSubscriber);
return handlers;
@@ -341,6 +350,19 @@ namespace Org.Apache.REEF.Driver.Bridge
}
}
+ /// <summary>
+ /// Call restart handlers
+ /// </summary>
+ internal void RestartHandlerOnNext(DateTime startTime)
+ {
+ var driverRestarted = new DriverRestarted(startTime);
+ foreach (var handler in _driverRestartedHandlers)
+ {
+ handler.OnNext(driverRestarted);
+ _logger.Log(Level.Info, "called OnDriverRestarted handler: " +
handler);
+ }
+ }
+
internal ISet<IConfigurationProvider> ConfigurationProviders { get {
return _configurationProviders; } }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfiguration.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfiguration.cs
index 78f0237..d48eb5e 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfiguration.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfiguration.cs
@@ -31,7 +31,6 @@ using Org.Apache.REEF.Tang.Annotations;
using Org.Apache.REEF.Tang.Formats;
using Org.Apache.REEF.Tang.Util;
using Org.Apache.REEF.Utilities.Logging;
-using Org.Apache.REEF.Wake.Time.Event;
[module: SuppressMessage("StyleCop.CSharp.MaintainabilityRules",
"SA1401:FieldsMustBePrivate", Justification = "static field, typical usage in
configurations")]
@@ -48,10 +47,10 @@ namespace Org.Apache.REEF.Driver.Bridge
public static readonly OptionalImpl<IStartHandler> OnDriverStarted =
new OptionalImpl<IStartHandler>();
/// <summary>
- /// The event handler invoked when driver restarts
+ /// The event handler invoked when driver restarts
/// </summary>
[SuppressMessage("Microsoft.Security", "CA2104:Do not declare read
only mutable reference types", Justification = "not applicable")]
- public static readonly OptionalImpl<IObserver<StartTime>>
OnDriverRestarted = new OptionalImpl<IObserver<StartTime>>();
+ public static readonly OptionalImpl<IObserver<IDriverRestarted>>
OnDriverRestarted = new OptionalImpl<IObserver<IDriverRestarted>>();
/// <summary>
/// The event handler for requesting evaluator
@@ -131,7 +130,7 @@ namespace Org.Apache.REEF.Driver.Bridge
/// Event handler for active context received during driver restart.
Defaults to closing the context if not bound.
/// </summary>
[SuppressMessage("Microsoft.Security", "CA2104:Do not declare read
only mutable reference types", Justification = "not applicable")]
- public static readonly OptionalImpl<IObserver<IActiveContext>>
OnDirverRestartContextActive = new OptionalImpl<IObserver<IActiveContext>>();
+ public static readonly OptionalImpl<IObserver<IActiveContext>>
OnDriverRestartContextActive = new OptionalImpl<IObserver<IActiveContext>>();
/// <summary>
/// Event handler for closed context. Defaults to logging if not bound.
@@ -175,6 +174,12 @@ namespace Org.Apache.REEF.Driver.Bridge
[SuppressMessage("Microsoft.Security", "CA2104:Do not declare read
only mutable reference types", Justification = "not applicable")]
public static readonly OptionalImpl<IDriverConnection>
OnDriverReconnect = new OptionalImpl<IDriverConnection>();
+ ///// <summary>
+ ///// Event handler for driver restart completed event received during
driver restart. Defaults to logging if not bound.
+ ///// </summary>
+ [SuppressMessage("Microsoft.Security", "CA2104:Do not declare read
only mutable reference types", Justification = "not applicable")]
+ public static readonly
OptionalImpl<IObserver<IDriverRestartCompleted>> OnDriverRestartCompleted = new
OptionalImpl<IObserver<IDriverRestartCompleted>>();
+
// This is currently not needed in Bridge/Driver model
///// <summary>
///// The event handler invoked right before the driver shuts down.
Defaults to ignore.
@@ -206,7 +211,7 @@ namespace Org.Apache.REEF.Driver.Bridge
{
return new DriverBridgeConfiguration()
.BindImplementation(GenericType<IStartHandler>.Class,
OnDriverStarted)
-
.BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.DriverRestartHandler>.Class,
OnDriverRestarted)
+
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartedHandlers>.Class,
OnDriverRestarted)
.BindImplementation(GenericType<IDriverConnection>.Class,
OnDriverReconnect)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.EvaluatorRequestHandlers>.Class,
OnEvaluatorRequested)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.AllocatedEvaluatorHandlers>.Class,
OnEvaluatorAllocated)
@@ -224,8 +229,9 @@ namespace Org.Apache.REEF.Driver.Bridge
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ArgumentSets>.Class,
CommandLineArguments)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.HttpEventHandlers>.Class,
OnHttpEvent)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.TraceListenersSet>.Class,
CustomTraceListeners)
-
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers>.Class,
OnDirverRestartContextActive)
+
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers>.Class,
OnDriverRestartContextActive)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartRunningTaskHandlers>.Class,
OnDriverRestartTaskRunning)
+
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartCompletedHandlers>.Class,
OnDriverRestartCompleted)
.BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.TraceLevel>.Class,
CustomTraceLevel)
.Build();
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfigurationOptions.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfigurationOptions.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfigurationOptions.cs
index 9935a89..488b2a7 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfigurationOptions.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverBridgeConfigurationOptions.cs
@@ -47,14 +47,13 @@ namespace Org.Apache.REEF.Driver.Bridge
{
}
- [Obsolete(message:"Since 0.12, Removed in 0.13. Use
DriverRestartedHandler instead.")]
- [NamedParameter(documentation: "Called when driver is restarted, after
CLR bridge is set up.", defaultClasses: new[] {
typeof(DefaultDriverRestartHandler) })]
- public class DriverRestartHandler : Name<IObserver<StartTime>>
+ [NamedParameter(documentation: "Called when driver is restarted, after
CLR bridge is set up.")]
+ public class DriverRestartedHandlers :
Name<ISet<IObserver<IDriverRestarted>>>
{
}
- [NamedParameter(documentation: "Called when driver is restarted, after
CLR bridge is set up.", defaultClasses: new[] {
typeof(DefaultDriverRestartedHandler) })]
- public class DriverRestartedHandler : Name<IObserver<IDriverRestarted>>
+ [NamedParameter(documentation: "Called when driver restart is
completed.", defaultClasses: new[] { typeof
(DefaultDriverRestartCompletedHandler) })]
+ public class DriverRestartCompletedHandlers :
Name<ISet<IObserver<IDriverRestartCompleted>>>
{
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverRestartHandlerWrapper.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverRestartHandlerWrapper.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverRestartHandlerWrapper.cs
deleted file mode 100644
index 7ff1ea4..0000000
--- a/lang/cs/Org.Apache.REEF.Driver/Bridge/DriverRestartHandlerWrapper.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-using System;
-using Org.Apache.REEF.Driver.Bridge.Events;
-using Org.Apache.REEF.Wake.Time.Event;
-
-namespace Org.Apache.REEF.Driver.Bridge
-{
- /// <summary>
- /// Wrapper of the new Observers of DriverRestarted with and into an
Observer of StartTime.
- /// </summary>
- /// <remarks>
- /// Rationale: This way, we don't have to change the C++ code in the same
change as the API.
- /// </remarks>
- internal sealed class DriverRestartHandlerWrapper : IObserver<StartTime>
- {
- private readonly IObserver<IDriverRestarted> _driverRestartedObserver;
- private readonly IObserver<StartTime> _startTimeObserver;
-
- internal DriverRestartHandlerWrapper(IObserver<StartTime>
startTimeObserver,
- IObserver<IDriverRestarted> driverRestartedObserver)
- {
- _startTimeObserver = startTimeObserver;
- _driverRestartedObserver = driverRestartedObserver;
- }
-
- public void OnNext(StartTime startTime)
- {
- _driverRestartedObserver.OnNext(new DriverRestarted(new
DateTime(startTime.TimeStamp)));
- _startTimeObserver.OnNext(startTime);
- }
-
- public void OnError(Exception error)
- {
- throw new NotImplementedException();
- }
-
- public void OnCompleted()
- {
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/DriverRestartCompleted.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/DriverRestartCompleted.cs
b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/DriverRestartCompleted.cs
new file mode 100644
index 0000000..e1db1f3
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/Bridge/Events/DriverRestartCompleted.cs
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System;
+
+namespace Org.Apache.REEF.Driver.Bridge.Events
+{
+ /// <summary>
+ /// Implementation of IDriverStarted.
+ /// </summary>
+ internal sealed class DriverRestartCompleted : IDriverRestartCompleted
+ {
+ private readonly DateTime _completedTime;
+
+ internal DriverRestartCompleted(DateTime completedTime)
+ {
+ this._completedTime = completedTime;
+ }
+
+ public DateTime CompletedTime
+ {
+ get { return this._completedTime; }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Constants.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Constants.cs
b/lang/cs/Org.Apache.REEF.Driver/Constants.cs
index 3a19bb7..c833827 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Constants.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/Constants.cs
@@ -24,55 +24,127 @@ namespace Org.Apache.REEF.Driver
{
public class Constants
{
+ /// <summary>
+ /// Null handler that is not used on Java side.
+ /// </summary>
public const ulong NullHandler = 0;
+ /// <summary>
+ /// The class hierarchy file from .NET.
+ /// </summary>
public const string ClassHierarachyBin = "clrClassHierarchy.bin";
+ /// <summary>
+ /// The file containing user supplied libaries.
+ /// </summary>
public const string GlobalUserSuppliedJavaLibraries =
"userSuppliedGlobalLibraries.txt";
+ /// <summary>
+ /// The default memory granularity for evaluators.
+ /// </summary>
public const int DefaultMemoryGranularity = 1024;
+ /// <summary>
+ /// The number of handlers total. Tightly coupled with Java.
+ /// </summary>
public const int HandlersNumber = 17;
+ /// <summary>
+ /// The name for EvaluatorRequestorHandler. Tightly coupled with Java.
+ /// </summary>
public const string EvaluatorRequestorHandler = "EvaluatorRequestor";
+ /// <summary>
+ /// The name for AllocatedEvaluatorHandler. Tightly coupled with Java.
+ /// </summary>
public const string AllocatedEvaluatorHandler = "AllocatedEvaluator";
+ /// <summary>
+ /// The name for CompletedEvaluatorHandler. Tightly coupled with Java.
+ /// </summary>
public const string CompletedEvaluatorHandler = "CompletedEvaluator";
+ /// <summary>
+ /// The name for ActiveContextHandler. Tightly coupled with Java.
+ /// </summary>
public const string ActiveContextHandler = "ActiveContext";
+ /// <summary>
+ /// The name for ClosedContextHandler. Tightly coupled with Java.
+ /// </summary>
public const string ClosedContextHandler = "ClosedContext";
+ /// <summary>
+ /// The name for FailedContextHandler. Tightly coupled with Java.
+ /// </summary>
public const string FailedContextHandler = "FailedContext";
-
+
+ /// <summary>
+ /// The name for ContextMessageHandler. Tightly coupled with Java.
+ /// </summary>
public const string ContextMessageHandler = "ContextMessage";
+ /// <summary>
+ /// The name for TaskMessageHandler. Tightly coupled with Java.
+ /// </summary>
public const string TaskMessageHandler = "TaskMessage";
+ /// <summary>
+ /// The name for FailedTaskHandler. Tightly coupled with Java.
+ /// </summary>
public const string FailedTaskHandler = "FailedTask";
+ /// <summary>
+ /// The name for RunningTaskHandler. Tightly coupled with Java.
+ /// </summary>
public const string RunningTaskHandler = "RunningTask";
+ /// <summary>
+ /// The name for FailedEvaluatorHandler. Tightly coupled with Java.
+ /// </summary>
public const string FailedEvaluatorHandler = "FailedEvaluator";
+ /// <summary>
+ /// The name for CompletedTaskHandler. Tightly coupled with Java.
+ /// </summary>
public const string CompletedTaskHandler = "CompletedTask";
+ /// <summary>
+ /// The name for SuspendedTaskHandler. Tightly coupled with Java.
+ /// </summary>
public const string SuspendedTaskHandler = "SuspendedTask";
+ /// <summary>
+ /// The name for HttpServerHandler. Tightly coupled with Java.
+ /// </summary>
public const string HttpServerHandler = "HttpServerHandler";
- public const string DriverRestartHandler = "DriverRestart";
-
+ /// <summary>
+ /// The name for DriverRestartActiveContextHandler. Tightly coupled
with Java.
+ /// </summary>
public const string DriverRestartActiveContextHandler =
"DriverRestartActiveContext";
+ /// <summary>
+ /// The name for DriverRestartRunningTaskHandler. Tightly coupled with
Java.
+ /// </summary>
public const string DriverRestartRunningTaskHandler =
"DriverRestartRunningTask";
+ /// <summary>
+ /// The name for DriverRestartCompletedHandler. Tightly coupled with
Java.
+ /// </summary>
+ public const string DriverRestartCompletedHandler =
"DriverRestartCompleted";
+
[Obsolete(message:"Use REEFFileNames instead.")]
public const string DriverBridgeConfiguration =
Common.Constants.ClrBridgeRuntimeConfiguration;
+ /// <summary>
+ /// The directory to load driver DLLs.
+ /// </summary>
public const string DriverAppDirectory = "ReefDriverAppDlls";
-
+
+ /// <summary>
+ /// The bridge JAR name.
+ /// </summary>
public const string JavaBridgeJarFileName =
"reef-bridge-java-0.13.0-incubating-SNAPSHOT-shaded.jar";
public const string BridgeLaunchClass =
"org.apache.reef.javabridge.generic.Launch";
@@ -80,12 +152,30 @@ namespace Org.Apache.REEF.Driver
[Obsolete(message: "Deprecated in 0.13. Use BridgeLaunchClass
instead.")]
public const string BridgeLaunchHeadlessClass =
"org.apache.reef.javabridge.generic.LaunchHeadless";
+ /// <summary>
+ /// The direct launcher class, deprecated in 0.13, please use
DirectREEFLauncherClass instead.
+ /// </summary>
+ [Obsolete("Deprecated in 0.13, please use DirectREEFLauncherClass
instead.")]
public const string DirectLauncherClass =
"org.apache.reef.runtime.common.Launcher";
+ /// <summary>
+ /// The direct launcher class.
+ /// </summary>
+ public const string DirectREEFLauncherClass =
"org.apache.reef.runtime.common.REEFLauncher";
+
+ /// <summary>
+ /// Configuration for Java CLR logging.
+ /// </summary>
public const string JavaToCLRLoggingConfig =
"-Djava.util.logging.config.class=org.apache.reef.util.logging.CLRLoggingConfig";
+ /// <summary>
+ /// Configuration for Java verbose logging.
+ /// </summary>
public const string JavaVerboseLoggingConfig =
"-Djava.util.logging.config.class=org.apache.reef.util.logging.Config";
+ /// <summary>
+ /// A dictionary of handler constants to handler descriptors.
+ /// </summary>
public static Dictionary<string, int> Handlers
{
get
@@ -107,9 +197,9 @@ namespace Org.Apache.REEF.Driver
{ ClosedContextHandler, 11 },
{ FailedContextHandler, 12 },
{ ContextMessageHandler, 13 },
- { DriverRestartHandler, 14 },
- { DriverRestartActiveContextHandler, 15 },
- { DriverRestartRunningTaskHandler, 16 },
+ { DriverRestartActiveContextHandler, 14 },
+ { DriverRestartRunningTaskHandler, 15 },
+ { DriverRestartCompletedHandler, 16 }
};
}
}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultDriverRestartCompletedHandler.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultDriverRestartCompletedHandler.cs
b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultDriverRestartCompletedHandler.cs
new file mode 100644
index 0000000..daa0470
--- /dev/null
+++
b/lang/cs/Org.Apache.REEF.Driver/Defaults/DefaultDriverRestartCompletedHandler.cs
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System;
+using System.Globalization;
+using Org.Apache.REEF.Driver.Context;
+using Org.Apache.REEF.Tang.Annotations;
+using Org.Apache.REEF.Utilities.Logging;
+
+namespace Org.Apache.REEF.Driver.Defaults
+{
+ /// <summary>
+ /// The default driver restart completed handler. Prints the time when
restart is completed.
+ /// </summary>
+ public sealed class DefaultDriverRestartCompletedHandler :
IObserver<IDriverRestartCompleted>
+ {
+ private static readonly Logger LOGGER =
Logger.GetLogger(typeof(DefaultDriverRestartCompletedHandler));
+
+ [Inject]
+ public DefaultDriverRestartCompletedHandler()
+ {
+ }
+
+ public void OnNext(IDriverRestartCompleted value)
+ {
+ LOGGER.Log(Level.Info, string.Format(CultureInfo.InvariantCulture,
"Driver restart completed at " + value.CompletedTime));
+ }
+
+ public void OnError(Exception error)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void OnCompleted()
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/DriverConfiguration.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/DriverConfiguration.cs
b/lang/cs/Org.Apache.REEF.Driver/DriverConfiguration.cs
index 70c4ce1..e597c10 100644
--- a/lang/cs/Org.Apache.REEF.Driver/DriverConfiguration.cs
+++ b/lang/cs/Org.Apache.REEF.Driver/DriverConfiguration.cs
@@ -27,7 +27,6 @@ using Org.Apache.REEF.Driver.Evaluator;
using Org.Apache.REEF.Driver.Task;
using Org.Apache.REEF.Tang.Formats;
using Org.Apache.REEF.Tang.Util;
-using Org.Apache.REEF.Wake.Time.Event;
namespace Org.Apache.REEF.Driver
{
@@ -45,8 +44,8 @@ namespace Org.Apache.REEF.Driver
/// <summary>
/// The event handler invoked when driver restarts
/// </summary>
- public static readonly OptionalImpl<IObserver<StartTime>>
OnDriverRestarted =
- new OptionalImpl<IObserver<StartTime>>();
+ public static readonly OptionalImpl<IObserver<IDriverRestarted>>
OnDriverRestarted =
+ new OptionalImpl<IObserver<IDriverRestarted>>();
/// <summary>
/// Event handler for allocated evaluators. Defaults to returning the
evaluator if not bound.
@@ -120,7 +119,7 @@ namespace Org.Apache.REEF.Driver
/// <summary>
/// Event handler for active context received during driver restart.
Defaults to closing the context if not bound.
/// </summary>
- public static readonly OptionalImpl<IObserver<IActiveContext>>
OnDirverRestartContextActive =
+ public static readonly OptionalImpl<IObserver<IActiveContext>>
OnDriverRestartContextActive =
new OptionalImpl<IObserver<IActiveContext>>();
/// <summary>
@@ -142,6 +141,12 @@ namespace Org.Apache.REEF.Driver
new OptionalImpl<IObserver<IContextMessage>>();
/// <summary>
+ /// Event handler for driver restart completed. Defaults to logging if
not bound.
+ /// </summary>
+ public static readonly
OptionalImpl<IObserver<IDriverRestartCompleted>> OnDriverRestartCompleted =
+ new OptionalImpl<IObserver<IDriverRestartCompleted>>();
+
+ /// <summary>
/// Additional set of string arguments that can be pssed to handlers
through client
/// </summary>
public static readonly OptionalParameter<string> CommandLineArguments
= new OptionalParameter<string>();
@@ -175,7 +180,7 @@ namespace Org.Apache.REEF.Driver
return new DriverConfiguration()
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverStartedHandlers>.Class,
OnDriverStarted)
-
.BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.DriverRestartHandler>.Class,
+
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartedHandlers>.Class,
OnDriverRestarted)
.BindImplementation(GenericType<IDriverConnection>.Class,
OnDriverReconnect)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.AllocatedEvaluatorHandlers>.Class,
@@ -199,13 +204,15 @@ namespace Org.Apache.REEF.Driver
OnContextFailed)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ContextMessageHandlers>.Class,
OnContextMessage)
+
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartCompletedHandlers>.Class,
+ OnDriverRestartCompleted)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.ArgumentSets>.Class,
CommandLineArguments)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.HttpEventHandlers>.Class,
OnHttpEvent)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.TraceListenersSet>.Class,
CustomTraceListeners)
.BindSetEntry(
GenericType<DriverBridgeConfigurationOptions.DriverRestartActiveContextHandlers>.Class,
- OnDirverRestartContextActive)
+ OnDriverRestartContextActive)
.BindSetEntry(GenericType<DriverBridgeConfigurationOptions.DriverRestartRunningTaskHandlers>.Class,
OnDriverRestartTaskRunning)
.BindNamedParameter(GenericType<DriverBridgeConfigurationOptions.TraceLevel>.Class,
CustomTraceLevel)
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/IDriverRestartCompleted.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/IDriverRestartCompleted.cs
b/lang/cs/Org.Apache.REEF.Driver/IDriverRestartCompleted.cs
new file mode 100644
index 0000000..a8acd3f
--- /dev/null
+++ b/lang/cs/Org.Apache.REEF.Driver/IDriverRestartCompleted.cs
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+using System;
+
+namespace Org.Apache.REEF.Driver
+{
+ /// <summary>
+ /// Event fired on Driver restart completed
+ /// </summary>
+ public interface IDriverRestartCompleted
+ {
+ DateTime CompletedTime { get; }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj
b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj
index 705cc08..f04eb8f 100644
--- a/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj
+++ b/lang/cs/Org.Apache.REEF.Driver/Org.Apache.REEF.Driver.csproj
@@ -62,13 +62,13 @@ under the License.
<Compile Include="Bridge\DriverBridge.cs" />
<Compile Include="Bridge\DriverBridgeConfiguration.cs" />
<Compile Include="Bridge\DriverBridgeConfigurationOptions.cs" />
- <Compile Include="Bridge\DriverRestartHandlerWrapper.cs" />
<Compile Include="Bridge\Events\ActiveContext.cs" />
<Compile Include="Bridge\Events\AllocatedEvaluator.cs" />
<Compile Include="Bridge\Events\ClosedContext.cs" />
<Compile Include="Bridge\Events\CompletedEvaluator.cs" />
<Compile Include="Bridge\Events\CompletedTask.cs" />
<Compile Include="Bridge\Events\ContextMessage.cs" />
+ <Compile Include="Bridge\Events\DriverRestartCompleted.cs" />
<Compile Include="Bridge\Events\DriverRestarted.cs" />
<Compile Include="Bridge\Events\DriverStarted.cs" />
<Compile Include="Bridge\Events\EvaluatorRequstor.cs" />
@@ -107,6 +107,7 @@ under the License.
<Compile Include="Defaults\DefaultContextFailureHandler.cs" />
<Compile Include="Defaults\DefaultContextMessageHandler.cs" />
<Compile Include="Defaults\DefaultCustomTraceListener.cs" />
+ <Compile Include="Defaults\DefaultDriverRestartCompletedHandler.cs" />
<Compile Include="Defaults\DefaultDriverRestartContextActiveHandler.cs" />
<Compile Include="Defaults\DefaultDriverRestartedHandler.cs" />
<Compile Include="Defaults\DefaultDriverRestartHandler.cs" />
@@ -140,6 +141,7 @@ under the License.
<Compile Include="IDriver.cs" />
<Compile Include="IDriverRestarted.cs" />
<Compile Include="IDriverStarted.cs" />
+ <Compile Include="IDriverRestartCompleted.cs" />
<Compile Include="IStartHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Task\ICompletedTask.cs" />
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Examples.AllHandlers/AllHandlers.cs
----------------------------------------------------------------------
diff --git a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/AllHandlers.cs
b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/AllHandlers.cs
index dd99e98..27a553b 100644
--- a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/AllHandlers.cs
+++ b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/AllHandlers.cs
@@ -67,7 +67,7 @@ namespace Org.Apache.REEF.Examples.AllHandlers
.Set(DriverConfiguration.CustomTraceLevel,
Level.Info.ToString())
.Set(DriverConfiguration.OnDriverRestarted,
GenericType<HelloRestartHandler>.Class)
.Set(DriverConfiguration.OnDriverReconnect,
GenericType<DefaultLocalHttpDriverConnection>.Class)
- .Set(DriverConfiguration.OnDirverRestartContextActive,
GenericType<HelloDriverRestartActiveContextHandler>.Class)
+ .Set(DriverConfiguration.OnDriverRestartContextActive,
GenericType<HelloDriverRestartActiveContextHandler>.Class)
.Set(DriverConfiguration.OnDriverRestartTaskRunning,
GenericType<HelloDriverRestartRunningTaskHandler>.Class)
.Build();
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloRestartHandler.cs
----------------------------------------------------------------------
diff --git
a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloRestartHandler.cs
b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloRestartHandler.cs
index 547aa08..d8b2756 100644
--- a/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloRestartHandler.cs
+++ b/lang/cs/Org.Apache.REEF.Examples.AllHandlers/HelloRestartHandler.cs
@@ -18,6 +18,7 @@
*/
using System;
+using Org.Apache.REEF.Driver;
using Org.Apache.REEF.Tang.Annotations;
using Org.Apache.REEF.Wake.Time.Event;
@@ -26,7 +27,7 @@ namespace Org.Apache.REEF.Examples.AllHandlers
/// <summary>
/// A sample implementation of driver restart handler
/// </summary>
- public class HelloRestartHandler : IObserver<StartTime>
+ public class HelloRestartHandler : IObserver<IDriverRestarted>
{
[Inject]
private HelloRestartHandler()
@@ -37,9 +38,9 @@ namespace Org.Apache.REEF.Examples.AllHandlers
/// It is called when the driver is restarted
/// </summary>
/// <param name="value"></param>
- public void OnNext(StartTime value)
+ public void OnNext(IDriverRestarted value)
{
- Console.WriteLine("Hello from CLR: we are informed that Driver has
restarted at " + new DateTime(value.TimeStamp));
+ Console.WriteLine("Hello from CLR: we are informed that Driver has
restarted at " + new DateTime(value.StartTime.Ticks));
}
public void OnError(Exception error)
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/NativeInterop.java
----------------------------------------------------------------------
diff --git
a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/NativeInterop.java
b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/NativeInterop.java
index 56306d7..c564157 100644
---
a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/NativeInterop.java
+++
b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/NativeInterop.java
@@ -36,9 +36,9 @@ public final class NativeInterop {
public static final String CLOSED_CONTEXT_KEY = "ClosedContext";
public static final String FAILED_CONTEXT_KEY = "FailedContext";
public static final String CONTEXT_MESSAGE_KEY = "ContextMessage";
- public static final String DRIVER_RESTART_KEY = "DriverRestart";
public static final String DRIVER_RESTART_ACTIVE_CONTEXT_KEY =
"DriverRestartActiveContext";
public static final String DRIVER_RESTART_RUNNING_TASK_KEY =
"DriverRestartRunningTask";
+ public static final String DRIVER_RESTART_COMPLETED_KEY =
"DriverRestartCompleted";
public static final HashMap<String, Integer> HANDLERS = new HashMap<String,
Integer>() {
{
put(ALLOCATED_EVALUATOR_KEY, 1);
@@ -54,9 +54,9 @@ public final class NativeInterop {
put(CLOSED_CONTEXT_KEY, 11);
put(FAILED_CONTEXT_KEY, 12);
put(CONTEXT_MESSAGE_KEY, 13);
- put(DRIVER_RESTART_KEY, 14);
- put(DRIVER_RESTART_ACTIVE_CONTEXT_KEY, 15);
- put(DRIVER_RESTART_RUNNING_TASK_KEY, 16);
+ put(DRIVER_RESTART_ACTIVE_CONTEXT_KEY, 14);
+ put(DRIVER_RESTART_RUNNING_TASK_KEY, 15);
+ put(DRIVER_RESTART_COMPLETED_KEY, 16);
}
};
@@ -145,8 +145,10 @@ public final class NativeInterop {
final ContextMessageBridge contextMessageBridge
);
- public static native void clrSystemDriverRestartHandlerOnNext(
- final long handle
+ public static native long[] callClrSystemOnRestartHandlerOnNext(
+ final String dateTime,
+ final String httpServerPortNumber,
+ final EvaluatorRequestorBridge javaEvaluatorRequestorBridge
);
public static native void clrSystemDriverRestartActiveContextHandlerOnNext(
@@ -159,6 +161,10 @@ public final class NativeInterop {
final RunningTaskBridge runningTaskBridge
);
+ public static native void clrSystemDriverRestartCompletedHandlerOnNext(
+ final long handle
+ );
+
/**
* Empty private constructor to prohibit instantiation of utility class.
*/
http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/e1a38602/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobDriver.java
----------------------------------------------------------------------
diff --git
a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobDriver.java
b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobDriver.java
index 747ef77..ea93ebc 100644
---
a/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobDriver.java
+++
b/lang/java/reef-bridge-java/src/main/java/org/apache/reef/javabridge/generic/JobDriver.java
@@ -135,6 +135,7 @@ public final class JobDriver {
private long driverRestartHandler = 0;
private long driverRestartActiveContextHandler = 0;
private long driverRestartRunningTaskHandler = 0;
+ private long driverRestartCompletedHandler = 0;
private boolean clrBridgeSetup = false;
private boolean isRestarted = false;
@@ -198,8 +199,9 @@ public final class JobDriver {
final String portNumber = httpServer == null ? null :
Integer.toString((httpServer.getPort()));
final EvaluatorRequestorBridge evaluatorRequestorBridge =
new EvaluatorRequestorBridge(JobDriver.this.evaluatorRequestor,
false, loggingScopeFactory);
- final long[] handlers =
- NativeInterop.callClrSystemOnStartHandler(startTime.toString(),
portNumber, evaluatorRequestorBridge);
+ final long[] handlers = JobDriver.this.isRestarted ?
+
NativeInterop.callClrSystemOnRestartHandlerOnNext(startTime.toString(),
portNumber, evaluatorRequestorBridge)
+ : NativeInterop.callClrSystemOnStartHandler(startTime.toString(),
portNumber, evaluatorRequestorBridge);
if (handlers != null) {
if (handlers.length != NativeInterop.N_HANDLERS) {
throw new RuntimeException(
@@ -220,11 +222,12 @@ public final class JobDriver {
this.closedContextHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.CLOSED_CONTEXT_KEY)];
this.failedContextHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.FAILED_CONTEXT_KEY)];
this.contextMessageHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.CONTEXT_MESSAGE_KEY)];
- this.driverRestartHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.DRIVER_RESTART_KEY)];
this.driverRestartActiveContextHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.DRIVER_RESTART_ACTIVE_CONTEXT_KEY)];
this.driverRestartRunningTaskHandler =
handlers[NativeInterop.HANDLERS.get(NativeInterop.DRIVER_RESTART_RUNNING_TASK_KEY)];
+ this.driverRestartCompletedHandler =
+
handlers[NativeInterop.HANDLERS.get(NativeInterop.DRIVER_RESTART_COMPLETED_KEY)];
}
try (final LoggingScope lp =
@@ -593,9 +596,8 @@ public final class JobDriver {
try (final LoggingScope ls =
loggingScopeFactory.driverRestart(startTime)) {
synchronized (JobDriver.this) {
- setupBridge(startTime);
-
JobDriver.this.isRestarted = true;
+ setupBridge(startTime);
LOG.log(Level.INFO, "Driver Restarted and CLR bridge set up.");
}
@@ -614,7 +616,7 @@ public final class JobDriver {
try (final LoggingScope ls =
loggingScopeFactory.driverRestartCompleted(driverRestartCompleted.getTimeStamp()))
{
if (JobDriver.this.driverRestartHandler != 0) {
LOG.log(Level.INFO, "CLR driver restart handler implemented, now
handle it in CLR.");
-
NativeInterop.clrSystemDriverRestartHandlerOnNext(JobDriver.this.driverRestartHandler);
+
NativeInterop.clrSystemDriverRestartCompletedHandlerOnNext(JobDriver.this.driverRestartCompletedHandler);
} else {
LOG.log(Level.WARNING, "No CLR driver restart handler implemented,
done with DriverRestartCompletedHandler.");