You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2013/04/15 02:35:39 UTC

svn commit: r1467843 - in /incubator/mesos/trunk/src: examples/ exec/ launcher/ log/ tests/

Author: bmahler
Date: Mon Apr 15 00:35:39 2013
New Revision: 1467843

URL: http://svn.apache.org/r1467843
Log:
Replaced sleep() and usleep() calls with os::sleep().

From: Jiang Yan Xu <ya...@jxu.me>
Review: https://reviews.apache.org/r/10443

Modified:
    incubator/mesos/trunk/src/examples/balloon_executor.cpp
    incubator/mesos/trunk/src/examples/long_lived_executor.cpp
    incubator/mesos/trunk/src/examples/test_executor.cpp
    incubator/mesos/trunk/src/exec/exec.cpp
    incubator/mesos/trunk/src/launcher/executor.cpp
    incubator/mesos/trunk/src/log/log.cpp
    incubator/mesos/trunk/src/tests/process_spawn.cpp
    incubator/mesos/trunk/src/tests/utils.hpp
    incubator/mesos/trunk/src/tests/zookeeper_tests.cpp

Modified: incubator/mesos/trunk/src/examples/balloon_executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/balloon_executor.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/balloon_executor.cpp (original)
+++ incubator/mesos/trunk/src/examples/balloon_executor.cpp Mon Apr 15 00:35:39 2013
@@ -21,7 +21,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include <sys/mman.h>
 
@@ -30,7 +29,9 @@
 
 #include <mesos/executor.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/numify.hpp>
+#include <stout/os.hpp>
 
 using namespace mesos;
 
@@ -69,7 +70,7 @@ static void balloon(size_t limit)
     }
 
     // Try not to increase the memory footprint too fast.
-    sleep(1);
+    os::sleep(Seconds(1));
   }
 }
 

Modified: incubator/mesos/trunk/src/examples/long_lived_executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/long_lived_executor.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/long_lived_executor.cpp (original)
+++ incubator/mesos/trunk/src/examples/long_lived_executor.cpp Mon Apr 15 00:35:39 2013
@@ -18,7 +18,6 @@
 
 #include <pthread.h>
 #include <stdlib.h> // For random.
-#include <unistd.h> // For sleep.
 
 #include <cstdlib>
 #include <iostream>
@@ -27,6 +26,9 @@
 
 #include <mesos/executor.hpp>
 
+#include <stout/duration.hpp>
+#include <stout/os.hpp>
+
 using namespace mesos;
 
 using std::cout;
@@ -36,7 +38,7 @@ using std::string;
 
 void run(ExecutorDriver* driver, const TaskInfo& task)
 {
-  sleep(random() % 10);
+  os::sleep(Seconds(random() % 10));
 
   TaskStatus status;
   status.mutable_task_id()->MergeFrom(task.task_id());

Modified: incubator/mesos/trunk/src/examples/test_executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/examples/test_executor.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/examples/test_executor.cpp (original)
+++ incubator/mesos/trunk/src/examples/test_executor.cpp Mon Apr 15 00:35:39 2013
@@ -16,12 +16,13 @@
  * limitations under the License.
  */
 
-#include <unistd.h>
-
 #include <iostream>
 
 #include <mesos/executor.hpp>
 
+#include <stout/duration.hpp>
+#include <stout/os.hpp>
+
 using namespace mesos;
 
 using std::cout;
@@ -60,7 +61,7 @@ public:
 
     driver->sendStatusUpdate(status);
 
-    sleep(1);
+    os::sleep(Seconds(1));
 
     cout << "Finishing task " << task.task_id().value() << endl;
 

Modified: incubator/mesos/trunk/src/exec/exec.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/exec/exec.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/exec/exec.cpp (original)
+++ incubator/mesos/trunk/src/exec/exec.cpp Mon Apr 15 00:35:39 2013
@@ -17,7 +17,6 @@
  */
 
 #include <signal.h>
-#include <unistd.h>
 
 #include <sys/types.h>
 
@@ -33,6 +32,7 @@
 #include <process/process.hpp>
 #include <process/protobuf.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/hashmap.hpp>
 #include <stout/hashset.hpp>
 #include <stout/fatal.hpp>
@@ -88,7 +88,7 @@ protected:
 
     // The signal might not get delivered immediately, so sleep for a
     // few seconds. Worst case scenario, exit abnormally.
-    sleep(5);
+    os::sleep(Seconds(5));
     exit(-1);
   }
 };

Modified: incubator/mesos/trunk/src/launcher/executor.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/launcher/executor.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/launcher/executor.cpp (original)
+++ incubator/mesos/trunk/src/launcher/executor.cpp Mon Apr 15 00:35:39 2013
@@ -26,6 +26,7 @@
 
 #include <mesos/executor.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/os.hpp>
 #include <stout/strings.hpp>
 
