You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2017/12/21 19:31:12 UTC
[1/4] mesos git commit: Removed `kilobytes()`, `megabytes()`,
etc from `Bytes`.
Repository: mesos
Updated Branches:
refs/heads/master 7db362c9e -> 63f116a54
Removed `kilobytes()`, `megabytes()`, etc from `Bytes`.
These functios are removed because they are lossy. The unit conversion
for `Resource` should be explicit. For example:
`resource.scalar().set_value((double) size.bytes() / Bytes::MEGABYTES)`
Review: https://reviews.apache.org/r/64754/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e3b8c1ab
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e3b8c1ab
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e3b8c1ab
Branch: refs/heads/master
Commit: e3b8c1ab5e74a473c75ddb22acfb6f04a327def7
Parents: 7db362c
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Thu Dec 21 11:03:22 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Dec 21 11:03:22 2017 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/bytes.hpp | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/e3b8c1ab/3rdparty/stout/include/stout/bytes.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/bytes.hpp b/3rdparty/stout/include/stout/bytes.hpp
index cbe9536..93d25b0 100644
--- a/3rdparty/stout/include/stout/bytes.hpp
+++ b/3rdparty/stout/include/stout/bytes.hpp
@@ -76,13 +76,7 @@ public:
constexpr Bytes(uint64_t bytes = 0) : value(bytes) {}
constexpr Bytes(uint64_t _value, uint64_t _unit) : value(_value * _unit) {}
- // TODO(bmahler): Consider killing kilobytes to terabyte helpers, given
- // they implicitly lose precision if not careful.
uint64_t bytes() const { return value; }
- uint64_t kilobytes() const { return value / KILOBYTES; }
- uint64_t megabytes() const { return value / MEGABYTES; }
- uint64_t gigabytes() const { return value / GIGABYTES; }
- uint64_t terabytes() const { return value / TERABYTES; }
bool operator<(const Bytes& that) const { return value < that.value; }
bool operator<=(const Bytes& that) const { return value <= that.value; }
@@ -148,17 +142,17 @@ inline std::ostream& operator<<(std::ostream& stream, const Bytes& bytes)
{
// Only raise the unit when there is no loss of information.
if (bytes.bytes() == 0) {
+ return stream << "0B";
+ } else if (bytes.bytes() % Bytes::KILOBYTES != 0) {
return stream << bytes.bytes() << "B";
- } else if (bytes.bytes() % 1024 != 0) {
- return stream << bytes.bytes() << "B";
- } else if (bytes.kilobytes() % 1024 != 0) {
- return stream << bytes.kilobytes() << "KB";
- } else if (bytes.megabytes() % 1024 != 0) {
- return stream << bytes.megabytes() << "MB";
- } else if (bytes.gigabytes() % 1024 != 0) {
- return stream << bytes.gigabytes() << "GB";
+ } else if (bytes.bytes() % Bytes::MEGABYTES != 0) {
+ return stream << (bytes.bytes() / Bytes::KILOBYTES) << "KB";
+ } else if (bytes.bytes() % Bytes::GIGABYTES != 0) {
+ return stream << (bytes.bytes() / Bytes::MEGABYTES) << "MB";
+ } else if (bytes.bytes() % Bytes::TERABYTES != 0) {
+ return stream << (bytes.bytes() / Bytes::GIGABYTES) << "GB";
} else {
- return stream << bytes.terabytes() << "TB";
+ return stream << (bytes.bytes() / Bytes::TERABYTES) << "TB";
}
}
[3/4] mesos git commit: Fixed a bug that SLRP would fail if the state
files do not exist.
Posted by ji...@apache.org.
Fixed a bug that SLRP would fail if the state files do not exist.
Review: https://reviews.apache.org/r/64756/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/1a365b78
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/1a365b78
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/1a365b78
Branch: refs/heads/master
Commit: 1a365b7856c7bad4b7fc76c2e6726c8e2ccf1ceb
Parents: 866d4c8
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Thu Dec 21 11:03:37 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Dec 21 11:03:37 2017 -0800
----------------------------------------------------------------------
src/resource_provider/storage/provider.cpp | 30 ++++++++++++++++---------
1 file changed, 20 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/1a365b78/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index 34c413e..ee9ac90 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -704,18 +704,20 @@ Future<Nothing> StorageLocalResourceProviderProcess::recoverServices()
info.storage().plugin().name(),
containerId);
- Result<CSIPluginContainerInfo> config =
- ::protobuf::read<CSIPluginContainerInfo>(configPath);
+ if (os::exists(configPath)) {
+ Result<CSIPluginContainerInfo> config =
+ ::protobuf::read<CSIPluginContainerInfo>(configPath);
- if (config.isError()) {
- return Failure(
- "Failed to read plugin container config from '" +
- configPath + "': " + config.error());
- }
+ if (config.isError()) {
+ return Failure(
+ "Failed to read plugin container config from '" +
+ configPath + "': " + config.error());
+ }
- if (config.isSome() &&
- getCSIPluginContainerInfo(info, containerId) == config.get()) {
- continue;
+ if (config.isSome() &&
+ getCSIPluginContainerInfo(info, containerId) == config.get()) {
+ continue;
+ }
}
}
@@ -790,6 +792,10 @@ Future<Nothing> StorageLocalResourceProviderProcess::recoverVolumes()
info.storage().plugin().name(),
volumeId);
+ if (!os::exists(statePath)) {
+ continue;
+ }
+
Result<csi::state::VolumeState> volumeState =
::protobuf::read<csi::state::VolumeState>(statePath);
@@ -892,6 +898,10 @@ StorageLocalResourceProviderProcess::recoverResourceProviderState()
const string statePath = slave::paths::getResourceProviderStatePath(
metaDir, slaveId, info.type(), info.name(), info.id());
+ if (!os::exists(statePath)) {
+ return Nothing();
+ }
+
Result<ResourceProviderState> resourceProviderState =
::protobuf::read<ResourceProviderState>(statePath);
[2/4] mesos git commit: Removed the usage of `Bytes::kilobytes()` and
`Bytes::megabytes()`.
Posted by ji...@apache.org.
Removed the usage of `Bytes::kilobytes()` and `Bytes::megabytes()`.
Review: https://reviews.apache.org/r/64755/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/866d4c8d
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/866d4c8d
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/866d4c8d
Branch: refs/heads/master
Commit: 866d4c8da0794b1d45ba0e57e857bf06dabdc295
Parents: e3b8c1a
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Thu Dec 21 11:03:25 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Dec 21 11:03:25 2017 -0800
----------------------------------------------------------------------
src/examples/balloon_executor.cpp | 2 +-
src/examples/balloon_framework.cpp | 5 +++--
src/examples/disk_full_framework.cpp | 5 +++--
src/master/validation.cpp | 4 ++--
src/resource_provider/storage/provider.cpp | 9 +++++----
src/slave/containerizer/containerizer.cpp | 8 ++++++--
.../mesos/isolators/cgroups/subsystems/memory.cpp | 3 ++-
src/slave/slave.cpp | 5 ++++-
src/tests/container_logger_tests.cpp | 16 ++++++++--------
.../containerizer/docker_containerizer_tests.cpp | 4 ++--
src/tests/hierarchical_allocator_tests.cpp | 14 +++++++++-----
src/tests/mesos.hpp | 6 ++++--
src/tests/persistent_volume_tests.cpp | 6 +++---
13 files changed, 52 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/examples/balloon_executor.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_executor.cpp b/src/examples/balloon_executor.cpp
index 7343ee7..941cbe7 100644
--- a/src/examples/balloon_executor.cpp
+++ b/src/examples/balloon_executor.cpp
@@ -59,7 +59,7 @@ void run(ExecutorDriver* driver, const TaskInfo& task)
// Get the balloon limit (in MB).
Try<Bytes> _limit = Bytes::parse(task.data());
CHECK(_limit.isSome());
- const size_t limit = _limit->megabytes();
+ const size_t limit = _limit->bytes() / Bytes::MEGABYTES;
const size_t chunk = BALLOON_STEP_MB * 1024 * 1024;
for (size_t i = 0; i < limit / BALLOON_STEP_MB; i++) {
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/examples/balloon_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/balloon_framework.cpp b/src/examples/balloon_framework.cpp
index a36e04b..410966e 100644
--- a/src/examples/balloon_framework.cpp
+++ b/src/examples/balloon_framework.cpp
@@ -91,7 +91,7 @@ public:
"The task will attempt to occupy memory up until this limit.",
static_cast<const Bytes*>(nullptr),
[](const Bytes& value) -> Option<Error> {
- if (value.megabytes() < MEM_PER_EXECUTOR) {
+ if (value < Bytes(MEM_PER_EXECUTOR, Bytes::MEGABYTES)) {
return Error(
"Please use a --task_memory_usage_limit greater than " +
stringify(MEM_PER_EXECUTOR) + " MB");
@@ -211,7 +211,8 @@ public:
{
Resources taskResources = Resources::parse(
"cpus:" + stringify(CPUS_PER_TASK) +
- ";mem:" + stringify(flags.task_memory.megabytes())).get();
+ ";mem:" + stringify(
+ (double) flags.task_memory.bytes() / Bytes::MEGABYTES)).get();
taskResources.allocate(role);
Resources executorResources = Resources(executor.resources());
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/examples/disk_full_framework.cpp
----------------------------------------------------------------------
diff --git a/src/examples/disk_full_framework.cpp b/src/examples/disk_full_framework.cpp
index d9d2d35..d75f769 100644
--- a/src/examples/disk_full_framework.cpp
+++ b/src/examples/disk_full_framework.cpp
@@ -149,7 +149,8 @@ public:
Resources taskResources = Resources::parse(
"cpus:" + stringify(CPUS_PER_TASK) +
";mem:" + stringify(MEMORY_PER_TASK) +
- ";disk:" + stringify(DISK_PER_TASK.megabytes())).get();
+ ";disk:" + stringify(
+ (double) DISK_PER_TASK.bytes() / Bytes::MEGABYTES)).get();
taskResources.allocate(role);
foreach (const Offer& offer, offers) {
@@ -182,7 +183,7 @@ public:
static const string command =
"sleep " + stringify(flags.pre_sleep_duration.secs()) +
" && dd if=/dev/zero of=file bs=1K count=" +
- stringify(flags.disk_use_limit.kilobytes()) +
+ stringify(flags.disk_use_limit.bytes() / Bytes::KILOBYTES) +
" && sleep " + stringify(flags.post_sleep_duration.secs());
TaskInfo task;
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/master/validation.cpp
----------------------------------------------------------------------
diff --git a/src/master/validation.cpp b/src/master/validation.cpp
index 1e1e754..44d7a57 100644
--- a/src/master/validation.cpp
+++ b/src/master/validation.cpp
@@ -1399,7 +1399,7 @@ Option<Error> validateExecutor(
<< "Executor '" << task.executor().executor_id()
<< "' for task '" << task.task_id()
<< "' uses less memory ("
- << (mem.isSome() ? stringify(mem.get().megabytes()) : "None")
+ << (mem.isSome() ? stringify(mem.get()) : "None")
<< ") than the minimum required (" << MIN_MEM
<< "). Please update your executor, as this will be mandatory "
<< "in future releases.";
@@ -1582,7 +1582,7 @@ Option<Error> validateExecutor(
return Error(
"Executor '" + stringify(executor.executor_id()) +
"' uses less memory (" +
- (mem.isSome() ? stringify(mem.get().megabytes()) : "None") +
+ (mem.isSome() ? stringify(mem.get()) : "None") +
") than the minimum required (" + stringify(MIN_MEM) + ")");
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/resource_provider/storage/provider.cpp
----------------------------------------------------------------------
diff --git a/src/resource_provider/storage/provider.cpp b/src/resource_provider/storage/provider.cpp
index b6781d6..34c413e 100644
--- a/src/resource_provider/storage/provider.cpp
+++ b/src/resource_provider/storage/provider.cpp
@@ -253,7 +253,8 @@ static inline Resource createRawDiskResource(
Resource resource;
resource.set_name("disk");
resource.set_type(Value::SCALAR);
- resource.mutable_scalar()->set_value(capacity.megabytes());
+ resource.mutable_scalar()
+ ->set_value((double) capacity.bytes() / Bytes::MEGABYTES);
resource.mutable_provider_id()->CopyFrom(info.id()),
resource.mutable_reservations()->CopyFrom(info.default_reservations());
resource.mutable_disk()->mutable_source()
@@ -1195,7 +1196,7 @@ ResourceConversion StorageLocalResourceProviderProcess::reconcileResources(
foreach (const Resource& resource, checkpointed) {
Resource unconverted = createRawDiskResource(
info,
- Bytes(resource.scalar().value(), Bytes::MEGABYTES),
+ Bytes(resource.scalar().value() * Bytes::MEGABYTES),
resource.disk().source().has_profile()
? resource.disk().source().profile() : Option<string>::none(),
resource.disk().source().has_id()
@@ -2743,7 +2744,7 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
// RAW profiled resources afterward.
created = createVolume(
operationUuid.toString(),
- Bytes(resource.scalar().value(), Bytes::MEGABYTES),
+ Bytes(resource.scalar().value() * Bytes::MEGABYTES),
profileInfos.at(resource.disk().source().profile()));
} else {
const string& volumeId = resource.disk().source().id();
@@ -2786,7 +2787,7 @@ StorageLocalResourceProviderProcess::applyCreateVolumeOrBlock(
// RAW profiled resources afterward.
created = createVolume(
operationUuid.toString(),
- Bytes(resource.scalar().value(), Bytes::MEGABYTES),
+ Bytes(resource.scalar().value() * Bytes::MEGABYTES),
profileInfos.at(resource.disk().source().profile()));
} else {
const string& volumeId = resource.disk().source().id();
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/slave/containerizer/containerizer.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/containerizer.cpp b/src/slave/containerizer/containerizer.cpp
index 935dfc9..fa1d24a 100644
--- a/src/slave/containerizer/containerizer.cpp
+++ b/src/slave/containerizer/containerizer.cpp
@@ -156,9 +156,11 @@ Try<Resources> Containerizer::resources(const Flags& flags)
}
}
+ // NOTE: The size is truncated here to preserve the existing
+ // behavior for backward compatibility.
resources += Resources::parse(
"mem",
- stringify(mem.megabytes()),
+ stringify(mem.bytes() / Bytes::MEGABYTES),
flags.default_role).get();
}
@@ -184,9 +186,11 @@ Try<Resources> Containerizer::resources(const Flags& flags)
}
}
+ // NOTE: The size is truncated here to preserve the existing
+ // behavior for backward compatibility.
resources += Resources::parse(
"disk",
- stringify(disk.megabytes()),
+ stringify(disk.bytes() / Bytes::MEGABYTES),
flags.default_role).get();
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/slave/containerizer/mesos/isolators/cgroups/subsystems/memory.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/isolators/cgroups/subsystems/memory.cpp b/src/slave/containerizer/mesos/isolators/cgroups/subsystems/memory.cpp
index 113e908..99e824a 100644
--- a/src/slave/containerizer/mesos/isolators/cgroups/subsystems/memory.cpp
+++ b/src/slave/containerizer/mesos/isolators/cgroups/subsystems/memory.cpp
@@ -560,7 +560,8 @@ void MemorySubsystem::oomWaited(
// we should save the resources passed in and report it here.
Resources mem = Resources::parse(
"mem",
- stringify(usage.isSome() ? usage.get().megabytes() : 0),
+ stringify(usage.isSome()
+ ? (double) usage->bytes() / Bytes::MEGABYTES : 0),
"*").get();
infos[containerId]->limitation.set(
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/slave/slave.cpp
----------------------------------------------------------------------
diff --git a/src/slave/slave.cpp b/src/slave/slave.cpp
index e091d82..47d5632 100644
--- a/src/slave/slave.cpp
+++ b/src/slave/slave.cpp
@@ -5602,6 +5602,8 @@ ExecutorInfo Slave::getExecutorInfo(
// Add an allowance for the command executor. This does lead to a
// small overcommit of resources.
//
+ // NOTE: The size of the memory is truncated here to preserve the
+ // existing behavior for backward compatibility.
// TODO(vinod): If a task is using revocable resources, mark the
// corresponding executor resource (e.g., cpus) to be also
// revocable. Currently, it is OK because the containerizer is
@@ -5609,7 +5611,8 @@ ExecutorInfo Slave::getExecutorInfo(
// the container being correctly marked as revocable.
Resources executorOverhead = Resources::parse(
"cpus:" + stringify(DEFAULT_EXECUTOR_CPUS) + ";" +
- "mem:" + stringify(DEFAULT_EXECUTOR_MEM.megabytes())).get();
+ "mem:" + stringify(
+ DEFAULT_EXECUTOR_MEM.bytes() / Bytes::MEGABYTES)).get();
// If the task has an allocation role, we inject it into
// the executor as well. Note that old masters will not
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/tests/container_logger_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/container_logger_tests.cpp b/src/tests/container_logger_tests.cpp
index b65cf6a..2d5e7de 100644
--- a/src/tests/container_logger_tests.cpp
+++ b/src/tests/container_logger_tests.cpp
@@ -370,8 +370,8 @@ TEST_F(ContainerLoggerTest, LOGROTATE_RotateInSandbox)
// one MB since there is also the executor's output besides the task's stdout.
Try<Bytes> stdoutSize = os::stat::size(stdoutPath);
ASSERT_SOME(stdoutSize);
- EXPECT_LE(1024u, stdoutSize->kilobytes());
- EXPECT_GE(1050u, stdoutSize->kilobytes());
+ EXPECT_LE(1024u, stdoutSize->bytes() / Bytes::KILOBYTES);
+ EXPECT_GE(1050u, stdoutSize->bytes() / Bytes::KILOBYTES);
// We should only have files up to "stdout.4".
stdoutPath = path::join(sandboxDirectory, "stdout.5");
@@ -385,8 +385,8 @@ TEST_F(ContainerLoggerTest, LOGROTATE_RotateInSandbox)
// NOTE: The rotated files are written in contiguous blocks, meaning that
// each file may be less than the maximum allowed size.
stdoutSize = os::stat::size(stdoutPath);
- EXPECT_LE(2040u, stdoutSize->kilobytes());
- EXPECT_GE(2048u, stdoutSize->kilobytes());
+ EXPECT_LE(2040u, stdoutSize->bytes() / Bytes::KILOBYTES);
+ EXPECT_GE(2048u, stdoutSize->bytes() / Bytes::KILOBYTES);
}
}
@@ -783,8 +783,8 @@ TEST_P(UserContainerLoggerTest, ROOT_LOGROTATE_RotateWithSwitchUserTrueOrFalse)
// one MB since there is also the executor's output besides the task's stdout.
Try<Bytes> stdoutSize = os::stat::size(stdoutPath);
ASSERT_SOME(stdoutSize);
- EXPECT_LE(1024u, stdoutSize->kilobytes());
- EXPECT_GE(1050u, stdoutSize->kilobytes());
+ EXPECT_LE(1024u, stdoutSize->bytes() / Bytes::KILOBYTES);
+ EXPECT_GE(1050u, stdoutSize->bytes() / Bytes::KILOBYTES);
// We should only have files up to "stdout.1".
stdoutPath = path::join(sandboxDirectory, "stdout.2");
@@ -798,8 +798,8 @@ TEST_P(UserContainerLoggerTest, ROOT_LOGROTATE_RotateWithSwitchUserTrueOrFalse)
// each file may be less than the maximum allowed size.
stdoutSize = os::stat::size(stdoutPath);
ASSERT_SOME(stdoutSize);
- EXPECT_LE(2040u, stdoutSize->kilobytes());
- EXPECT_GE(2048u, stdoutSize->kilobytes());
+ EXPECT_LE(2040u, stdoutSize->bytes() / Bytes::KILOBYTES);
+ EXPECT_GE(2048u, stdoutSize->bytes() / Bytes::KILOBYTES);
}
#endif // __WINDOWS__
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/tests/containerizer/docker_containerizer_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/containerizer/docker_containerizer_tests.cpp b/src/tests/containerizer/docker_containerizer_tests.cpp
index 630bb2e..d1e6570 100644
--- a/src/tests/containerizer/docker_containerizer_tests.cpp
+++ b/src/tests/containerizer/docker_containerizer_tests.cpp
@@ -1131,7 +1131,7 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Update)
ASSERT_SOME(mem);
EXPECT_EQ(1024u, cpu.get());
- EXPECT_EQ(128u, mem->megabytes());
+ EXPECT_EQ(128u, mem->bytes() / Bytes::MEGABYTES);
newResources = Resources::parse("cpus:1;mem:144");
@@ -1151,7 +1151,7 @@ TEST_F(DockerContainerizerTest, ROOT_DOCKER_Update)
ASSERT_SOME(mem);
EXPECT_EQ(1024u, cpu.get());
- EXPECT_EQ(144u, mem->megabytes());
+ EXPECT_EQ(144u, mem->bytes() / Bytes::MEGABYTES);
driver.stop();
driver.join();
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/tests/hierarchical_allocator_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/hierarchical_allocator_tests.cpp b/src/tests/hierarchical_allocator_tests.cpp
index c98bebb..ad9d556 100644
--- a/src/tests/hierarchical_allocator_tests.cpp
+++ b/src/tests/hierarchical_allocator_tests.cpp
@@ -2069,7 +2069,8 @@ TEST_F(HierarchicalAllocatorTest, Allocatable)
// Not enough memory or cpu to be considered allocatable.
SlaveInfo slave1 = createSlaveInfo(
"cpus:" + stringify(MIN_CPUS / 2u) + ";"
- "mem:" + stringify((MIN_MEM / 2u).megabytes()) + ";"
+ "mem:" + stringify(
+ (double) (MIN_MEM / 2u).bytes() / Bytes::MEGABYTES) + ";"
"disk:128");
allocator->addSlave(
slave1.id(),
@@ -2082,7 +2083,8 @@ TEST_F(HierarchicalAllocatorTest, Allocatable)
// Enough cpus to be considered allocatable.
SlaveInfo slave2 = createSlaveInfo(
"cpus:" + stringify(MIN_CPUS) + ";"
- "mem:" + stringify((MIN_MEM / 2u).megabytes()) + ";"
+ "mem:" + stringify(
+ (double) (MIN_MEM / 2u).bytes() / Bytes::MEGABYTES) + ";"
"disk:128");
allocator->addSlave(
slave2.id(),
@@ -2101,7 +2103,7 @@ TEST_F(HierarchicalAllocatorTest, Allocatable)
// Enough memory to be considered allocatable.
SlaveInfo slave3 = createSlaveInfo(
"cpus:" + stringify(MIN_CPUS / 2u) + ";"
- "mem:" + stringify((MIN_MEM).megabytes()) + ";"
+ "mem:" + stringify((double) (MIN_MEM).bytes() / Bytes::MEGABYTES) + ";"
"disk:128");
allocator->addSlave(
slave3.id(),
@@ -2121,9 +2123,11 @@ TEST_F(HierarchicalAllocatorTest, Allocatable)
// but it lies across unreserved and reserved resources!
SlaveInfo slave4 = createSlaveInfo(
"cpus:" + stringify(MIN_CPUS * 3u / 2u) + ";"
- "mem:" + stringify((MIN_MEM / 2u).megabytes()) + ";"
+ "mem:" + stringify(
+ (double) (MIN_MEM / 2u).bytes() / Bytes::MEGABYTES) + ";"
"cpus(role1):" + stringify(MIN_CPUS * 3u / 2u) + ";"
- "mem(role1):" + stringify((MIN_MEM / 2u).megabytes()) + ";"
+ "mem(role1):" + stringify(
+ (double) (MIN_MEM / 2u).bytes() / Bytes::MEGABYTES) + ";"
"disk:128");
allocator->addSlave(
slave4.id(),
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/tests/mesos.hpp
----------------------------------------------------------------------
diff --git a/src/tests/mesos.hpp b/src/tests/mesos.hpp
index 5e833a1..93913f2 100644
--- a/src/tests/mesos.hpp
+++ b/src/tests/mesos.hpp
@@ -1138,8 +1138,10 @@ inline TResource createPersistentVolume(
const Option<std::string>& creatorPrincipal = None(),
bool isShared = false)
{
- TResource volume =
- TResources::parse("disk", stringify(size.megabytes()), role).get();
+ TResource volume = TResources::parse(
+ "disk",
+ stringify((double) size.bytes() / Bytes::MEGABYTES),
+ role).get();
volume.mutable_disk()->CopyFrom(
createDiskInfo<TResource, TVolume>(
http://git-wip-us.apache.org/repos/asf/mesos/blob/866d4c8d/src/tests/persistent_volume_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/persistent_volume_tests.cpp b/src/tests/persistent_volume_tests.cpp
index 5962dd1..372037f 100644
--- a/src/tests/persistent_volume_tests.cpp
+++ b/src/tests/persistent_volume_tests.cpp
@@ -260,7 +260,7 @@ protected:
switch (::testing::get<0>(GetParam())) {
case NONE: {
diskResource = createDiskResource(
- stringify(mb.megabytes()),
+ stringify((double) mb.bytes() / Bytes::MEGABYTES),
DEFAULT_TEST_ROLE,
None(),
None());
@@ -269,7 +269,7 @@ protected:
}
case PATH: {
diskResource = createDiskResource(
- stringify(mb.megabytes()),
+ stringify((double) mb.bytes() / Bytes::MEGABYTES),
DEFAULT_TEST_ROLE,
None(),
None(),
@@ -279,7 +279,7 @@ protected:
}
case MOUNT: {
diskResource = createDiskResource(
- stringify(mb.megabytes()),
+ stringify((double) mb.bytes() / Bytes::MEGABYTES),
DEFAULT_TEST_ROLE,
None(),
None(),
[4/4] mesos git commit: Fixed compilation for python eggs when gRPC
is enabled.
Posted by ji...@apache.org.
Fixed compilation for python eggs when gRPC is enabled.
Review: https://reviews.apache.org/r/64763/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/63f116a5
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/63f116a5
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/63f116a5
Branch: refs/heads/master
Commit: 63f116a54e4a67d08535d9ddd03f1343ec0181a1
Parents: 1a365b7
Author: Chun-Hung Hsiao <ch...@mesosphere.io>
Authored: Thu Dec 21 11:03:41 2017 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Thu Dec 21 11:03:41 2017 -0800
----------------------------------------------------------------------
src/python/native_common/ext_modules.py.in | 28 +++++++++++++++++++++++++
1 file changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/63f116a5/src/python/native_common/ext_modules.py.in
----------------------------------------------------------------------
diff --git a/src/python/native_common/ext_modules.py.in b/src/python/native_common/ext_modules.py.in
index 47c2d24..cc4c6a4 100644
--- a/src/python/native_common/ext_modules.py.in
+++ b/src/python/native_common/ext_modules.py.in
@@ -124,6 +124,34 @@ def _create_module(module_name):
if os.path.exists(libprofiler):
EXTRA_OBJECTS.append(libprofiler)
+
+ # We need to check for the presense of libgrpc++.a, libgrpc.a and libgpr.a
+ # only if gRPC is enabled.
+ if '@ENABLE_GRPC_FALSE@' == '#':
+ grpc = os.path.join('3rdparty', 'grpc-1.4.2')
+ libgrpcxx = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 'libgrpc++.a')
+ libgrpc = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 'libgrpc.a')
+ libgpr = os.path.join(abs_top_builddir, grpc, 'libs', 'opt', 'libgpr.a')
+
+ if os.path.exists(libgrpcxx):
+ EXTRA_OBJECTS.append(libgrpcxx)
+ else:
+ EXTRA_OBJECTS.append('-lgrpc++')
+
+ if os.path.exists(libgrpc):
+ EXTRA_OBJECTS.append(libgrpc)
+ else:
+ EXTRA_OBJECTS.append('-lgrpc')
+
+ if os.path.exists(libgpr):
+ EXTRA_OBJECTS.append(libgpr)
+ else:
+ EXTRA_OBJECTS.append('-lgpr')
+
+ EXTRA_OBJECTS.append('-lssl')
+ EXTRA_OBJECTS.append('-lcrypto')
+
+
# OSX uses a different linker (llvm-ld) and doesn't support --as-needed
# TODO(SteveNiemitz): Feature detect --as-needed instead of looking at
# sys.platform.