You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 05:19:39 UTC
svn commit: r1131537 - in /incubator/mesos/trunk/src: master.cpp
messages.hpp slave.cpp
Author: benh
Date: Sun Jun 5 03:19:39 2011
New Revision: 1131537
URL: http://svn.apache.org/viewvc?rev=1131537&view=rev
Log:
Special message to restore state. Now updates resourcesInUse state which was previously lost
Modified:
incubator/mesos/trunk/src/master.cpp
incubator/mesos/trunk/src/messages.hpp
incubator/mesos/trunk/src/slave.cpp
Modified: incubator/mesos/trunk/src/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master.cpp?rev=1131537&r1=1131536&r2=1131537&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master.cpp (original)
+++ incubator/mesos/trunk/src/master.cpp Sun Jun 5 03:19:39 2011
@@ -366,6 +366,21 @@ void Master::operator () ()
break;
}
+ case S2M_REREGISTER_SLAVE: {
+ string slaveId = lexical_cast<string>(masterId) + "-" + lexical_cast<string>(nextSlaveId++);
+
+ Slave *slave = new Slave(from(), slaveId);
+ unpack<S2M_REREGISTER_SLAVE>(slave->hostname, slave->publicDns,
+ slave->resources, slave->resourcesInUse);
+ LOG(INFO) << "Registering " << slave << " at " << slave->pid;
+ slaves[slave->id] = slave;
+ pidToSid[slave->pid] = slave->id;
+ link(slave->pid);
+ send(slave->pid, pack<M2S_REGISTER_REPLY>(slave->id));
+ allocator->slaveAdded(slave);
+ break;
+ }
+
case S2M_UNREGISTER_SLAVE: {
SlaveID sid;
unpack<S2M_UNREGISTER_SLAVE>(sid);
@@ -459,6 +474,11 @@ void Master::operator () ()
foreachpair (_, Framework *framework, frameworks)
framework->removeExpiredFilters();
allocator->timerTick();
+
+ int cnt=0;
+ foreachpair(_, Slave *slave, slaves) {
+ LOG(INFO)<<(cnt++)<<" "<<slave->resourcesInUse;
+ }
break;
}
Modified: incubator/mesos/trunk/src/messages.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/messages.hpp?rev=1131537&r1=1131536&r2=1131537&view=diff
==============================================================================
--- incubator/mesos/trunk/src/messages.hpp (original)
+++ incubator/mesos/trunk/src/messages.hpp Sun Jun 5 03:19:39 2011
@@ -36,6 +36,7 @@ enum MessageType {
/* From slave to master. */
S2M_REGISTER_SLAVE,
+ S2M_REREGISTER_SLAVE,
S2M_UNREGISTER_SLAVE,
S2M_STATUS_UPDATE,
S2M_FRAMEWORK_MESSAGE,
@@ -157,6 +158,12 @@ TUPLE(S2M_REGISTER_SLAVE,
std::string /*publicDns*/,
Resources));
+TUPLE(S2M_REREGISTER_SLAVE,
+ (std::string /*name*/,
+ std::string /*publicDns*/,
+ Resources,
+ Resources /*ResourcesInUse*/ ));
+
TUPLE(S2M_UNREGISTER_SLAVE,
(SlaveID));
Modified: incubator/mesos/trunk/src/slave.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave.cpp?rev=1131537&r1=1131536&r2=1131537&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave.cpp (original)
+++ incubator/mesos/trunk/src/slave.cpp Sun Jun 5 03:19:39 2011
@@ -336,7 +336,19 @@ void Slave::operator () ()
LOG(INFO) << "Connecting to Nexus master at " << master;
link(master);
- send(master, pack<S2M_REGISTER_SLAVE>(hostname, publicDns, resources));
+
+ // reconstruct resourcesInUse for the master
+ // alig: do I need to include queuedTasks in this number? Don't think so.
+ Resources resourcesInUse;
+
+ foreachpair(_, Framework *framework, frameworks) {
+ foreachpair(_, Task *task, framework->tasks) {
+ resourcesInUse += task->resources;
+ }
+ }
+ //alibandali
+
+ send(master, pack<S2M_REREGISTER_SLAVE>(hostname, publicDns, resources, resourcesInUse));
break;
}