Events from Master The following events from the leading Mesos master are exposed:
-
subscribed: The first event sent by the master when the scheduler sends a SUBSCRIBE request on the persistent connection (i.e. the framework was started). Emits an object containing the frameworkId and the mesosStreamId.
+
subscribed: The first event sent by the master when the scheduler sends a SUBSCRIBE request on the persistent connection (i.e. the framework was started). Emits an object containing the frameworkId and the mesosStreamId, this may be emitted multiple times in the lifetime of a framework, as reconnections emit it as well.
offers: Sent by the master whenever there are new resources that can be offered to the framework. Emits the base object from the Master for this event.
rescind: Sent by the master when a particular offer is no longer valid. Emits the base object from the Master for this event.
update: Sent by the master whenever there is a status update that is generated by the executor, agent or master. Emits the base object from the Master for this event.
@@ -248,7 +248,25 @@
Mesos
The module also exposes the Mesos protocol buffer object, which
"value": "my-task-id"
};
-var TaskID = new (Builder.build("mesos.TaskID"))(taskId);
+var TaskID = new (Builder.build("mesos.TaskID"))(taskId);
taskHealthHelper
This module allows for testing of task health (or any metric available via HTTP, for example cluster state, leader, etc...) and emit a scheduler event so the issue will be handled in code.
+
The option properties you can specify to create a taskHealthHelper are the following:
+
+
interval: The time interval between checks, in seconds, can be partial seconds (but not recommended), defaults to 30 seconds.
+
graceCount: The amount of failed checks until a task is marked as unhealthy, defaults to 4.
+
portIndex: The port index to check, defaults to 0.
+
propertyPrefix: A optional prefix for the health property, mainly to be used when having multiple health checks per framework (normal health and leader status, for instance), defaults to an empty string.
+
errorEvent: The name of the event to emit when a task fails the health check (after the grace count), defaults to propertyPrefix + "task_unhealthy".
+
additionalProperties: An array of additional properties to be set, these properties do not have the prefix added to them, information below.
+
taskNameFilter: An optional regular expression to filter tasks to be checked by the health check.
+
statusCodes: An array of acceptable HTTP status codes, defaults to [200].
+
checkBodyFunction: An optional function to check the body of the HTTP response (only after it passed the status check), parameters are the task object and the response body, needs to retrun a boolean.
+
+
The additional properties array is an array of objects with the following members:
+
+
name: The name of the property to set, for example: "leader" (mandatory).
+
setUnhealthy: Should the property be set when the check fails (optional, when unset it only sets the property when healthy).
+
inverse: Whether the health status and the property are inversed or not (optional).
+
@@ -261,7 +279,7 @@
Mesos
The module also exposes the Mesos protocol buffer object, which
diff --git a/docs/mesos.js.html b/docs/mesos.js.html
index f5f825f..5835e02 100644
--- a/docs/mesos.js.html
+++ b/docs/mesos.js.html
@@ -99,7 +99,7 @@
// Register a timeout for triggering of re-registrations of the scheduler
self.httpRequest.on('socket', function (socket) {
+ var httpRequest = self.httpRequest;
socket.setTimeout(self.options.masterConnectionTimeout);
socket.on('timeout', function() {
self.logger.error("Received a timeout on the long-running Master connection! Will try to re-register the framework scheduler!");
handledTimeout = true;
socket.destroy();
+ // Make sure the timeout is not re-emitted.
+ socket.setTimeout(0);
+ if (httpRequest !== self.httpRequest) {
+ self.logger.info("Already reconnected, not attempting again.");
+ return;
+ }
// If we're using Mesos DNS, we can directy re-register, because Mesos DNS will discover the current leader automatically
if (self.options.masterUrl === "leader.mesos") {
@@ -594,7 +601,7 @@
scheduler.js
* @param {array} filters - The array of {@link https://github.com/apache/mesos/blob/c6e9ce16850f69fda719d4e32be3f2a2e1d80387/include/mesos/v1/mesos.proto#L1418|Filter} objects.
*/
Scheduler.prototype.accept = function (offers, operations, filters) {
-
+
var self = this;
// Set the Accept object
@@ -946,6 +953,11 @@
scheduler.js
}
}
self.reconcileTasks = [];
+ self.launchedTasks.forEach(function (task) {
+ if (task.runtimeInfo.agentId) {
+ self.reconcile(task.taskId, task.runtimeInfo.agentId);
+ }
+ });
for (var i = 0; i < self.killTasks.length; i++) {
self.kill(self.killTasks[i].taskId, self.killTasks[i].runtimeInfo.agentId);
}
@@ -968,7 +980,7 @@