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 10:54:07 UTC

svn commit: r1132172 - in /incubator/mesos/trunk/src: common/date_utils.cpp common/date_utils.hpp event_history/file_event_writer.cpp master/master.cpp

Author: benh
Date: Sun Jun  5 08:54:07 2011
New Revision: 1132172

URL: http://svn.apache.org/viewvc?rev=1132172&view=rev
Log:
Renamed currentDate() to humanReadableDate().

Modified:
    incubator/mesos/trunk/src/common/date_utils.cpp
    incubator/mesos/trunk/src/common/date_utils.hpp
    incubator/mesos/trunk/src/event_history/file_event_writer.cpp
    incubator/mesos/trunk/src/master/master.cpp

Modified: incubator/mesos/trunk/src/common/date_utils.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/date_utils.cpp?rev=1132172&r1=1132171&r2=1132172&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/date_utils.cpp (original)
+++ incubator/mesos/trunk/src/common/date_utils.cpp Sun Jun  5 08:54:07 2011
@@ -16,7 +16,7 @@ string DateUtils::mockDate = "";
 
 
 // Get the current date in the format used for Mesos IDs (YYYYMMDDhhmm).
-string DateUtils::currentDate()
+string DateUtils::humanReadableDate()
 {
   if (useMockDate) {
     return mockDate;
@@ -34,10 +34,18 @@ string DateUtils::currentDate()
 
 // Get the current time in microseconds since the UNIX epoch.
 long DateUtils::currentDateInMicro() {
-  struct timeval curr_time;
-  struct timezone tzp;
-  gettimeofday(&curr_time, &tzp);
-  return (long)(curr_time.tv_sec * 1000000 + curr_time.tv_usec);
+  if (useMockDate) {
+    struct tm* timeinfo;
+    strptime(mockDate.c_str(), "%Y%m%d%H%M", timeinfo);
+    time_t rawtime = mktime(timeinfo);
+    long microSinceEpoch = rawtime * 1000000;
+    return microSinceEpoch;
+  } else {
+    struct timeval curr_time;
+    struct timezone tzp;
+    gettimeofday(&curr_time, &tzp);
+    return (long)(curr_time.tv_sec * 1000000 + curr_time.tv_usec);
+  }
 }
 
 

Modified: incubator/mesos/trunk/src/common/date_utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/date_utils.hpp?rev=1132172&r1=1132171&r2=1132172&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/date_utils.hpp (original)
+++ incubator/mesos/trunk/src/common/date_utils.hpp Sun Jun  5 08:54:07 2011
@@ -15,7 +15,7 @@ public:
   /**
    * Get the current date in the format used for Mesos IDs (YYYYMMDDhhmm).
    */
-  static std::string currentDate();
+  static std::string humanReadableDate();
 
   /**
    * Get the current time in microseconds since the UNIX epoch.

Modified: incubator/mesos/trunk/src/event_history/file_event_writer.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/event_history/file_event_writer.cpp?rev=1132172&r1=1132171&r2=1132172&view=diff
==============================================================================
--- incubator/mesos/trunk/src/event_history/file_event_writer.cpp (original)
+++ incubator/mesos/trunk/src/event_history/file_event_writer.cpp Sun Jun  5 08:54:07 2011
@@ -32,7 +32,7 @@ int FileEventWriter::logTaskCreated(Task
                                     string webuiUrl, Resources resVec)
 {
   logfile << "{"
-            << "datetime:" << DateUtils::currentDate() << ","
+            << "datetime:" << DateUtils::humanReadableDate() << ","
             << "event_type:CreateTask,"
             << "taskid:" << tid << ","
             << "fwid:" << fwid << ","
@@ -48,7 +48,7 @@ int FileEventWriter::logTaskStateUpdated
                                          TaskState state)
 {
   logfile << "{" 
-            << "datetime:" << DateUtils::currentDate() << "," 
+            << "datetime:" << DateUtils::humanReadableDate() << "," 
             << "event_type:TaskStateUpdate,"
             << "taskid:" << tid << ","
             << "fwid:" << fwid << ","
@@ -61,7 +61,7 @@ int FileEventWriter::logTaskStateUpdated
 
 int FileEventWriter::logFrameworkRegistered(FrameworkID fwid, string user) {
   logfile << "{"
-            << "datetime:" << DateUtils::currentDate() << ","
+            << "datetime:" << DateUtils::humanReadableDate() << ","
             << "event_type:CreateFramework,"
             << "fwid:" << fwid << ","
             << "userid:" << user

Modified: incubator/mesos/trunk/src/master/master.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/master.cpp?rev=1132172&r1=1132171&r2=1132172&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/master.cpp (original)
+++ incubator/mesos/trunk/src/master/master.cpp Sun Jun  5 08:54:07 2011
@@ -264,7 +264,7 @@ void Master::operator () ()
   }
   string faultToleranceId;
   tie(faultToleranceId) = unpack<GOT_MASTER_ID>(body());
-  masterId = DateUtils::currentDate() + "-" + faultToleranceId;
+  masterId = DateUtils::humanReadableDate() + "-" + faultToleranceId;
   LOG(INFO) << "Master ID: " << masterId;
 
   // Create the allocator (we do this after the constructor because it