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 11:02:04 UTC
svn commit: r1132212 - in /incubator/mesos/trunk/src: local/local.cpp
sched/sched.cpp
Author: benh
Date: Sun Jun 5 09:02:04 2011
New Revision: 1132212
URL: http://svn.apache.org/viewvc?rev=1132212&view=rev
Log:
Fixed a few bugs that appeared when stop() was called multiple times on
the same local MesosSchedulerDriver.
Modified:
incubator/mesos/trunk/src/local/local.cpp
incubator/mesos/trunk/src/sched/sched.cpp
Modified: incubator/mesos/trunk/src/local/local.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/local/local.cpp?rev=1132212&r1=1132211&r2=1132212&view=diff
==============================================================================
--- incubator/mesos/trunk/src/local/local.cpp (original)
+++ incubator/mesos/trunk/src/local/local.cpp Sun Jun 5 09:02:04 2011
@@ -10,8 +10,6 @@
#include "configurator/configurator.hpp"
-#include "event_history/event_logger.hpp"
-
#include "master/master.hpp"
#include "slave/process_based_isolation_module.hpp"
@@ -19,7 +17,6 @@
using namespace mesos::internal;
-using mesos::internal::eventhistory::EventLogger;
using mesos::internal::master::Master;
using mesos::internal::slave::Slave;
using mesos::internal::slave::IsolationModule;
@@ -43,7 +40,6 @@ void initialize_glog() {
namespace mesos { namespace internal { namespace local {
-static EventLogger* evLogger = NULL;
static Master *master = NULL;
static map<IsolationModule*, Slave*> slaves;
static MasterDetector *detector = NULL;
@@ -52,7 +48,6 @@ static MasterDetector *detector = NULL;
void registerOptions(Configurator* conf)
{
conf->addOption<int>("slaves", 's', "Number of slaves", 1);
- EventLogger::registerOptions(conf);
Logging::registerOptions(conf);
Master::registerOptions(conf);
Slave::registerOptions(conf);
@@ -88,9 +83,7 @@ PID launch(const Configuration& conf, bo
google::SetStderrLogging(google::INFO);
}
- evLogger = new EventLogger(conf);
-
- master = new Master(conf, evLogger);
+ master = new Master(conf);
PID pid = Process::spawn(master);
@@ -113,29 +106,30 @@ PID launch(const Configuration& conf, bo
void shutdown()
{
- MesosProcess::post(master->self(), M2M_SHUTDOWN);
- Process::wait(master->self());
- delete master;
- delete evLogger;
- master = NULL;
-
- // TODO(benh): Ugh! Because the isolation module calls back into the
- // slave (not the best design) we can't delete the slave until we
- // have deleted the isolation module. But since the slave calls into
- // the isolation module, we can't delete the isolation module until
- // we have stopped the slave.
-
- foreachpair (IsolationModule *isolationModule, Slave *slave, slaves) {
- MesosProcess::post(slave->self(), S2S_SHUTDOWN);
- Process::wait(slave->self());
- delete isolationModule;
- delete slave;
- }
+ if (master != NULL) {
+ MesosProcess::post(master->self(), M2M_SHUTDOWN);
+ Process::wait(master->self());
+ delete master;
+ master = NULL;
+
+ // TODO(benh): Ugh! Because the isolation module calls back into the
+ // slave (not the best design) we can't delete the slave until we
+ // have deleted the isolation module. But since the slave calls into
+ // the isolation module, we can't delete the isolation module until
+ // we have stopped the slave.
+
+ foreachpair (IsolationModule *isolationModule, Slave *slave, slaves) {
+ MesosProcess::post(slave->self(), S2S_SHUTDOWN);
+ Process::wait(slave->self());
+ delete isolationModule;
+ delete slave;
+ }
- slaves.clear();
+ slaves.clear();
- delete detector;
- detector = NULL;
+ delete detector;
+ detector = NULL;
+ }
}
}}} /* namespace mesos { namespace internal { namespace local { */
Modified: incubator/mesos/trunk/src/sched/sched.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/sched/sched.cpp?rev=1132212&r1=1132211&r2=1132212&view=diff
==============================================================================
--- incubator/mesos/trunk/src/sched/sched.cpp (original)
+++ incubator/mesos/trunk/src/sched/sched.cpp Sun Jun 5 09:02:04 2011
@@ -592,10 +592,16 @@ int MesosSchedulerDriver::stop()
if (process != NULL) {
Process::dispatch(process, &SchedulerProcess::stop);
process->terminate = true;
+ process = NULL;
}
running = false;
+ // TODO: It might make more sense to clean up our local cluster here than in
+ // the destructor. However, what would be even better is to allow multiple
+ // local clusters to exist (i.e. not use global vars in local.cpp) so that
+ // ours can just be an instance variable in MesosSchedulerDriver.
+
pthread_cond_signal(&cond);
return 0;