Windows: [3/3] Used `os::random`. Review: https://reviews.apache.org/r/47053/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/148348b4 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/148348b4 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/148348b4 Branch: refs/heads/master Commit: 148348b4f9c0cd9bd3b7154e81d9d4a38d99c6c1 Parents: 2f83201 Author: Daniel Pravat <dpra...@outlook.com> Authored: Fri May 13 11:08:54 2016 -0400 Committer: Joris Van Remoortere <joris.van.remoort...@gmail.com> Committed: Fri May 13 11:27:59 2016 -0400 ---------------------------------------------------------------------- src/executor/executor.cpp | 2 +- src/log/consensus.cpp | 3 ++- src/log/recover.cpp | 3 ++- src/log/tool/benchmark.cpp | 3 ++- src/sched/sched.cpp | 2 +- src/slave/slave.cpp | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/executor/executor.cpp ---------------------------------------------------------------------- diff --git a/src/executor/executor.cpp b/src/executor/executor.cpp index 921872c..fd2d0cd 100644 --- a/src/executor/executor.cpp +++ b/src/executor/executor.cpp @@ -485,7 +485,7 @@ protected: // Linearly backoff by picking a random duration between 0 and // `maxBackoff`. - Duration backoff = maxBackoff.get() * ((double) ::random() / RAND_MAX); + Duration backoff = maxBackoff.get() * ((double) os::random() / RAND_MAX); VLOG(1) << "Will retry connecting with the agent again in " << backoff; http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/log/consensus.cpp ---------------------------------------------------------------------- diff --git a/src/log/consensus.cpp b/src/log/consensus.cpp index 67bd30b..27f2c58 100644 --- a/src/log/consensus.cpp +++ b/src/log/consensus.cpp @@ -27,6 +27,7 @@ #include <stout/check.hpp> #include <stout/duration.hpp> #include <stout/lambda.hpp> +#include <stout/os.hpp> #include <stout/nothing.hpp> #include <stout/foreach.hpp> @@ -771,7 +772,7 @@ private: // one proposer usually times out and wins before others wake up. // On the other hand, we want T to be as small as possible such // that we can reduce the wait time. - Duration d = T * (1.0 + (double) ::random() / RAND_MAX); + Duration d = T * (1.0 + (double) os::random() / RAND_MAX); delay(d, self(), &Self::runPromisePhase); } http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/log/recover.cpp ---------------------------------------------------------------------- diff --git a/src/log/recover.cpp b/src/log/recover.cpp index eaa001e..826e5cd 100644 --- a/src/log/recover.cpp +++ b/src/log/recover.cpp @@ -33,6 +33,7 @@ #include <stout/lambda.hpp> #include <stout/none.hpp> #include <stout/option.hpp> +#include <stout/os.hpp> #include "log/catchup.hpp" #include "log/recover.hpp" @@ -332,7 +333,7 @@ private: // likelihood of conflicts (i.e., a replica receives a recover // request while it is changing its status). static const Duration T = Milliseconds(500); - Duration d = T * (1.0 + (double) ::random() / RAND_MAX); + Duration d = T * (1.0 + (double) os::random() / RAND_MAX); VLOG(2) << "Didn't receive enough responses for recovery, retrying " << "in " << stringify(d); http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/log/tool/benchmark.cpp ---------------------------------------------------------------------- diff --git a/src/log/tool/benchmark.cpp b/src/log/tool/benchmark.cpp index 0f556e1..7e13506 100644 --- a/src/log/tool/benchmark.cpp +++ b/src/log/tool/benchmark.cpp @@ -31,6 +31,7 @@ #include <stout/bytes.hpp> #include <stout/error.hpp> #include <stout/foreach.hpp> +#include <stout/os.hpp> #include <stout/stopwatch.hpp> #include <stout/strings.hpp> #include <stout/os/read.hpp> @@ -216,7 +217,7 @@ Try<Nothing> Benchmark::execute(int argc, char** argv) if (flags.type == "one") { data.push_back(string(sizes[i].bytes(), static_cast<char>(0xff))); } else if (flags.type == "random") { - data.push_back(string(sizes[i].bytes(), ::random() % 256)); + data.push_back(string(sizes[i].bytes(), os::random() % 256)); } else { data.push_back(string(sizes[i].bytes(), 0)); } http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/sched/sched.cpp ---------------------------------------------------------------------- diff --git a/src/sched/sched.cpp b/src/sched/sched.cpp index cc3aac9..9e55885 100644 --- a/src/sched/sched.cpp +++ b/src/sched/sched.cpp @@ -811,7 +811,7 @@ protected: // Determine the delay for next attempt by picking a random // duration between 0 and 'maxBackoff'. // TODO(vinod): Use random numbers from <random> header. - Duration delay = maxBackoff * ((double) ::random() / RAND_MAX); + Duration delay = maxBackoff * ((double) os::random() / RAND_MAX); VLOG(1) << "Will retry registration in " << delay << " if necessary"; http://git-wip-us.apache.org/repos/asf/mesos/blob/148348b4/src/slave/slave.cpp ---------------------------------------------------------------------- diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp index 0a73480..7c87039 100644 --- a/src/slave/slave.cpp +++ b/src/slave/slave.cpp @@ -953,7 +953,7 @@ void Slave::detected(const Future<Option<MasterInfo>>& _master) // Wait for a random amount of time before authentication or // registration. Duration duration = - flags.registration_backoff_factor * ((double) ::random() / RAND_MAX); + flags.registration_backoff_factor * ((double) os::random() / RAND_MAX); if (credential.isSome()) { // Authenticate with the master. @@ -1480,7 +1480,7 @@ void Slave::doReliableRegistration(Duration maxBackoff) // Determine the delay for next attempt by picking a random // duration between 0 and 'maxBackoff'. - Duration delay = maxBackoff * ((double) ::random() / RAND_MAX); + Duration delay = maxBackoff * ((double) os::random() / RAND_MAX); VLOG(1) << "Will retry registration in " << delay << " if necessary";