mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r1382595 - in /incubator/mesos/trunk: src/java/jni/ src/log/ src/logging/ src/master/ src/tests/ third_party/libprocess/include/process/ third_party/libprocess/src/
Date Sun, 09 Sep 2012 22:03:41 GMT
Author: benh
Date: Sun Sep  9 22:03:40 2012
New Revision: 1382595

URL: http://svn.apache.org/viewvc?rev=1382595&view=rev
Log:
Replaced double with Duration in Timeout
(https://reviews.apache.org/r/6848).

Modified:
    incubator/mesos/trunk/src/java/jni/org_apache_mesos_Log.cpp
    incubator/mesos/trunk/src/log/network.hpp
    incubator/mesos/trunk/src/logging/logging.cpp
    incubator/mesos/trunk/src/master/hierarchical_allocator_process.hpp
    incubator/mesos/trunk/src/tests/log_tests.cpp
    incubator/mesos/trunk/third_party/libprocess/include/process/timeout.hpp
    incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp
    incubator/mesos/trunk/third_party/libprocess/src/process.cpp

Modified: incubator/mesos/trunk/src/java/jni/org_apache_mesos_Log.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/java/jni/org_apache_mesos_Log.cpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/src/java/jni/org_apache_mesos_Log.cpp (original)
+++ incubator/mesos/trunk/src/java/jni/org_apache_mesos_Log.cpp Sun Sep  9 22:03:40 2012
@@ -18,6 +18,8 @@
 
 #include <jni.h>
 
+#include <process/timeout.hpp>
+
 #include <stout/duration.hpp>
 
 #include "log/log.hpp"
@@ -147,9 +149,8 @@ JNIEXPORT jobject JNICALL Java_org_apach
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Timeout timeout(jseconds);
-
-  Result<std::list<Log::Entry> > entries = reader->read(from, to, timeout);
+  Result<std::list<Log::Entry> > entries =
+    reader->read(from, to, Timeout(Seconds(jseconds)));
 
   if (entries.isError()) {
     clazz = env->FindClass("org/apache/mesos/Log$OperationFailedException");
@@ -297,9 +298,8 @@ JNIEXPORT jobject JNICALL Java_org_apach
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Timeout timeout(jseconds);
-
-  Result<Log::Position> position = writer->append(data, timeout);
+  Result<Log::Position> position =
+    writer->append(data, Timeout(Seconds(jseconds)));
 
   env->ReleaseByteArrayElements(jdata, temp, 0);
 
@@ -350,9 +350,8 @@ JNIEXPORT jobject JNICALL Java_org_apach
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Timeout timeout(jseconds);
-
-  Result<Log::Position> position = writer->truncate(to, timeout);
+  Result<Log::Position> position =
+    writer->truncate(to, Timeout(Seconds(jseconds)));
 
   if (position.isError()) {
     clazz = env->FindClass("org/apache/mesos/Log$WriterFailedException");
@@ -404,12 +403,11 @@ JNIEXPORT void JNICALL Java_org_apache_m
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Timeout timeout(jseconds);
-
   int retries = jretries;
 
   // Create the C++ Log::Writer and initialize the __writer variable.
-  Log::Writer* writer = new Log::Writer(log, timeout, retries);
+  Log::Writer* writer =
+    new Log::Writer(log, Timeout(Seconds(jseconds)), retries);
 
   clazz = env->GetObjectClass(thiz);
 
@@ -517,12 +515,12 @@ JNIEXPORT void JNICALL Java_org_apache_m
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Seconds timeout(jseconds);
+  Seconds seconds(jseconds);
 
   std::string znode = construct<std::string>(env, jznode);
 
    // Create the C++ Log and initialize the __log variable.
-  Log* log = new Log(quorum, path, servers, timeout, znode);
+  Log* log = new Log(quorum, path, servers, seconds, znode);
 
   clazz = env->GetObjectClass(thiz);
 
@@ -561,7 +559,7 @@ JNIEXPORT void JNICALL Java_org_apache_m
 
   jlong jseconds = env->CallLongMethod(junit, toSeconds, jtimeout);
 
-  Seconds timeout(jseconds);
+  Seconds seconds(jseconds);
 
   std::string znode = construct<std::string>(env, jznode);
 
@@ -580,9 +578,9 @@ JNIEXPORT void JNICALL Java_org_apache_m
 
     zookeeper::Authentication authentication(scheme, credentials);
 
-    log = new Log(quorum, path, servers, timeout, znode, authentication);
+    log = new Log(quorum, path, servers, seconds, znode, authentication);
   } else {
-    log = new Log(quorum, path, servers, timeout, znode);
+    log = new Log(quorum, path, servers, seconds, znode);
   }
 
   CHECK(log != NULL);

Modified: incubator/mesos/trunk/src/log/network.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/log/network.hpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/src/log/network.hpp (original)
+++ incubator/mesos/trunk/src/log/network.hpp Sun Sep  9 22:03:40 2012
@@ -30,6 +30,7 @@
 #include <process/protobuf.hpp>
 #include <process/timeout.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/foreach.hpp>
 #include <stout/lambda.hpp>
 
@@ -279,7 +280,7 @@ inline void ZooKeeperNetwork::watched()
     futures.push_back(group->data(membership));
   }
 
-  datas = process::collect(futures, process::Timeout(5.0));
+  datas = process::collect(futures, process::Timeout(Seconds(5.0)));
   datas.onAny(executor.defer(lambda::bind(&This::collected, this)));
 }
 

