You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2016/07/21 20:43:37 UTC
[1/6] mesos git commit: Fixed a length argument bug when reading file.
Repository: mesos
Updated Branches:
refs/heads/master 19bfd8984 -> f69a27c43
Fixed a length argument bug when reading file.
If length provided by client is bigger than
(size - offset), the data returned by Read
File API should only contain data actually
read from the file. However, a length long string
was being returned which may contain blank characters.
This patch addresses that by limiting the length to
be the number of bytes read from `io::read()`.
Review: https://reviews.apache.org/r/50184/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b3d57a8c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b3d57a8c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b3d57a8c
Branch: refs/heads/master
Commit: b3d57a8cdfb015f5c46a0fa146bd0dd0295db72f
Parents: 19bfd89
Author: zhou xing <xi...@cn.ibm.com>
Authored: Thu Jul 21 13:24:50 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:24:50 2016 -0700
----------------------------------------------------------------------
src/files/files.cpp | 5 ++--
src/tests/api_tests.cpp | 58 +++++++++++++++++++++++++++++++++++++++-----
2 files changed, 55 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b3d57a8c/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index 8ab8f8a..b88e34e 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -684,8 +684,9 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
boost::shared_array<char> data(new char[length.get()]);
return io::read(fd.get(), data.get(), length.get())
- .then([size, data, length]() -> Try<tuple<size_t, string>, FilesError> {
- return std::make_tuple(size, string(data.get(), length.get()));
+ .then([size, data](const size_t dataLength)
+ -> Try<tuple<size_t, string>, FilesError> {
+ return std::make_tuple(size, string(data.get(), dataLength));
});
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/b3d57a8c/src/tests/api_tests.cpp
----------------------------------------------------------------------
diff --git a/src/tests/api_tests.cpp b/src/tests/api_tests.cpp
index e8e4f57..88523fd 100644
--- a/src/tests/api_tests.cpp
+++ b/src/tests/api_tests.cpp
@@ -1999,7 +1999,7 @@ TEST_P(MasterAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::master::Response> v1Response =
- post(master.get()->pid, v1Call, contentType);
+ post(master.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2022,7 +2022,7 @@ TEST_P(MasterAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::master::Response> v1Response =
- post(master.get()->pid, v1Call, contentType);
+ post(master.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2044,7 +2044,7 @@ TEST_P(MasterAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::master::Response> v1Response =
- post(master.get()->pid, v1Call, contentType);
+ post(master.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2054,6 +2054,29 @@ TEST_P(MasterAPITest, ReadFile)
ASSERT_EQ("body", v1Response.get().read_file().data());
ASSERT_EQ(4, v1Response.get().read_file().size());
}
+
+ // Read the file with `length > size - offset`. This should return the
+ // data actually read.
+ {
+ v1::master::Call v1Call;
+ v1Call.set_type(v1::master::Call::READ_FILE);
+
+ v1::master::Call::ReadFile* readFile = v1Call.mutable_read_file();
+ readFile->set_offset(1);
+ readFile->set_length(6);
+ readFile->set_path("myname");
+
+ Future<v1::master::Response> v1Response =
+ post(master.get()->pid, v1Call, contentType);
+
+ AWAIT_READY(v1Response);
+
+ ASSERT_TRUE(v1Response.get().IsInitialized());
+ ASSERT_EQ(v1::master::Response::READ_FILE, v1Response.get().type());
+
+ ASSERT_EQ("ody", v1Response.get().read_file().data());
+ ASSERT_EQ(4, v1Response.get().read_file().size());
+ }
}
@@ -2567,7 +2590,7 @@ TEST_P(AgentAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::agent::Response> v1Response =
- post(slave.get()->pid, v1Call, contentType);
+ post(slave.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2590,7 +2613,7 @@ TEST_P(AgentAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::agent::Response> v1Response =
- post(slave.get()->pid, v1Call, contentType);
+ post(slave.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2612,7 +2635,7 @@ TEST_P(AgentAPITest, ReadFile)
readFile->set_path("myname");
Future<v1::agent::Response> v1Response =
- post(slave.get()->pid, v1Call, contentType);
+ post(slave.get()->pid, v1Call, contentType);
AWAIT_READY(v1Response);
@@ -2622,6 +2645,29 @@ TEST_P(AgentAPITest, ReadFile)
ASSERT_EQ("body", v1Response.get().read_file().data());
ASSERT_EQ(4, v1Response.get().read_file().size());
}
+
+ // Read the file with `length > size - offset`. This should return the
+ // data actually read.
+ {
+ v1::agent::Call v1Call;
+ v1Call.set_type(v1::agent::Call::READ_FILE);
+
+ v1::agent::Call::ReadFile* readFile = v1Call.mutable_read_file();
+ readFile->set_offset(1);
+ readFile->set_length(6);
+ readFile->set_path("myname");
+
+ Future<v1::agent::Response> v1Response =
+ post(slave.get()->pid, v1Call, contentType);
+
+ AWAIT_READY(v1Response);
+
+ ASSERT_TRUE(v1Response.get().IsInitialized());
+ ASSERT_EQ(v1::agent::Response::READ_FILE, v1Response.get().type());
+
+ ASSERT_EQ("ody", v1Response.get().read_file().data());
+ ASSERT_EQ(4, v1Response.get().read_file().size());
+ }
}
[6/6] mesos git commit: Added logging when `Offer::Operation::Launch`
has no tasks.
Posted by an...@apache.org.
Added logging when `Offer::Operation::Launch` has no tasks.
Added a implict decline warning message when an offer is accepted
by a framework without specifying any task to be launched.
Review: https://reviews.apache.org/r/49239/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f69a27c4
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f69a27c4
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f69a27c4
Branch: refs/heads/master
Commit: f69a27c43eaf9ade386819dd707ce33041ee1f20
Parents: a853cc2
Author: Jose Guilherme Vanz <gu...@gmail.com>
Authored: Thu Jul 21 13:36:16 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:36:16 2016 -0700
----------------------------------------------------------------------
src/master/master.cpp | 3 +++
1 file changed, 3 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/f69a27c4/src/master/master.cpp
----------------------------------------------------------------------
diff --git a/src/master/master.cpp b/src/master/master.cpp
index f2b803d..b87d18f 100644
--- a/src/master/master.cpp
+++ b/src/master/master.cpp
@@ -3378,6 +3378,9 @@ void Master::accept(
++metrics->messages_launch_tasks;
} else {
++metrics->messages_decline_offers;
+ LOG(WARNING) << "Implicitly declining offers: " << accept.offer_ids()
+ << " in ACCEPT call for framework " << framework->id()
+ << " as the launch operation specified no tasks";
}
}
[4/6] mesos git commit: Added tests for `UUID::fromString()`.
Posted by an...@apache.org.
Added tests for `UUID::fromString()`.
Review: https://reviews.apache.org/r/48693/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/dc002e95
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/dc002e95
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/dc002e95
Branch: refs/heads/master
Commit: dc002e95f05fadd6ac123216216f9c3b096fcd68
Parents: 8edfc79
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Jul 21 13:35:04 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:35:04 2016 -0700
----------------------------------------------------------------------
3rdparty/stout/tests/uuid_tests.cpp | 4 ++++
1 file changed, 4 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/dc002e95/3rdparty/stout/tests/uuid_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/uuid_tests.cpp b/3rdparty/stout/tests/uuid_tests.cpp
index b061b82..8f28fcf 100644
--- a/3rdparty/stout/tests/uuid_tests.cpp
+++ b/3rdparty/stout/tests/uuid_tests.cpp
@@ -48,6 +48,10 @@ TEST(UUIDTest, Test)
EXPECT_EQ(string1, string2);
EXPECT_EQ(string2, string3);
EXPECT_EQ(string1, string3);
+
+ EXPECT_EQ(uuid1, UUID::fromString(string1));
+ EXPECT_EQ(uuid2, UUID::fromString(string2));
+ EXPECT_EQ(uuid3, UUID::fromString(string3));
}
[5/6] mesos git commit: Optimized `UUID::fromString()` and
`UUID::toString()` in stout.
Posted by an...@apache.org.
Optimized `UUID::fromString()` and `UUID::toString()` in stout.
Rather than using `std::istringstream` and `std::ostringstream`,
instead use the facilities provided by Boost's UUID for input
and output respectively. This improves a simple benchmark that
uses `fromString()` and `toString()` by ~7x.
Review: https://reviews.apache.org/r/48694/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a853cc23
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a853cc23
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a853cc23
Branch: refs/heads/master
Commit: a853cc238757066b16090f571c54e4a114a6db69
Parents: dc002e9
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Jul 21 13:35:17 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:35:17 2016 -0700
----------------------------------------------------------------------
3rdparty/stout/include/stout/uuid.hpp | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/a853cc23/3rdparty/stout/include/stout/uuid.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/uuid.hpp b/3rdparty/stout/include/stout/uuid.hpp
index a384022..e638d45 100644
--- a/3rdparty/stout/include/stout/uuid.hpp
+++ b/3rdparty/stout/include/stout/uuid.hpp
@@ -15,10 +15,10 @@
#include <assert.h>
-#include <sstream>
#include <string>
#include <boost/uuid/random_generator.hpp>
+#include <boost/uuid/string_generator.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_io.hpp>
@@ -71,9 +71,11 @@ public:
static UUID fromString(const std::string& s)
{
- boost::uuids::uuid uuid;
- std::istringstream in(s);
- in >> uuid;
+ // NOTE: We don't use THREAD_LOCAL for the `string_generator`
+ // (unlike for the `random_generator` above), because it is cheap
+ // to construct one each time.
+ boost::uuids::string_generator gen;
+ boost::uuids::uuid uuid = gen(s);
return UUID(uuid);
}
@@ -85,9 +87,7 @@ public:
std::string toString() const
{
- std::ostringstream out;
- out << *this;
- return out.str();
+ return to_string(*this);
}
private:
[3/6] mesos git commit: Cleaned up header includes in stout/uuid.
Posted by an...@apache.org.
Cleaned up header includes in stout/uuid.
Review: https://reviews.apache.org/r/48692/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8edfc79c
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8edfc79c
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8edfc79c
Branch: refs/heads/master
Commit: 8edfc79c43ceb55d54b756c6d690215fa7a0276a
Parents: 8476cf1
Author: Neil Conway <ne...@gmail.com>
Authored: Thu Jul 21 13:34:52 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:34:52 2016 -0700
----------------------------------------------------------------------
3rdparty/stout/include/stout/uuid.hpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8edfc79c/3rdparty/stout/include/stout/uuid.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/uuid.hpp b/3rdparty/stout/include/stout/uuid.hpp
index a57896c..a384022 100644
--- a/3rdparty/stout/include/stout/uuid.hpp
+++ b/3rdparty/stout/include/stout/uuid.hpp
@@ -18,8 +18,8 @@
#include <sstream>
#include <string>
+#include <boost/uuid/random_generator.hpp>
#include <boost/uuid/uuid.hpp>
-#include <boost/uuid/uuid_generators.hpp>
#include <boost/uuid/uuid_io.hpp>
#include <stout/error.hpp>
[2/6] mesos git commit: Fixed a file descriptor leak while reading
file.
Posted by an...@apache.org.
Fixed a file descriptor leak while reading file.
There were two early returns without closing the file
in code common to the `ReadFile` operation in the v1
Operator API and the `/files/read` endpoint.
Review: https://reviews.apache.org/r/50208/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8476cf1e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8476cf1e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8476cf1e
Branch: refs/heads/master
Commit: 8476cf1e58b6fa2160e3bb109e538fb9d94ccc58
Parents: b3d57a8
Author: zhou xing <xi...@cn.ibm.com>
Authored: Thu Jul 21 13:31:14 2016 -0700
Committer: Anand Mazumdar <an...@apache.org>
Committed: Thu Jul 21 13:31:14 2016 -0700
----------------------------------------------------------------------
src/files/files.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/8476cf1e/src/files/files.cpp
----------------------------------------------------------------------
diff --git a/src/files/files.cpp b/src/files/files.cpp
index b88e34e..793d68e 100644
--- a/src/files/files.cpp
+++ b/src/files/files.cpp
@@ -653,6 +653,7 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
// Return the size of file if length is 0.
if (length == 0) {
+ os::close(fd.get());
return std::make_tuple(size, "");
}
@@ -687,7 +688,8 @@ Future<Try<tuple<size_t, string>, FilesError>> FilesProcess::_read(
.then([size, data](const size_t dataLength)
-> Try<tuple<size_t, string>, FilesError> {
return std::make_tuple(size, string(data.get(), dataLength));
- });
+ })
+ .onAny([fd]() { os::close(fd.get()); });
}