You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by al...@apache.org on 2017/09/01 09:34:39 UTC
[1/4] mesos git commit: Ensured JAVA HTTP adapter propagates a
subscription error.
Repository: mesos
Updated Branches:
refs/heads/1.4.x 3293e4a61 -> 2f72e6130
Ensured JAVA HTTP adapter propagates a subscription error.
Prior to this patch, if an error occurred during subscription /
registration to the master, it was not propagated back to the
scheduler if the HTTP adapter was used. This happened because
the HTTP adapter does not call `scheduler.connected` until after
successful registration and hence the scheduler does not try to
send the `SUBSCRIBE` call, without which the adapter does not
send any events to the scheduler.
A fix is to call `scheduler.connected` if an error occurred
before the scheduler had subscribed.
Review: https://reviews.apache.org/r/61579
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f26fb42f
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f26fb42f
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f26fb42f
Branch: refs/heads/1.4.x
Commit: f26fb42f0501ac3a0402b3cb7b50891b8d6e706e
Parents: 3293e4a
Author: Alexander Rukletsov <al...@apache.org>
Authored: Thu Aug 10 22:34:38 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Sep 1 11:17:43 2017 +0200
----------------------------------------------------------------------
.../org_apache_mesos_v1_scheduler_V0Mesos.cpp | 84 ++++++++++++--------
1 file changed, 53 insertions(+), 31 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f26fb42f/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
----------------------------------------------------------------------
diff --git a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
index 1f58fbf..e487f1e 100644
--- a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
+++ b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
@@ -189,6 +189,8 @@ protected:
void __received(const Event& event);
+ void connect();
+
void heartbeat();
void disconnect();
@@ -355,35 +357,7 @@ void V0ToV1AdapterProcess::registered(
const FrameworkID& _frameworkId,
const MasterInfo& masterInfo)
{
- jvm->AttachCurrentThread(JNIENV_CAST(&env), NULL);
-
- jclass clazz = env->GetObjectClass(jmesos);
-
- jfieldID scheduler =
- env->GetFieldID(clazz, "scheduler",
- "Lorg/apache/mesos/v1/scheduler/Scheduler;");
-
- jobject jscheduler = env->GetObjectField(jmesos, scheduler);
-
- clazz = env->GetObjectClass(jscheduler);
-
- // scheduler.connected(mesos);
- jmethodID connected =
- env->GetMethodID(clazz, "connected",
- "(Lorg/apache/mesos/v1/scheduler/Mesos;)V");
-
- env->ExceptionClear();
-
- env->CallVoidMethod(jscheduler, connected, jmesos);
-
- if (env->ExceptionCheck()) {
- env->ExceptionDescribe();
- env->ExceptionClear();
- jvm->DetachCurrentThread();
- ABORT("Exception thrown during `connected` call");
- }
-
- jvm->DetachCurrentThread();
+ connect();
// We need this copy to populate the fields in `Event::Subscribed` upon
// receiving a `reregistered()` callback later.
@@ -554,6 +528,18 @@ void V0ToV1AdapterProcess::error(const string& message)
event.mutable_error()->set_message(message);
+ // There might be an error during the communication with the master or
+ // implicit registration happening on driver initialization. Since
+ // `Scheduler.connect` is called upon a successful registration only, the
+ // scheduler will never try to subscribe and hence will never receive the
+ // error. This workaround satisfies the invariant of the v1 interface that
+ // a scheduler can receive an event only after successfully connecting with
+ // the master.
+ if (!subscribeCall) {
+ LOG(INFO) << "Implicitly connecting the scheduler to send an error";
+ connect();
+ }
+
received(event);
}
@@ -579,7 +565,8 @@ void V0ToV1AdapterProcess::send(SchedulerDriver* driver, const Call& _call)
// The driver subscribes implicitly with the master upon initialization.
// For compatibility with the v1 interface, send the already enqueued
- // subscribed event upon receiving the subscribe request.
+ // subscribed event (or subscription error) upon receiving the subscribe
+ // request.
_received();
break;
}
@@ -699,7 +686,8 @@ void V0ToV1AdapterProcess::send(SchedulerDriver* driver, const Call& _call)
void V0ToV1AdapterProcess::received(const Event& event)
{
// For compatibility with the v1 interface, we only start sending events
- // once the scheduler has sent the subscribe call.
+ // once the scheduler has sent the subscribe call. An exception to this
+ // is an error event, which can be sent before the subscribe call.
if (!subscribeCall) {
pending.push(event);
return;
@@ -759,6 +747,40 @@ void V0ToV1AdapterProcess::__received(const Event& event)
}
+void V0ToV1AdapterProcess::connect()
+{
+ jvm->AttachCurrentThread(JNIENV_CAST(&env), NULL);
+
+ jclass clazz = env->GetObjectClass(jmesos);
+
+ jfieldID scheduler =
+ env->GetFieldID(clazz, "scheduler",
+ "Lorg/apache/mesos/v1/scheduler/Scheduler;");
+
+ jobject jscheduler = env->GetObjectField(jmesos, scheduler);
+
+ clazz = env->GetObjectClass(jscheduler);
+
+ // scheduler.connected(mesos);
+ jmethodID connected =
+ env->GetMethodID(clazz, "connected",
+ "(Lorg/apache/mesos/v1/scheduler/Mesos;)V");
+
+ env->ExceptionClear();
+
+ env->CallVoidMethod(jscheduler, connected, jmesos);
+
+ if (env->ExceptionCheck()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ jvm->DetachCurrentThread();
+ ABORT("Exception thrown during `connected` call");
+ }
+
+ jvm->DetachCurrentThread();
+}
+
+
void V0ToV1AdapterProcess::heartbeat()
{
// It is possible that we were unable to cancel this timer upon a
[3/4] mesos git commit: Added several logs to the C++ part of the
v1-v0 adapter.
Posted by al...@apache.org.
Added several logs to the C++ part of the v1-v0 adapter.
Review: https://reviews.apache.org/r/61991
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/4af16883
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/4af16883
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/4af16883
Branch: refs/heads/1.4.x
Commit: 4af16883a799d559439276070b96b098439f7cdd
Parents: bd9138c
Author: Alexander Rukletsov <al...@apache.org>
Authored: Wed Aug 30 16:04:14 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Sep 1 11:17:56 2017 +0200
----------------------------------------------------------------------
src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/4af16883/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
----------------------------------------------------------------------
diff --git a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
index 014aabd..0e7716d 100644
--- a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
+++ b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
@@ -357,6 +357,8 @@ void V0ToV1AdapterProcess::registered(
const FrameworkID& _frameworkId,
const MasterInfo& masterInfo)
{
+ LOG(INFO) << "Registered with the Mesos master; invoking connected callback";
+
connect();
// We need this copy to populate the fields in `Event::Subscribed` upon
@@ -403,6 +405,9 @@ void V0ToV1AdapterProcess::disconnected()
// - Any outstanding offers are invalidated by the master upon a scheduler
// (re-)registration.
// - Any task status updates could be reconciled by the scheduler.
+ LOG(INFO) << "Dropping " << pending.size() << " pending event(s)"
+ << " because master disconnected";
+
pending = queue<Event>();
subscribeCall = false;
@@ -411,6 +416,9 @@ void V0ToV1AdapterProcess::disconnected()
heartbeatTimer = None();
}
+ LOG(INFO) << "Disconnected with the Mesos master;"
+ << " invoking disconnected callback";
+
disconnect();
}
[2/4] mesos git commit: Extracted JNI code into a protected function
for clarity.
Posted by al...@apache.org.
Extracted JNI code into a protected function for clarity.
Review: https://reviews.apache.org/r/61580
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/bd9138c1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/bd9138c1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/bd9138c1
Branch: refs/heads/1.4.x
Commit: bd9138c1c71e661ccb8910790f9d5ece9a0634d2
Parents: f26fb42
Author: Alexander Rukletsov <al...@apache.org>
Authored: Thu Aug 10 22:38:35 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Sep 1 11:17:50 2017 +0200
----------------------------------------------------------------------
.../org_apache_mesos_v1_scheduler_V0Mesos.cpp | 80 ++++++++++----------
1 file changed, 40 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/bd9138c1/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
----------------------------------------------------------------------
diff --git a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
index e487f1e..014aabd 100644
--- a/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
+++ b/src/java/jni/org_apache_mesos_v1_scheduler_V0Mesos.cpp
@@ -396,37 +396,22 @@ void V0ToV1AdapterProcess::reregistered(const MasterInfo& masterInfo)
void V0ToV1AdapterProcess::disconnected()
{
- disconnect();
-
- jvm->AttachCurrentThread(JNIENV_CAST(&env), NULL);
-
- jclass clazz = env->GetObjectClass(jmesos);
-
- jfieldID scheduler =
- env->GetFieldID(clazz, "scheduler",
- "Lorg/apache/mesos/v1/scheduler/Scheduler;");
-
- jobject jscheduler = env->GetObjectField(jmesos, scheduler);
-
- clazz = env->GetObjectClass(jscheduler);
-
- // scheduler.disconnected(mesos);
- jmethodID disconnected =
- env->GetMethodID(clazz, "disconnected",
- "(Lorg/apache/mesos/v1/scheduler/Mesos;)V");
-
- env->ExceptionClear();
-
- env->CallVoidMethod(jscheduler, disconnected, jmesos);
+ // Upon noticing a disconnection with the master, we drain the pending
+ // events in the queue that were waiting to be sent to the scheduler
+ // upon receiving the subscribe call.
+ // It's fine to do so because:
+ // - Any outstanding offers are invalidated by the master upon a scheduler
+ // (re-)registration.
+ // - Any task status updates could be reconciled by the scheduler.
+ pending = queue<Event>();
+ subscribeCall = false;
- if (env->ExceptionCheck()) {
- env->ExceptionDescribe();
- env->ExceptionClear();
- jvm->DetachCurrentThread();
- ABORT("Exception thrown during `disconnected` call");
+ if (heartbeatTimer.isSome()) {
+ Clock::cancel(heartbeatTimer.get());
+ heartbeatTimer = None();
}
- jvm->DetachCurrentThread();
+ disconnect();
}
@@ -805,20 +790,35 @@ void V0ToV1AdapterProcess::heartbeat()
void V0ToV1AdapterProcess::disconnect()
{
- // Upon noticing a disconnection with the master, we drain the pending
- // events in the queue that were waiting to be sent to the scheduler
- // upon receiving the subscribe call.
- // It's fine to do so because:
- // - Any outstanding offers are invalidated by the master upon a scheduler
- // (re-)registration.
- // - Any task status updates could be reconciled by the scheduler.
- pending = queue<Event>();
- subscribeCall = false;
+ jvm->AttachCurrentThread(JNIENV_CAST(&env), NULL);
- if (heartbeatTimer.isSome()) {
- Clock::cancel(heartbeatTimer.get());
- heartbeatTimer = None();
+ jclass clazz = env->GetObjectClass(jmesos);
+
+ jfieldID scheduler =
+ env->GetFieldID(clazz, "scheduler",
+ "Lorg/apache/mesos/v1/scheduler/Scheduler;");
+
+ jobject jscheduler = env->GetObjectField(jmesos, scheduler);
+
+ clazz = env->GetObjectClass(jscheduler);
+
+ // scheduler.disconnected(mesos);
+ jmethodID disconnected =
+ env->GetMethodID(clazz, "disconnected",
+ "(Lorg/apache/mesos/v1/scheduler/Mesos;)V");
+
+ env->ExceptionClear();
+
+ env->CallVoidMethod(jscheduler, disconnected, jmesos);
+
+ if (env->ExceptionCheck()) {
+ env->ExceptionDescribe();
+ env->ExceptionClear();
+ jvm->DetachCurrentThread();
+ ABORT("Exception thrown during `disconnected` call");
}
+
+ jvm->DetachCurrentThread();
}
[4/4] mesos git commit: Added MESOS-7872 to 1.4.1 CHANGELOG.
Posted by al...@apache.org.
Added MESOS-7872 to 1.4.1 CHANGELOG.
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/2f72e613
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/2f72e613
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/2f72e613
Branch: refs/heads/1.4.x
Commit: 2f72e6130294f36f0b7138cf665cf0a97aadf76c
Parents: 4af1688
Author: Alexander Rukletsov <al...@apache.org>
Authored: Fri Sep 1 11:19:41 2017 +0200
Committer: Alexander Rukletsov <al...@apache.org>
Committed: Fri Sep 1 11:19:41 2017 +0200
----------------------------------------------------------------------
CHANGELOG | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/2f72e613/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index 6203f05..051ce78 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ Release Notes - Mesos - Version 1.4.1 (WIP)
All Issues:
** Bug
+ * [MESOS-7872] - Scheduler hang when registration fails.
* [MESOS-7912] - Master WebUI not working in Chrome.