Browse Source

HADOOP-10577. Native Hadoop Client: Fix some minor error and compile on macosx (Binglin Chang)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HADOOP-10388@1593181 13f79535-47bb-0310-9956-ffa450edef68
Binglin Chang 11 years ago
parent
commit
15b635343e

+ 2 - 2
hadoop-native-core/CMakeLists.txt

@@ -31,9 +31,9 @@ if (NOT (PROTOBUFC_LIB AND PROTOBUFC_EXE))
 endif()
 endif()
 
 
 # Find protobuf
 # Find protobuf
-find_library(PROTOC_LIB NAMES libprotoc.so
+find_library(PROTOC_LIB NAMES protoc
     HINTS /usr/lib /usr/lib64)
     HINTS /usr/lib /usr/lib64)
-find_library(PROTOBUF_LIB NAMES libprotobuf.so
+find_library(PROTOBUF_LIB NAMES protobuf
     HINTS /usr/lib /usr/lib64)
     HINTS /usr/lib /usr/lib64)
 find_program(PROTOC_EXE NAMES protoc)
 find_program(PROTOC_EXE NAMES protoc)
 find_path(PROTOC_HEADER_PATH NAMES 
 find_path(PROTOC_HEADER_PATH NAMES 

+ 7 - 6
hadoop-native-core/hdfs/namenode-rpc-unit.c

@@ -68,13 +68,12 @@ void set_replication_cb(SetReplicationResponseProto *resp,
     if (err) {
     if (err) {
         fprintf(stderr, "set_replication_cb: got an error.  %s\n",
         fprintf(stderr, "set_replication_cb: got an error.  %s\n",
                 hadoop_err_msg(err));
                 hadoop_err_msg(err));
-        goto done;
+    } else {
+        fprintf(stderr, "set_replication_cb: resp->result = %d\n",
+                !!resp->result);
     }
     }
-    fprintf(stderr, "set_replication_cb: resp->result = %d\n",
-            !!resp->result);
 
 
-done:
-    sem_post(sem);
+    uv_sem_post(sem);
     if (err) {
     if (err) {
         hadoop_err_free(err);
         hadoop_err_free(err);
     }
     }
@@ -83,6 +82,8 @@ done:
     }
     }
 }
 }
 
 
+
+
 int main(void)
 int main(void)
 {
 {
     struct hrpc_messenger_builder *msgr_bld;
     struct hrpc_messenger_builder *msgr_bld;
@@ -110,7 +111,7 @@ int main(void)
         req.replication = 2;
         req.replication = 2;
         cnn_async_set_replication(proxy, &req, set_replication_cb, &sem);
         cnn_async_set_replication(proxy, &req, set_replication_cb, &sem);
     }
     }
-    sem_wait(&sem);
+    uv_sem_wait(&sem);
 
 
     hrpc_proxy_free(proxy);
     hrpc_proxy_free(proxy);
     hrpc_messenger_shutdown(msgr);
     hrpc_messenger_shutdown(msgr);

+ 10 - 1
hadoop-native-core/rpc/protoc-gen-hrpc.cc

@@ -23,7 +23,13 @@
 #include <google/protobuf/io/printer.h>
 #include <google/protobuf/io/printer.h>
 #include <google/protobuf/io/zero_copy_stream.h>
 #include <google/protobuf/io/zero_copy_stream.h>
 #include <google/protobuf/stubs/common.h>
 #include <google/protobuf/stubs/common.h>
+
+#include <cstddef>
+#ifdef _LIBCPP_VERSION
+#include <memory>
+#else
 #include <tr1/memory>
 #include <tr1/memory>
+#endif
 
 
 #include <iostream>
 #include <iostream>
 #include <map>
 #include <map>
@@ -58,8 +64,11 @@ using google::protobuf::compiler::GeneratorContext;
 using google::protobuf::io::Printer;
 using google::protobuf::io::Printer;
 using std::map;
 using std::map;
 using std::string;
 using std::string;
+#ifdef _LIBCPP_VERSION
+using std::shared_ptr;
+#else
 using std::tr1::shared_ptr;
 using std::tr1::shared_ptr;
-
+#endif
 typedef map<string, string> string_map_t;
 typedef map<string, string> string_map_t;
 
 
 static string camel_case_to_uscore(const string &in)
 static string camel_case_to_uscore(const string &in)

+ 2 - 2
hadoop-native-core/rpc/shorten.c

@@ -63,13 +63,13 @@ static void add_word(char ***words, size_t *num_words, const char *word)
     new_num_words = *num_words + 1;
     new_num_words = *num_words + 1;
     nword = strdup(word);
     nword = strdup(word);
     if (!nword) {
     if (!nword) {
-        fprintf(stderr, "failed to allocate memory for %Zd words\n",
+        fprintf(stderr, "failed to allocate memory for %zu words\n",
                 new_num_words);
                 new_num_words);
         exit(1);
         exit(1);
     }
     }
     nwords = realloc(*words, sizeof(char **) * new_num_words);
     nwords = realloc(*words, sizeof(char **) * new_num_words);
     if (!nwords) {
     if (!nwords) {
-        fprintf(stderr, "failed to allocate memory for %Zd words\n",
+        fprintf(stderr, "failed to allocate memory for %zu words\n",
                 new_num_words);
                 new_num_words);
         free(nword);
         free(nword);
         exit(1);
         exit(1);