hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmcc...@apache.org
Subject [1/4] HDFS-7014. Implement input streams and file system functionality (zhwangzw via cmccabe)
Date Fri, 24 Oct 2014 23:21:25 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-6994 4d28f73b5 -> e559ce048


http://git-wip-us.apache.org/repos/asf/hadoop/blob/e559ce04/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.cc
b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.cc
index 1a0a655..9706d6d 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.cc
@@ -16,9 +16,11 @@
  * limitations under the License.
  */
 
+#include "Config.h"
+#include "ConfigImpl.h"
 #include "NamenodeInfo.h"
+#include "StatusInternal.h"
 #include "StringUtil.h"
-#include "XmlConfig.h"
 
 #include <string>
 #include <vector>
@@ -35,25 +37,35 @@ const char *const DFS_NAMENODE_HA = "dfs.ha.namenodes";
 const char *const DFS_NAMENODE_RPC_ADDRESS_KEY = "dfs.namenode.rpc-address";
 const char *const DFS_NAMENODE_HTTP_ADDRESS_KEY = "dfs.namenode.http-address";
 
-std::vector<NamenodeInfo> NamenodeInfo::GetHANamenodeInfo(
-    const std::string & service, const Config & conf) {
-    std::vector<NamenodeInfo> retval;
-    std::string strNameNodes = StringTrim(
-              conf.getString(std::string(DFS_NAMENODE_HA) + "." + service));
-    std::vector<std::string> nns = StringSplit(strNameNodes, ",");
-    retval.resize(nns.size());
-
-    for (size_t i = 0; i < nns.size(); ++i) {
-        std::string dfsRpcAddress = StringTrim(
-              std::string(DFS_NAMENODE_RPC_ADDRESS_KEY) + "." + service + "."
-              + StringTrim(nns[i]));
-        std::string dfsHttpAddress = StringTrim(
-              std::string(DFS_NAMENODE_HTTP_ADDRESS_KEY) + "." + service + "." +
-              StringTrim(nns[i]));
-        retval[i].setRpcAddr(StringTrim(conf.getString(dfsRpcAddress, "")));
-        retval[i].setHttpAddr(StringTrim(conf.getString(dfsHttpAddress, "")));
+Status NamenodeInfo::GetHANamenodeInfo(const std::string &service,
+                                       const Config &c,
+                                       std::vector<NamenodeInfo> *output) {
+    ConfigImpl &conf = *c.impl;
+    CHECK_PARAMETER(NULL != output, EINVAL, "invalid parameter \"output\"");
+
+    try {
+        std::vector<NamenodeInfo> &retval = *output;
+        std::string strNameNodes = StringTrim(
+            conf.getString(std::string(DFS_NAMENODE_HA) + "." + service));
+        std::vector<std::string> nns = StringSplit(strNameNodes, ",");
+        retval.resize(nns.size());
+
+        for (size_t i = 0; i < nns.size(); ++i) {
+            std::string dfsRpcAddress =
+                StringTrim(std::string(DFS_NAMENODE_RPC_ADDRESS_KEY) + "." +
+                           service + "." + StringTrim(nns[i]));
+            std::string dfsHttpAddress =
+                StringTrim(std::string(DFS_NAMENODE_HTTP_ADDRESS_KEY) + "." +
+                           service + "." + StringTrim(nns[i]));
+            retval[i].setRpcAddr(StringTrim(conf.getString(dfsRpcAddress, "")));
+            retval[i].setHttpAddr(
+                StringTrim(conf.getString(dfsHttpAddress, "")));
+        }
+
+    } catch (...) {
+        return CreateStatusFromException(current_exception());
     }
 
-    return retval;
+    return Status::OK();
 }
 }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e559ce04/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.h
b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.h
index f317161..d35218a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.h
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeInfo.h
@@ -19,7 +19,8 @@
 #ifndef _HDFS_LIBHDFS_SERVER_NAMENODEINFO_H_
 #define _HDFS_LIBHDFS_SERVER_NAMENODEINFO_H_
 
-#include "XmlConfig.h"
+#include "Config.h"
+#include "Status.h"
 
 #include <string>
 #include <vector>
@@ -46,14 +47,14 @@ public:
         rpc_addr = rpcAddr;
     }
 
-    static std::vector<NamenodeInfo> GetHANamenodeInfo(
-          const std::string &service, const Config &conf);
+    static Status GetHANamenodeInfo(const std::string &service,
+                                    const Config &conf,
+                                    std::vector<NamenodeInfo> *output);
 
 private:
     std::string rpc_addr;
     std::string http_addr;
 };
-
 }
 
 #endif /* _HDFS_LIBHDFS_SERVER_NAMENODEINFO_H_ */

http://git-wip-us.apache.org/repos/asf/hadoop/blob/e559ce04/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeProxy.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeProxy.h
b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeProxy.h
index 2cbd460..65e1cd7 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeProxy.h
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/contrib/libhdfs3/src/server/NamenodeProxy.h
@@ -24,51 +24,54 @@
 #include "SharedPtr.h"
 #include "Thread.h"
 
