hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject hadoop git commit: HDFS-10188. libhdfs++: Implement debug allocators. Contributed by Xiaowei Zhu
Date Fri, 20 May 2016 21:43:32 GMT
Repository: hadoop
Updated Branches:
  refs/heads/HDFS-8707 d187112dc -> efc843e18


HDFS-10188. libhdfs++: Implement debug allocators.  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/efc843e1
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/efc843e1
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/efc843e1

Branch: refs/heads/HDFS-8707
Commit: efc843e189fc8fbd73f1f7a5a66a18b05f3e5646
Parents: d187112
Author: James <jhc@apache.org>
Authored: Fri May 20 17:42:53 2016 -0400
Committer: James <jhc@apache.org>
Committed: Fri May 20 17:42:53 2016 -0400

----------------------------------------------------------------------
 .../native/libhdfspp/lib/common/new_delete.h    | 52 ++++++++++++++++++++
 .../lib/connection/datanodeconnection.h         | 12 +++--
 .../main/native/libhdfspp/lib/fs/filehandle.h   |  2 +
 .../main/native/libhdfspp/lib/fs/filesystem.h   |  3 ++
 .../native/libhdfspp/lib/reader/block_reader.h  |  2 +
 .../main/native/libhdfspp/lib/rpc/rpc_engine.h  |  5 ++
 6 files changed, 71 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/new_delete.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/new_delete.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/new_delete.h
new file mode 100644
index 0000000..48f97ca
--- /dev/null
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/common/new_delete.h
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef COMMON_HDFS_NEW_DELETE_H_
+#define COMMON_HDFS_NEW_DELETE_H_
+
+#include <cstring>
+
+struct mem_struct {
+  size_t mem_size;
+};
+
+#ifndef NDEBUG
+#define MEMCHECKED_CLASS(clazz) \
+static void* operator new(size_t size) { \
+  void* p = ::malloc(size); \
+  return p; \
+} \
+static void* operator new[](size_t size) { \
+  mem_struct* p = (mem_struct*)::malloc(sizeof(mem_struct) + size); \
+  p->mem_size = size; \
+  return (void*)++p; \
+} \
+static void operator delete(void* p) { \
+  ::memset(p, 0, sizeof(clazz)); \
+  ::free(p); \
+} \
+static void operator delete[](void* p) { \
+  mem_struct* header = (mem_struct*)p; \
+  size_t size = (--header)->mem_size; \
+  ::memset(p, 0, size); \
+  ::free(header); \
+}
+#else
+#define MEMCHECKED_CLASS(clazz)
+#endif
+#endif

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/connection/datanodeconnection.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/connection/datanodeconnection.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/connection/datanodeconnection.h
index aa193f3..0ff6fc4 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/connection/datanodeconnection.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/connection/datanodeconnection.h
@@ -24,6 +24,7 @@
 #include "common/libhdfs_events_impl.h"
 #include "common/logging.h"
 #include "common/util.h"
+#include "common/new_delete.h"
 
 #include "asio.hpp"
 
