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 2015/12/18 23:40:17 UTC
[3/9] mesos git commit: Cleaned up uneccessary JSON parse in local
puller.
Cleaned up uneccessary JSON parse in local puller.
Review: https://reviews.apache.org/r/41194/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/c6d9eb14
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/c6d9eb14
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/c6d9eb14
Branch: refs/heads/master
Commit: c6d9eb14b4b2c1b6d0814d16332e4b17427934f1
Parents: 9f717a9
Author: Gilbert Song <so...@gmail.com>
Authored: Fri Dec 18 14:13:09 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 18 14:29:59 2015 -0800
----------------------------------------------------------------------
.../mesos/provisioner/docker/local_puller.cpp | 37 ++++++++------------
1 file changed, 14 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/c6d9eb14/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp b/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
index f885666..f71b572 100644
--- a/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
+++ b/src/slave/containerizer/mesos/provisioner/docker/local_puller.cpp
@@ -15,6 +15,7 @@
// limitations under the License.
#include <list>
+#include <map>
#include <vector>
#include <glog/logging.h>
@@ -37,6 +38,7 @@
using namespace process;
using std::list;
+using std::map;
using std::pair;
using std::string;
using std::vector;
@@ -46,25 +48,25 @@ namespace internal {
namespace slave {
namespace docker {
-class LocalPullerProcess : public process::Process<LocalPullerProcess>
+class LocalPullerProcess : public Process<LocalPullerProcess>
{
public:
LocalPullerProcess(const Flags& _flags) : flags(_flags) {}
~LocalPullerProcess() {}
- process::Future<list<pair<string, string>>> pull(
+ Future<list<pair<string, string>>> pull(
const Image::Name& name,
const string& directory);
private:
- process::Future<list<pair<string, string>>> putImage(
+ Future<list<pair<string, string>>> putImage(
const Image::Name& name,
- const std::string& directory);
+ const string& directory);
- process::Future<list<pair<string, string>>> putLayers(
- const std::string& directory,
- const std::vector<std::string>& layerIds);
+ Future<list<pair<string, string>>> putLayers(
+ const string& directory,
+ const vector<string>& layerIds);
const Flags flags;
};
@@ -73,14 +75,14 @@ private:
LocalPuller::LocalPuller(const Flags& flags)
{
process = Owned<LocalPullerProcess>(new LocalPullerProcess(flags));
- process::spawn(process.get());
+ spawn(process.get());
}
LocalPuller::~LocalPuller()
{
- process::terminate(process.get());
- process::wait(process.get());
+ terminate(process.get());
+ wait(process.get());
}
@@ -168,7 +170,7 @@ Future<list<pair<string, string>>> LocalPullerProcess::putImage(
const JSON::Object repositoryJson = repositoryValue.get();
// We don't use JSON find here because a tag might contain a '.'.
- std::map<string, JSON::Value>::const_iterator entry =
+ map<string, JSON::Value>::const_iterator entry =
repositoryJson.values.find(name.tag());
if (entry == repositoryJson.values.end()) {
@@ -179,21 +181,10 @@ Future<list<pair<string, string>>> LocalPullerProcess::putImage(
const string layerId = entry->second.as<JSON::String>().value;
- Try<string> manifest =
- os::read(paths::getImageArchiveLayerManifestPath(directory, layerId));
-
- if (manifest.isError()) {
- return Failure("Failed to read manifest: " + manifest.error());
- }
-
- Try<JSON::Object> manifestJson = JSON::parse<JSON::Object>(manifest.get());
- if (manifestJson.isError()) {
- return Failure("Failed to parse manifest: " + manifestJson.error());
- }
-
vector<string> layerIds;
layerIds.push_back(layerId);
Result<string> parentId = getParentId(directory, layerId);
+
while (parentId.isSome()) {
layerIds.insert(layerIds.begin(), parentId.get());
parentId = getParentId(directory, parentId.get());