+#include <string>
+#include <vector>
+
 namespace hdfs {
 namespace internal {
 
-class NamenodeProxy: public Namenode {
+class NamenodeProxy : public Namenode {
 public:
     NamenodeProxy(const std::vector<NamenodeInfo> &namenodeInfos,
-            const std::string &tokenService,
-            const SessionConfig &c, const RpcAuth &a);
+                  const std::string &tokenService, const SessionConfig &c,
+                  const RpcAuth &a);
     ~NamenodeProxy();
 
 public:
-
     void getBlockLocations(const std::string &src, int64_t offset,
-            int64_t length, LocatedBlocks &lbs);
+                           int64_t length, LocatedBlocks &lbs);
 
     void create(const std::string &src, const Permission &masked,
-            const std::string &clientName, int flag, bool createParent,
-            short replication, int64_t blockSize);
+                const std::string &clientName, int flag, bool createParent,
+                short replication, int64_t blockSize);
 
     shared_ptr<LocatedBlock> append(const std::string &src,
-            const std::string &clientName);
+                                    const std::string &clientName);
 
     bool setReplication(const std::string &src, short replication);
 
     void setPermission(const std::string &src, const Permission &permission);
 
     void setOwner(const std::string &src, const std::string &username,
-            const std::string &groupname);
+                  const std::string &groupname);
 
     void abandonBlock(const ExtendedBlock &b, const std::string &src,
-            const std::string &holder);
+                      const std::string &holder);
 
-    shared_ptr<LocatedBlock> addBlock(const std::string &src,
-            const std::string &clientName, const ExtendedBlock *previous,
-            const std::vector<DatanodeInfo> &excludeNodes);
+    shared_ptr<LocatedBlock> addBlock(
+        const std::string &src, const std::string &clientName,
+        const ExtendedBlock *previous,
+        const std::vector<DatanodeInfo> &excludeNodes);
 
-    shared_ptr<LocatedBlock> getAdditionalDatanode(const std::string &src,
-            const ExtendedBlock &blk,
-            const std::vector<DatanodeInfo> &existings,
-            const std::vector<std::string> &storageIDs,
-            const std::vector<DatanodeInfo> &excludes, int numAdditionalNodes,
-            const std::string &clientName);
+    shared_ptr<LocatedBlock> getAdditionalDatanode(
+        const std::string &src, const ExtendedBlock &blk,
+        const std::vector<DatanodeInfo> &existings,
+        const std::vector<std::string> &storageIDs,
+        const std::vector<DatanodeInfo> &excludes, int numAdditionalNodes,
+        const std::string &clientName);
 
     bool complete(const std::string &src, const std::string &clientName,
-            const ExtendedBlock *last);
+                  const ExtendedBlock *last);
 
     void reportBadBlocks(const std::vector<LocatedBlock> &blocks);
 
@@ -85,10 +88,10 @@ public:
     bool deleteFile(const std::string &src, bool recursive);
 
     bool mkdirs(const std::string &src, const Permission &masked,
-            bool createParent);
+                bool createParent);
 
     bool getListing(const std::string &src, const std::string &startAfter,
-            bool needLocation, std::vector<FileStatus> &dl);
+                    bool needLocation, std::vector<FileStatus> &dl);
 
     void renewLease(const std::string &clientName);
 
@@ -103,24 +106,25 @@ public:
     FileStatus getFileLinkInfo(const std::string &src);
 
     void setQuota(const std::string &path, int64_t namespaceQuota,
-            int64_t diskspaceQuota);
+                  int64_t diskspaceQuota);
 
     void fsync(const std::string &src, const std::string &client);
 
     void setTimes(const std::string &src, int64_t mtime, int64_t atime);
 
     void createSymlink(const std::string &target, const std::string &link,
-            const Permission &dirPerm, bool createParent);
+                       const Permission &dirPerm, bool createParent);
 
     std::string getLinkTarget(const std::string &path);
 
-    shared_ptr<LocatedBlock> updateBlockForPipeline(const ExtendedBlock &block,
-            const std::string &clientName);
+    shared_ptr<LocatedBlock> updateBlockForPipeline(
+        const ExtendedBlock &block, const std::string &clientName);
 
     void updatePipeline(const std::string &clientName,
-            const ExtendedBlock &oldBlock, const ExtendedBlock &newBlock,
-            const std::vector<DatanodeInfo> &newNodes,
-            const std::vector<std::string> &storageIDs);
+                        const ExtendedBlock &oldBlock,
+                        const ExtendedBlock &newBlock,
+                        const std::vector<DatanodeInfo> &newNodes,
+                        const std::vector<std::string> &storageIDs);
 
     Token getDelegationToken(const std::string &renewer);
 
@@ -131,18 +135,18 @@ public:
     void close();
 
 private:
+    NamenodeProxy(const NamenodeProxy &other);
+    NamenodeProxy &operator=(const NamenodeProxy &other);
     shared_ptr<Namenode> getActiveNamenode(uint32_t &oldValue);
     void failoverToNextNamenode(uint32_t oldValue);
 
-private:
     bool enableNamenodeHA;
     int maxNamenodeHARetry;
     mutex mut;
     std::string clusterid;
-    std::vector<shared_ptr<Namenode> > namenodes;
+    std::vector<shared_ptr<Namenode>> namenodes;
     uint32_t currentNamenode;
 };
-
 }
 }
 


Mime
View raw message