Scatter downloads to reduce bandwidth spikes.
Support in update_engine to honor the enterprise policy to scatter the
downloading of ChromeOS automatic updates so that we reduce bandwidth
spikes caused due to simultaneous downloads of updates by a large number
of enterprise devices.
This has no effect on consumer devices.
BUG=chromeos-29615: Implement scattering of downloads in UpdateEngine
TEST=Manually tested all scenarios, Unit tests added for all new code.
CQ-DEPEND=I1f56b5516970d5988eebb2cf8f93f6905823801d
Change-Id: I4a8f4974467a064d723ab13cbd78b1ca3ceff420
Reviewed-on: https://gerrit.chromium.org/gerrit/21574
Commit-Ready: Jay Srinivasan <[email protected]>
Reviewed-by: Jay Srinivasan <[email protected]>
Tested-by: Jay Srinivasan <[email protected]>
diff --git a/utils.cc b/utils.cc
index 1cdcc5c..bf9267c 100644
--- a/utils.cc
+++ b/utils.cc
@@ -24,6 +24,7 @@
#include <base/file_util.h>
#include <base/logging.h>
#include <base/rand_util.h>
+#include <base/string_number_conversions.h>
#include <base/string_util.h>
#include <base/stringprintf.h>
#include <google/protobuf/stubs/common.h>
@@ -33,6 +34,7 @@
#include "update_engine/omaha_request_params.h"
#include "update_engine/subprocess.h"
+using base::Time;
using std::min;
using std::string;
using std::vector;
@@ -43,6 +45,7 @@
static const char kOOBECompletedMarker[] = "/home/chronos/.oobe_completed";
static const char kDevImageMarker[] = "/root/.dev_mode";
+const char* const kStatefulPartition = "/mnt/stateful_partition";
bool IsOfficialBuild() {
return !file_util::PathExists(FilePath(kDevImageMarker));
@@ -626,7 +629,17 @@
return str;
}
-const char* const kStatefulPartition = "/mnt/stateful_partition";
+string ToString(const Time utc_time) {
+ Time::Exploded exp_time;
+ utc_time.UTCExplode(&exp_time);
+ return StringPrintf("%d/%d/%d %d:%02d:%02d GMT",
+ exp_time.month,
+ exp_time.day_of_month,
+ exp_time.year,
+ exp_time.hour,
+ exp_time.minute,
+ exp_time.second);
+}
} // namespace utils