You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by qi...@apache.org on 2019/04/12 02:09:36 UTC
[mesos] 01/04: Added an optional parameter `outputFileName` to the
fetcher interface.
This is an automated email from the ASF dual-hosted git repository.
qianzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 27b238dc44527cf30815d53579c928052f35add8
Author: Qian Zhang <zh...@gmail.com>
AuthorDate: Wed Apr 10 11:00:48 2019 +0800
Added an optional parameter `outputFileName` to the fetcher interface.
Review: https://reviews.apache.org/r/70443
---
include/mesos/uri/fetcher.hpp | 8 ++++++--
src/tests/uri_fetcher_tests.cpp | 8 ++++----
src/uri/fetcher.cpp | 6 ++++--
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/include/mesos/uri/fetcher.hpp b/include/mesos/uri/fetcher.hpp
index 760d6b3..645995a 100644
--- a/include/mesos/uri/fetcher.hpp
+++ b/include/mesos/uri/fetcher.hpp
@@ -95,12 +95,14 @@ public:
* @param uri the URI to fetch
* @param directory the directory the URI will be downloaded to
* @param data the optional user defined data
+ * @param outputFileName the optional output file name
*/
// TODO(jieyu): Consider using 'Path' for 'directory' here.
process::Future<Nothing> fetch(
const URI& uri,
const std::string& directory,
- const Option<std::string>& data = None()) const;
+ const Option<std::string>& data = None(),
+ const Option<std::string>& outputFileName = None()) const;
/**
* Fetches a URI to the given directory. This method will dispatch
@@ -110,12 +112,14 @@ public:
* @param directory the directory the URI will be downloaded to
* @param name of the plugin that is used to download
* @param data the optional user defined data
+ * @param outputFileName the optional output file name
*/
process::Future<Nothing> fetch(
const URI& uri,
const std::string& directory,
const std::string& name,
- const Option<std::string>& data = None()) const;
+ const Option<std::string>& data = None(),
+ const Option<std::string>& outputFileName = None()) const;
private:
Fetcher(const Fetcher&) = delete; // Not copyable.
diff --git a/src/tests/uri_fetcher_tests.cpp b/src/tests/uri_fetcher_tests.cpp
index bb224d8..8a38e17 100644
--- a/src/tests/uri_fetcher_tests.cpp
+++ b/src/tests/uri_fetcher_tests.cpp
@@ -146,7 +146,7 @@ TEST_F(CurlFetcherPluginTest, CURL_InvokeFetchByName)
Try<Owned<uri::Fetcher>> fetcher = uri::fetcher::create();
ASSERT_SOME(fetcher);
- AWAIT_READY(fetcher.get()->fetch(uri, os::getcwd(), "curl", None()));
+ AWAIT_READY(fetcher.get()->fetch(uri, os::getcwd(), "curl", None(), None()));
EXPECT_TRUE(os::exists(path::join(os::getcwd(), "test")));
}
@@ -266,7 +266,7 @@ TEST_F(HadoopFetcherPluginTest, InvokeFetchByName)
string dir = path::join(os::getcwd(), "dir");
- AWAIT_READY(fetcher.get()->fetch(uri, dir, "hadoop", None()));
+ AWAIT_READY(fetcher.get()->fetch(uri, dir, "hadoop", None(), None()));
EXPECT_SOME_EQ("abc", os::read(path::join(dir, "file")));
}
@@ -379,7 +379,7 @@ TEST_F(DockerFetcherPluginTest, INTERNET_CURL_InvokeFetchByName)
string dir = path::join(os::getcwd(), "dir");
AWAIT_READY_FOR(
- fetcher.get()->fetch(uri, dir, "docker", None()),
+ fetcher.get()->fetch(uri, dir, "docker", None(), None()),
Seconds(60));
Try<string> _manifest = os::read(path::join(dir, "manifest"));
@@ -462,7 +462,7 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(CopyFetcherPluginTest, InvokeFetchByName)
const string dir = path::join(os::getcwd(), "dir");
- AWAIT_READY(fetcher.get()->fetch(uri, dir, "copy", None()));
+ AWAIT_READY(fetcher.get()->fetch(uri, dir, "copy", None(), None()));
// Validate the fetched file's content.
EXPECT_SOME_EQ("abc", os::read(path::join(dir, "file")));
diff --git a/src/uri/fetcher.cpp b/src/uri/fetcher.cpp
index 3147e41..62a33c4 100644
--- a/src/uri/fetcher.cpp
+++ b/src/uri/fetcher.cpp
@@ -103,7 +103,8 @@ Fetcher::Fetcher(const vector<Owned<Plugin>>& plugins)
Future<Nothing> Fetcher::fetch(
const URI& uri,
const string& directory,
- const Option<string>& data) const
+ const Option<string>& data,
+ const Option<string>& outputFileName) const
{
if (!pluginsByScheme.contains(uri.scheme())) {
return Failure("Scheme '" + uri.scheme() + "' is not supported");
@@ -117,7 +118,8 @@ Future<Nothing> Fetcher::fetch(
const URI& uri,
const string& directory,
const string& name,
- const Option<string>& data) const
+ const Option<string>& data,
+ const Option<string>& outputFileName) const
{
if (!pluginsByName.contains(name)) {
return Failure("Plugin '" + name + "' is not registered.");