@@ -31,12 +32,13 @@ namespace hdfs {
 
 class DataNodeConnection : public AsyncStream {
 public:
-    std::string uuid_;
-    std::unique_ptr<hadoop::common::TokenProto> token_;
+  MEMCHECKED_CLASS(DataNodeConnection)
+  std::string uuid_;
+  std::unique_ptr<hadoop::common::TokenProto> token_;
 
-    virtual ~DataNodeConnection();
-    virtual void Connect(std::function<void(Status status, std::shared_ptr<DataNodeConnection>
dn)> handler) = 0;
-    virtual void Cancel() = 0;
+  virtual ~DataNodeConnection();
+  virtual void Connect(std::function<void(Status status, std::shared_ptr<DataNodeConnection>
dn)> handler) = 0;
+  virtual void Cancel() = 0;
 };
 
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filehandle.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filehandle.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filehandle.h
index 0fb014b..a99550a 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filehandle.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filehandle.h
@@ -22,6 +22,7 @@
 #include "common/async_stream.h"
 #include "common/cancel_tracker.h"
 #include "common/libhdfs_events_impl.h"
+#include "common/new_delete.h"
 #include "reader/fileinfo.h"
 #include "reader/readergroup.h"
 
@@ -49,6 +50,7 @@ class DataNodeConnection;
  */
 class FileHandleImpl : public FileHandle {
 public:
+  MEMCHECKED_CLASS(FileHandleImpl)
   FileHandleImpl(const std::string & cluster_name,
                  const std::string & path,
                  ::asio::io_service *io_service, const std::string &client_name,

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h
index 24854c0..ca233d1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/fs/filesystem.h
@@ -22,6 +22,7 @@
 #include "common/libhdfs_events_impl.h"
 #include "common/hdfs_public_api.h"
 #include "common/async_stream.h"
+#include "common/new_delete.h"
 #include "hdfspp/hdfspp.h"
 #include "fs/bad_datanode_tracker.h"
 #include "rpc/rpc_engine.h"
@@ -47,6 +48,7 @@ namespace hdfs {
  */
 class NameNodeOperations {
 public:
+  MEMCHECKED_CLASS(NameNodeOperations);
   NameNodeOperations(::asio::io_service *io_service, const Options &options,
             const std::string &client_name, const std::string &user_name,
             const char *protocol_name, int protocol_version) :
@@ -83,6 +85,7 @@ private:
  */
 class FileSystemImpl : public FileSystem {
 public:
+  MEMCHECKED_CLASS(FileSystemImpl)
   FileSystemImpl(IoService *&io_service, const std::string& user_name, const Options
&options);
   ~FileSystemImpl() override;
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/block_reader.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/block_reader.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/block_reader.h
index 3d5ece4..f9794b1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/block_reader.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/reader/block_reader.h
@@ -21,6 +21,7 @@
 #include "hdfspp/status.h"
 #include "common/async_stream.h"
 #include "common/cancel_tracker.h"
+#include "common/new_delete.h"
 #include "datatransfer.pb.h"
 #include "connection/datanodeconnection.h"
 
@@ -67,6 +68,7 @@ struct BlockReaderOptions {
  */
 class BlockReader {
 public:
+  MEMCHECKED_CLASS(BlockReader)
   virtual void AsyncReadBlock(
     const std::string & client_name,
     const hadoop::hdfs::LocatedBlockProto &block, size_t offset,

http://git-wip-us.apache.org/repos/asf/hadoop/blob/efc843e1/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h
b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h
index 8ea6e8d..b35a663 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h
+++ b/hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfspp/lib/rpc/rpc_engine.h
@@ -23,6 +23,7 @@
 
 #include "common/retry_policy.h"
 #include "common/libhdfs_events_impl.h"
+#include "common/new_delete.h"
 
 #include <google/protobuf/message_lite.h>
 #include <google/protobuf/io/coded_stream.h>
@@ -64,6 +65,7 @@ class RpcConnection;
  */
 class Request {
  public:
+  MEMCHECKED_CLASS(Request)
   typedef std::function<void(::google::protobuf::io::CodedInputStream *is,
                              const Status &status)> Handler;
 
@@ -108,6 +110,7 @@ class Request {
  */
 class RpcConnection : public std::enable_shared_from_this<RpcConnection> {
  public:
+  MEMCHECKED_CLASS(RpcConnection)
   RpcConnection(LockFreeRpcEngine *engine);
   virtual ~RpcConnection();
 
@@ -212,6 +215,7 @@ class RpcConnection : public std::enable_shared_from_this<RpcConnection>
{
  */
 class LockFreeRpcEngine {
 public:
+  MEMCHECKED_CLASS(LockFreeRpcEngine)
   /* Enqueues a CommsError without acquiring a lock*/
   virtual void AsyncRpcCommsError(const Status &status,
                       std::shared_ptr<RpcConnection> failedConnection,
@@ -238,6 +242,7 @@ public:
  */
 class RpcEngine : public LockFreeRpcEngine {
  public:
+  MEMCHECKED_CLASS(RpcEngine)
   enum { kRpcVersion = 9 };
   enum {
     kCallIdAuthorizationFailed = -1,


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


Mime
View raw message