You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ae...@apache.org on 2018/03/22 22:04:36 UTC
[12/50] [abbrv] hadoop git commit: HDFS-10705: libhdfs++: FileSystem
should have a convenience no-args ctor. Contributed by James Clampffer.
HDFS-10705: libhdfs++: FileSystem should have a convenience no-args ctor. Contributed by James Clampffer.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/9d1c9021
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/9d1c9021
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/9d1c9021
Branch: refs/heads/HDFS-7240
Commit: 9d1c9021591484145d14e889093fb773cc4b0557
Parents: 4f6cb5d
Author: James <jh...@apache.org>
Authored: Wed Sep 7 10:52:29 2016 -0400
Committer: James Clampffer <ja...@hp.com>
Committed: Thu Mar 22 17:19:47 2018 -0400
----------------------------------------------------------------------
.../main/native/libhdfspp/include/hdfspp/hdfspp.h | 17 ++++++++++++-----
.../src/main/native/libhdfspp/lib/fs/filesystem.cc | 15 ++++++++++++++-
2 files changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d1c9021/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfspp.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfspp.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfspp.h
index 4b88fe5..78ad594 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfspp.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfspp.h
@@ -155,18 +155,25 @@ class FileSystem {
* initializes the RPC connections to the NameNode and returns an
* FileSystem object.
*
+ * Note: The FileSystem takes ownership of the IoService passed in the
+ * constructor. The FileSystem destructor will call delete on it.
+ *
* If user_name is blank, the current user will be used for a default.
**/
- static FileSystem * New(
+ static FileSystem *New(
IoService *&io_service, const std::string &user_name, const Options &options);
- virtual void Connect(const std::string &server,
- const std::string &service,
+ /**
+ * Returns a new instance with default user and option, with the default IOService.
+ **/
+ static FileSystem *New();
+
+
+ virtual void Connect(const std::string &server, const std::string &service,
const std::function<void(const Status &, FileSystem *)> &handler) = 0;
/* Synchronous call of Connect */
- virtual Status Connect(const std::string &server,
- const std::string &service) = 0;
+ virtual Status Connect(const std::string &server, const std::string &service) = 0;
/**
http://git-wip-us.apache.org/repos/asf/hadoop/blob/9d1c9021/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc
index d75939f..aa6f4ba 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.cc
@@ -40,6 +40,9 @@ using ::asio::ip::tcp;
static constexpr uint16_t kDefaultPort = 8020;
+// forward declarations
+const std::string get_effective_user_name(const std::string &);
+
uint32_t FileSystem::GetDefaultFindMaxDepth() {
return std::numeric_limits<uint32_t>::max();
}
@@ -72,11 +75,21 @@ Status FileSystem::CheckValidReplication(uint16_t replication) {
* FILESYSTEM BASE CLASS
****************************************************************************/
-FileSystem * FileSystem::New(
+FileSystem *FileSystem::New(
IoService *&io_service, const std::string &user_name, const Options &options) {
return new FileSystemImpl(io_service, user_name, options);
}
+FileSystem *FileSystem::New() {
+ // No, this pointer won't be leaked. The FileSystem takes ownership.
+ IoService *io_service = IoService::New();
+ if(!io_service)
+ return nullptr;
+ std::string user_name = get_effective_user_name("");
+ Options options;
+ return new FileSystemImpl(io_service, user_name, options);
+}
+
/*****************************************************************************
* FILESYSTEM IMPLEMENTATION
****************************************************************************/
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org