Modified: incubator/mesos/trunk/src/logging/logging.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/logging/logging.cpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/src/logging/logging.cpp (original)
+++ incubator/mesos/trunk/src/logging/logging.cpp Sun Sep  9 22:03:40 2012
@@ -110,10 +110,10 @@ private:
       return BadRequest("'" + stringify(v.get()) + "' < original level.\n");
     }
 
-    Try<Duration> s = Duration::parse(duration.get());
+    Try<Duration> d = Duration::parse(duration.get());
 
-    if (s.isError()) {
-      return BadRequest(s.error() + ".\n");
+    if (d.isError()) {
+      return BadRequest(d.error() + ".\n");
     }
 
     // Set the logging level.
@@ -121,7 +121,7 @@ private:
 
     // Start a revert timer (if necessary).
     if (v.get() != original) {
-      timeout = s.get().secs();
+      timeout = d.get();
       delay(timeout.remaining(), this, &This::revert);
     }
 

Modified: incubator/mesos/trunk/src/master/hierarchical_allocator_process.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/master/hierarchical_allocator_process.hpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/src/master/hierarchical_allocator_process.hpp (original)
+++ incubator/mesos/trunk/src/master/hierarchical_allocator_process.hpp Sun Sep  9 22:03:40
2012
@@ -20,8 +20,10 @@
 #define __HIERARCHICAL_ALLOCATOR_PROCESS_HPP__
 
 #include <process/delay.hpp>
+#include <process/timeout.hpp>
 #include <process/timer.hpp>
 
+#include <stout/duration.hpp>
 #include <stout/hashmap.hpp>
 #include <stout/stopwatch.hpp>
 
@@ -432,21 +434,25 @@ void HierarchicalAllocatorProcess<UserSo
   allocatable[slaveId] += resources;
 
   // Create a refused resources filter.
-  Seconds timeout(filters.isSome()
+  Seconds seconds(filters.isSome()
                   ? filters.get().refuse_seconds()
                   : Filters().refuse_seconds());
 
-  if (timeout != Seconds(0)) {
+  if (seconds != Seconds(0)) {
     LOG(INFO) << "Framework " << frameworkId
 	      << " filtered slave " << slaveId
-	      << " for " << timeout;
+	      << " for " << seconds;
 
     // Create a new filter and delay it's expiration.
-    mesos::internal::master::Filter* filter = new RefusedFilter(slaveId, resources, timeout.secs());
+    mesos::internal::master::Filter* filter =
+      new RefusedFilter(slaveId, resources, Timeout(seconds));
+
     this->filters.put(frameworkId, filter);
 
-    delay(timeout, self(),
-          &HierarchicalAllocatorProcess<UserSorter, FrameworkSorter>::expire, frameworkId,
filter);
+    delay(seconds, self(),
+          &HierarchicalAllocatorProcess<UserSorter, FrameworkSorter>::expire,
+          frameworkId,
+          filter);
   }
 }
 

Modified: incubator/mesos/trunk/src/tests/log_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/log_tests.cpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/log_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/log_tests.cpp Sun Sep  9 22:03:40 2012
@@ -279,7 +279,7 @@ TEST(CoordinatorTest, Elect)
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -318,7 +318,7 @@ TEST(CoordinatorTest, AppendRead)
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -326,7 +326,8 @@ TEST(CoordinatorTest, AppendRead)
   uint64_t position;
 
   {
-    Result<uint64_t> result2 = coord.append("hello world", Timeout(2.0));
+    Result<uint64_t> result2 =
+      coord.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result2.isSome());
     position = result2.get();
     EXPECT_EQ(1u, position);
@@ -367,7 +368,7 @@ TEST(CoordinatorTest, AppendReadError)
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -375,7 +376,8 @@ TEST(CoordinatorTest, AppendReadError)
   uint64_t position;
 
   {
-    Result<uint64_t> result2 = coord.append("hello world", Timeout(2.0));
+    Result<uint64_t> result2 =
+      coord.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result2.isSome());
     position = result2.get();
     EXPECT_EQ(1u, position);
@@ -425,7 +427,7 @@ TEST(CoordinatorTest, DISABLED_ElectNoQu
   Coordinator coord(2, &replica, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
   }
 
@@ -452,7 +454,7 @@ TEST(CoordinatorTest, DISABLED_AppendNoQ
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -460,7 +462,8 @@ TEST(CoordinatorTest, DISABLED_AppendNoQ
   network.remove(replica1.pid());
 
   {
-    Result<uint64_t> result = coord.append("hello world", Timeout(2.0));
+    Result<uint64_t> result =
+      coord.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
   }
 
@@ -488,7 +491,7 @@ TEST(CoordinatorTest, Failover)
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -496,7 +499,7 @@ TEST(CoordinatorTest, Failover)
   uint64_t position;
 
   {
-    Result<uint64_t> result = coord1.append("hello world", Timeout(2.0));
+    Result<uint64_t> result = coord1.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     position = result.get();
     EXPECT_EQ(1u, position);
@@ -510,7 +513,7 @@ TEST(CoordinatorTest, Failover)
   Coordinator coord2(2, &replica2, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
@@ -550,7 +553,7 @@ TEST(CoordinatorTest, Demoted)
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -558,7 +561,8 @@ TEST(CoordinatorTest, Demoted)
   uint64_t position;
 
   {
-    Result<uint64_t> result = coord1.append("hello world", Timeout(2.0));
+    Result<uint64_t> result =
+      coord1.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     position = result.get();
     EXPECT_EQ(1u, position);
@@ -572,19 +576,21 @@ TEST(CoordinatorTest, Demoted)
   Coordinator coord2(2, &replica2, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
 
   {
-    Result<uint64_t> result = coord1.append("hello moto", Timeout(2.0));
+    Result<uint64_t> result =
+      coord1.append("hello moto", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isError());
     EXPECT_EQ("Coordinator demoted", result.error());
   }
 
   {
-    Result<uint64_t> result = coord2.append("hello hello", Timeout(2.0));
+    Result<uint64_t> result =
+      coord2.append("hello hello", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     position = result.get();
     EXPECT_EQ(2u, position);
@@ -627,7 +633,7 @@ TEST(CoordinatorTest, Fill)
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -635,7 +641,8 @@ TEST(CoordinatorTest, Fill)
   uint64_t position;
 
   {
-    Result<uint64_t> result = coord1.append("hello world", Timeout(2.0));
+    Result<uint64_t> result =
+      coord1.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     position = result.get();
     EXPECT_EQ(1u, position);
@@ -651,9 +658,9 @@ TEST(CoordinatorTest, Fill)
   Coordinator coord2(2, &replica3, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
-    result = coord2.elect(Timeout(2.0));
+    result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
@@ -705,7 +712,7 @@ TEST(CoordinatorTest, NotLearnedFill)
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
@@ -713,7 +720,8 @@ TEST(CoordinatorTest, NotLearnedFill)
   uint64_t position;
 
   {
-    Result<uint64_t> result = coord1.append("hello world", Timeout(2.0));
+    Result<uint64_t> result =
+      coord1.append("hello world", Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     position = result.get();
     EXPECT_EQ(1u, position);
@@ -729,9 +737,9 @@ TEST(CoordinatorTest, NotLearnedFill)
   Coordinator coord2(2, &replica3, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
-    result = coord2.elect(Timeout(2.0));
+    result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
@@ -774,14 +782,14 @@ TEST(CoordinatorTest, MultipleAppends)
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
 
   for (uint64_t position = 1; position <= 10; position++) {
     Result<uint64_t> result =
-      coord.append(stringify(position), Timeout(2.0));
+      coord.append(stringify(position), Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
@@ -833,14 +841,14 @@ TEST(CoordinatorTest, MultipleAppendsNot
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
 
   for (uint64_t position = 1; position <= 10; position++) {
     Result<uint64_t> result =
-      coord1.append(stringify(position), Timeout(2.0));
+      coord1.append(stringify(position), Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
@@ -855,9 +863,9 @@ TEST(CoordinatorTest, MultipleAppendsNot
   Coordinator coord2(2, &replica3, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
-    result = coord2.elect(Timeout(2.0));
+    result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(10u, result.get());
   }
@@ -901,20 +909,20 @@ TEST(CoordinatorTest, Truncate)
   Coordinator coord(2, &replica1, &network);
 
   {
-    Result<uint64_t> result = coord.elect(Timeout(2.0));
+    Result<uint64_t> result = coord.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
 
   for (uint64_t position = 1; position <= 10; position++) {
     Result<uint64_t> result =
-      coord.append(stringify(position), Timeout(2.0));
+      coord.append(stringify(position), Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
 
   {
-    Result<uint64_t> result = coord.truncate(7, Timeout(2.0));
+    Result<uint64_t> result = coord.truncate(7, Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(11u, result.get());
   }
@@ -973,20 +981,20 @@ TEST(CoordinatorTest, TruncateNotLearned
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
 
   for (uint64_t position = 1; position <= 10; position++) {
     Result<uint64_t> result =
-      coord1.append(stringify(position), Timeout(2.0));
+      coord1.append(stringify(position), Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
 
   {
-    Result<uint64_t> result = coord1.truncate(7, Timeout(2.0));
+    Result<uint64_t> result = coord1.truncate(7, Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(11u, result.get());
   }
@@ -1001,9 +1009,9 @@ TEST(CoordinatorTest, TruncateNotLearned
   Coordinator coord2(2, &replica3, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
-    result = coord2.elect(Timeout(2.0));
+    result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(11u, result.get());
   }
@@ -1056,20 +1064,20 @@ TEST(CoordinatorTest, TruncateLearnedFil
   Coordinator coord1(2, &replica1, &network1);
 
   {
-    Result<uint64_t> result = coord1.elect(Timeout(2.0));
+    Result<uint64_t> result = coord1.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(0u, result.get());
   }
 
   for (uint64_t position = 1; position <= 10; position++) {
     Result<uint64_t> result =
-      coord1.append(stringify(position), Timeout(2.0));
+      coord1.append(stringify(position), Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(position, result.get());
   }
 
   {
-    Result<uint64_t> result = coord1.truncate(7, Timeout(2.0));
+    Result<uint64_t> result = coord1.truncate(7, Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(11u, result.get());
   }
@@ -1084,9 +1092,9 @@ TEST(CoordinatorTest, TruncateLearnedFil
   Coordinator coord2(2, &replica3, &network2);
 
   {
-    Result<uint64_t> result = coord2.elect(Timeout(2.0));
+    Result<uint64_t> result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isNone());
-    result = coord2.elect(Timeout(2.0));
+    result = coord2.elect(Timeout(Seconds(2.0)));
     ASSERT_TRUE(result.isSome());
     EXPECT_EQ(11u, result.get());
   }
@@ -1131,16 +1139,17 @@ TEST(LogTest, WriteRead)
 
   Log log(2, path2, pids);
 
-  Log::Writer writer(&log, Timeout(1.0));
+  Log::Writer writer(&log, Timeout(Seconds(2.0)));
 
-  Result<Log::Position> position = writer.append("hello world", Timeout(1.0));
+  Result<Log::Position> position =
+    writer.append("hello world", Timeout(Seconds(2.0)));
 
   ASSERT_TRUE(position.isSome());
 
   Log::Reader reader(&log);
 
   Result<std::list<Log::Entry> > entries =
-    reader.read(position.get(), position.get(), Timeout(1.0));
+    reader.read(position.get(), position.get(), Timeout(Seconds(2.0)));
 
   ASSERT_TRUE(entries.isSome());
   ASSERT_EQ(1u, entries.get().size());
@@ -1167,9 +1176,10 @@ TEST(LogTest, Position)
 
   Log log(2, path2, pids);
 
-  Log::Writer writer(&log, Timeout(1.0));
+  Log::Writer writer(&log, Timeout(Seconds(2.0)));
 
-  Result<Log::Position> position = writer.append("hello world", Timeout(1.0));
+  Result<Log::Position> position =
+    writer.append("hello world", Timeout(Seconds(2.0)));
 
   ASSERT_TRUE(position.isSome());
 

Modified: incubator/mesos/trunk/third_party/libprocess/include/process/timeout.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/timeout.hpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/timeout.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/timeout.hpp Sun Sep  9 22:03:40
2012
@@ -3,6 +3,8 @@
 
 #include <process/process.hpp>
 
+#include <stout/duration.hpp>
+
 namespace process {
 
 class Timeout
@@ -13,9 +15,9 @@ public:
     timeout = Clock::now();
   }
 
-  Timeout(double seconds)
+  Timeout(const Duration& duration)
   {
-    timeout = Clock::now() + seconds;
+    timeout = Clock::now() + duration.secs();
   }
 
   Timeout(const Timeout& that)
@@ -32,9 +34,9 @@ public:
     return *this;
   }
 
-  Timeout& operator = (double seconds)
+  Timeout& operator = (const Duration& duration)
   {
-    timeout = Clock::now() + seconds;
+    timeout = Clock::now() + duration.secs();
     return *this;
   }
 

Modified: incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/include/process/timer.hpp Sun Sep  9 22:03:40
2012
@@ -16,7 +16,7 @@ namespace process {
 class Timer
 {
 public:
-  Timer() : id(0), t(0), pid(process::UPID()), thunk(&abort) {}
+  Timer() : id(0), pid(process::UPID()), thunk(&abort) {}
 
   static Timer create(
       const Duration& duration,

Modified: incubator/mesos/trunk/third_party/libprocess/src/process.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/third_party/libprocess/src/process.cpp?rev=1382595&r1=1382594&r2=1382595&view=diff
==============================================================================
--- incubator/mesos/trunk/third_party/libprocess/src/process.cpp (original)
+++ incubator/mesos/trunk/third_party/libprocess/src/process.cpp Sun Sep  9 22:03:40 2012
@@ -2568,7 +2568,7 @@ Timer Timer::create(
 {
   static uint64_t id = 1; // Start at 1 since Timer() instances start with 0.
 
-  Timeout timeout(duration.secs()); // Assumes Clock::now() does Clock::now(__process__).
+  Timeout timeout(duration); // Assumes Clock::now() does Clock::now(__process__).
 
   UPID pid = __process__ != NULL ? __process__->self() : UPID();
 



Mime
View raw message