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 jh...@apache.org on 2016/11/07 15:42:46 UTC

hadoop git commit: HDFS-11099: libhdfs++: Expose rack id in hdfsDNInfo. Contributed by Xiaowei Zhu.

Repository: hadoop
Updated Branches:
  refs/heads/HDFS-8707 4f3696d7e -> c252ac225


HDFS-11099: libhdfs++: Expose rack id in hdfsDNInfo.  Contributed by Xiaowei Zhu.


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/c252ac22
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/c252ac22
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/c252ac22

Branch: refs/heads/HDFS-8707
Commit: c252ac22560e957f2b5bc0542514f3a7813886d2
Parents: 4f3696d
Author: James <jh...@apache.org>
Authored: Mon Nov 7 10:41:59 2016 -0500
Committer: James <jh...@apache.org>
Committed: Mon Nov 7 10:41:59 2016 -0500

----------------------------------------------------------------------
 .../main/native/libhdfspp/include/hdfspp/block_location.h   | 9 +++++++++
 .../src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h     | 1 +
 .../src/main/native/libhdfspp/lib/bindings/c/hdfs.cc        | 5 +++++
 .../src/main/native/libhdfspp/lib/fs/filesystem.cc          | 2 ++
 .../src/main/native/libhdfspp/tests/hdfs_ext_test.cc        | 1 +
 5 files changed, 18 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/c252ac22/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/block_location.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/block_location.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/block_location.h
index cbe34be..5a03f41 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/block_location.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/block_location.h
@@ -41,6 +41,14 @@ public:
     this->ip_addr = ip_addr;
   }
 
+  std::string getNetworkLocation() const {
+    return network_location;
+  }
+
+  void setNetworkLocation(const std::string & location) {
+    this->network_location = location;
+  }
+
   int getXferPort() const {
     return xfer_port;
   }
@@ -75,6 +83,7 @@ public:
 private:
   std::string hostname;
   std::string ip_addr;
+  std::string network_location;
   int         xfer_port;
   int         info_port;
   int         IPC_port;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c252ac22/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h
index b41857c..72434e6 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/include/hdfspp/hdfs_ext.h
@@ -132,6 +132,7 @@ int hdfsBuilderConfGetLong(struct hdfsBuilder *bld, const char *key, int64_t *va
 struct hdfsDNInfo {
   const char *    ip_address;
   const char *    hostname;
+  const char *    network_location;
   int             xfer_port;
   int             info_port;
   int             IPC_port;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c252ac22/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
index a43d94f..dd7d00c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/bindings/c/hdfs.cc
@@ -1248,6 +1248,10 @@ int hdfsGetBlockLocations(hdfsFS fs, const char *path, struct hdfsBlockLocations
         buf = new char[ppDNInfo.getIPAddr().size() + 1];
         strncpy(buf, ppDNInfo.getIPAddr().c_str(), ppDNInfo.getIPAddr().size() + 1);
         dn_info->ip_address = buf;
+
+        buf = new char[ppDNInfo.getNetworkLocation().size() + 1];
+        strncpy(buf, ppDNInfo.getNetworkLocation().c_str(), ppDNInfo.getNetworkLocation().size() + 1);
+        dn_info->network_location = buf;
       }
     }
 
@@ -1270,6 +1274,7 @@ int hdfsFreeBlockLocations(struct hdfsBlockLocations * blockLocations) {
       auto location = &block->locations[j];
       delete[] location->hostname;
       delete[] location->ip_address;
+      delete[] location->network_location;
     }
   }
   delete[] blockLocations->blocks;

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c252ac22/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 72b30e5..5d5b9f2 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
@@ -354,6 +354,8 @@ BlockLocation LocatedBlockToBlockLocation(const hadoop::hdfs::LocatedBlockProto
         newInfo.setIPCPort(id.ipcport());
     if (id.has_infosecureport())
       newInfo.setInfoSecurePort(id.infosecureport());
+    if (datanode_info.has_location())
+      newInfo.setNetworkLocation(datanode_info.location());
     dn_info.push_back(newInfo);
   }
   result.setDataNodes(dn_info);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/c252ac22/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
index c160f7f..400b97c 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/tests/hdfs_ext_test.cc
@@ -56,6 +56,7 @@ TEST_F(HdfsExtTest, TestGetBlockLocations) {
   EXPECT_EQ(1, blocks->blocks->num_locations);
   EXPECT_NE(nullptr, blocks->blocks->locations->hostname);
   EXPECT_NE(nullptr, blocks->blocks->locations->ip_address);
+  EXPECT_NE(nullptr, blocks->blocks->locations->network_location);
   EXPECT_NE(0, blocks->blocks->locations->xfer_port);
 
   result = hdfsFreeBlockLocations(blocks);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org