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 07:42:06 UTC
svn commit: r1131863 - in /incubator/mesos/trunk/src: master.cpp master.hpp
tests/test_master.cpp
Author: benh
Date: Sun Jun 5 05:42:05 2011
New Revision: 1131863
URL: http://svn.apache.org/viewvc?rev=1131863&view=rev
Log:
Made framework ID contain start date. Fixes #40.
Modified:
incubator/mesos/trunk/src/master.cpp
incubator/mesos/trunk/src/master.hpp
incubator/mesos/trunk/src/tests/test_master.cpp
Modified: incubator/mesos/trunk/src/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master.cpp?rev=1131863&r1=1131862&r2=1131863&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master.cpp (original)
+++ incubator/mesos/trunk/src/master.cpp Sun Jun 5 05:42:05 2011
@@ -290,8 +290,7 @@ void Master::operator () ()
}
case F2M_REGISTER_FRAMEWORK: {
- FrameworkID fid = lexical_cast<string>(masterId) + "-"
- + lexical_cast<string>(nextFrameworkId++);
+ FrameworkID fid = newFrameworkId();
Framework *framework = new Framework(from(), fid, elapsed());
unpack<F2M_REGISTER_FRAMEWORK>(framework->name, framework->user,
framework->executorInfo);
@@ -660,7 +659,8 @@ void Master::operator () ()
OfferID Master::makeOffer(Framework *framework,
const vector<SlaveResources>& resources)
{
- OfferID oid = lexical_cast<string>(masterId) + "-" + lexical_cast<string>(nextSlotOfferId++);
+ OfferID oid = lexical_cast<string>(masterId) + "-"
+ + lexical_cast<string>(nextSlotOfferId++);
SlotOffer *offer = new SlotOffer(oid, framework->id, resources);
slotOffers[offer->id] = offer;
@@ -997,3 +997,22 @@ Allocator* Master::createAllocator()
LOG(INFO) << "Creating \"" << allocatorType << "\" allocator";
return AllocatorFactory::instantiate(allocatorType, this);
}
+
+
+// Create a new framework ID. We format the ID as YYYYMMDDhhmm-master-fw,
+// where the first part is the submission date and submission time, master
+// is the unique ID of the master (provided by ZooKeeper), and fw is the ID
+// of the framework within the master (an increasing integer).
+FrameworkID Master::newFrameworkId()
+{
+ time_t rawtime;
+ struct tm* timeinfo;
+ time(&rawtime);
+ timeinfo = localtime(&rawtime);
+ char timestr[32];
+ strftime(timestr, sizeof(timestr), "%Y%m%d%H%M", timeinfo);
+ int fwId = nextFrameworkId++;
+ char buf[128];
+ snprintf(buf, sizeof(buf), "%s-%d-%04d", timestr, masterId, fwId);
+ return string(buf);
+}
Modified: incubator/mesos/trunk/src/master.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master.hpp?rev=1131863&r1=1131862&r2=1131863&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master.hpp (original)
+++ incubator/mesos/trunk/src/master.hpp Sun Jun 5 05:42:05 2011
@@ -356,6 +356,8 @@ protected:
void removeSlave(Slave *slave);
virtual Allocator* createAllocator();
+
+ FrameworkID newFrameworkId();
};
Modified: incubator/mesos/trunk/src/tests/test_master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_master.cpp?rev=1131863&r1=1131862&r2=1131863&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_master.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_master.cpp Sun Jun 5 05:42:05 2011
@@ -637,7 +637,7 @@ public:
// TODO(benh): Cleanup the way we launch local drivers!
setenv("NEXUS_LOCAL", "1", 1);
setenv("NEXUS_SLAVE_PID", pid.c_str(), 1);
- setenv("NEXUS_FRAMEWORK_ID", "0-0", 1);
+ setenv("NEXUS_FRAMEWORK_ID", framework->id.c_str(), 1);
driver = new NexusExecutorDriver(executor);
driver->start();