@@ -77,7 +78,7 @@ static void waiter(pid_t pid, const Task
 
   // A hack for now ... but we need to wait until for the status
   // update to get sent to the slave before we shut ourselves down.
-  sleep(1);
+  os::sleep(Seconds(1));
   driver->stop();
 }
 

Modified: incubator/mesos/trunk/src/log/log.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/log/log.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/log/log.cpp (original)
+++ incubator/mesos/trunk/src/log/log.cpp Mon Apr 15 00:35:39 2013
@@ -35,8 +35,6 @@
 // out ways of bringing new replicas online that seem to check the
 // consistency of the other replicas.
 
-#include <unistd.h>
-
 #include <list>
 #include <map>
 #include <set>
@@ -49,8 +47,10 @@
 #include <process/process.hpp>
 #include <process/run.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/fatal.hpp>
 #include <stout/foreach.hpp>
+#include <stout/os.hpp>
 #include <stout/result.hpp>
 
 #include "zookeeper/zookeeper.hpp"
@@ -116,7 +116,7 @@ bool coordinate(Coordinator* coordinator
         restart();
       } else {
         attempt++;
-        sleep(1);
+        os::sleep(Seconds(1));
       }
     } else {
       CHECK_SOME(result);
@@ -141,7 +141,7 @@ bool coordinate(Coordinator* coordinator
           restart();
         } else {
           attempt++;
-          sleep(1);
+          os::sleep(Seconds(1));
         }
       } else {
         CHECK_SOME(result);
@@ -183,13 +183,13 @@ bool coordinate(Coordinator* coordinator
           restart();
         } else {
           attempt++;
-          sleep(1);
+          os::sleep(Seconds(1));
           continue;
         }
       } else {
         CHECK_SOME(result);
         LOG(INFO) << "Truncated to " << to;
-        sleep(1);
+        os::sleep(Seconds(1));
         attempt = 1;
       }
     }
@@ -204,12 +204,12 @@ bool coordinate(Coordinator* coordinator
         restart();
       } else {
         attempt++;
-        sleep(1);
+        os::sleep(Seconds(1));
       }
     } else {
       CHECK_SOME(result);
       LOG(INFO) << "Wrote " << value;
-      sleep(1);
+      os::sleep(Seconds(1));
       writes--;
       value++;
       attempt = 1;

Modified: incubator/mesos/trunk/src/tests/process_spawn.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/process_spawn.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/process_spawn.cpp (original)
+++ incubator/mesos/trunk/src/tests/process_spawn.cpp Mon Apr 15 00:35:39 2013
@@ -19,7 +19,9 @@
 #include <iostream>
 #include <climits>
 #include <cstdio>
-#include <unistd.h>
+
+#include <stout/duration.hpp>
+#include <stout/os.hpp>
 
 using std::cout;
 using std::cin;
@@ -38,7 +40,7 @@ void processinfo()
 void dummywait()
 {
   while(getchar() == EOF) {
-    sleep(INT_MAX);
+    os::sleep(Seconds(INT_MAX));
   }
 
   cout << "Error: Shouldn't come here" << endl;

Modified: incubator/mesos/trunk/src/tests/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/utils.hpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/utils.hpp (original)
+++ incubator/mesos/trunk/src/tests/utils.hpp Mon Apr 15 00:35:39 2013
@@ -779,7 +779,7 @@ ACTION_P(SendStatusUpdateFromTaskID, sta
       if (expression) {                                                 \
         break;                                                          \
       }                                                                 \
-      usleep(10);                                                       \
+      os::sleep(Microseconds(10));                                      \
       sleeps++;                                                         \
       if (Microseconds(10 * sleeps) >= duration) {                      \
         FAIL() << "Waited too long for '" #expression "'";              \

Modified: incubator/mesos/trunk/src/tests/zookeeper_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/zookeeper_tests.cpp?rev=1467843&r1=1467842&r2=1467843&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/zookeeper_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/zookeeper_tests.cpp Mon Apr 15 00:35:39 2013
@@ -27,6 +27,7 @@
 #include <process/protobuf.hpp>
 
 #include <stout/duration.hpp>
+#include <stout/os.hpp>
 #include <stout/strings.hpp>
 #include <stout/nothing.hpp>
 #include <stout/try.hpp>
@@ -425,7 +426,7 @@ TEST_F(ZooKeeperTest, MasterDetectorExpi
   server->expireSession(session.get());
 
   // Wait for enough time to ensure no NewMasterDetected message is sent.
-  sleep(4); // ZooKeeper needs extra time for session expiration.
+  os::sleep(Seconds(4)); // ZooKeeper needs extra time for session expiration.
 
   process::terminate(slave);
   process::wait(slave);