Skip to content

Commit 947ffce

Browse files
harshith-212shubhluck
authored andcommitted
Revert "HDFS-14267. Add test_libhdfs_ops to libhdfs tests, mark libhdfs_read/write.c as examples. Contributed by Sahil Takiar."
This reverts commit d1664a7.
1 parent b2cb6b9 commit 947ffce

File tree

7 files changed

+20
-97
lines changed

7 files changed

+20
-97
lines changed

hadoop-hdfs-project/hadoop-hdfs-native-client/src/CMakeLists.txt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,11 @@ if(WIN32)
5858
# Omit unneeded headers.
5959
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWIN32_LEAN_AND_MEAN")
6060
set(OS_DIR ${CMAKE_SOURCE_DIR}/main/native/libhdfs/os/windows)
61-
62-
# IMPORTANT: OUT_DIR MUST be relative to maven's
63-
# project.build.directory (=target) and match dist-copynativelibs
64-
# in order to be in a release
65-
set(OUT_DIR bin)
61+
set(OUT_DIR target/bin)
6662
else()
6763
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden")
68-
# using old default behavior on GCC >= 10.0
69-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcommon")
7064
set(OS_DIR ${CMAKE_SOURCE_DIR}/main/native/libhdfs/os/posix)
71-
72-
# IMPORTANT: OUT_DIR MUST be relative to maven's
73-
# project.build.directory (=target) and match dist-copynativelibs
74-
# in order to be in a release
75-
set(OUT_DIR native/target/usr/local/lib)
65+
set(OUT_DIR target/usr/local/lib)
7666
endif()
7767

7868
# Configure JNI.
@@ -148,7 +138,6 @@ endif()
148138

149139
add_subdirectory(main/native/libhdfs)
150140
add_subdirectory(main/native/libhdfs-tests)
151-
add_subdirectory(main/native/libhdfs-examples)
152141

153142
# Temporary fix to disable Libhdfs++ build on older systems that do not support thread_local
154143
include(CheckCXXSourceCompiles)
@@ -192,4 +181,4 @@ else()
192181
if(REQUIRE_FUSE)
193182
message(FATAL_ERROR "Required component fuse_dfs could not be built.")
194183
endif()
195-
endif()
184+
endif()

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-examples/CMakeLists.txt

Lines changed: 0 additions & 34 deletions
This file was deleted.

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs-examples/README.md

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,11 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "hdfs/hdfs.h"
19+
#include "hdfs/hdfs.h"
2020

2121
#include <stdio.h>
2222
#include <stdlib.h>
2323

24-
/**
25-
* An example of using libhdfs to read files. The usage of this file is as follows:
26-
*
27-
* Usage: hdfs_read <filename> <filesize> <buffersize>
28-
*/
2924
int main(int argc, char **argv) {
3025
hdfsFS fs;
3126
const char *rfile = argv[1];
@@ -38,12 +33,12 @@ int main(int argc, char **argv) {
3833
fprintf(stderr, "Usage: hdfs_read <filename> <filesize> <buffersize>\n");
3934
exit(-1);
4035
}
41-
36+
4237
fs = hdfsConnect("default", 0);
4338
if (!fs) {
4439
fprintf(stderr, "Oops! Failed to connect to hdfs!\n");
4540
exit(-1);
46-
}
41+
}
4742

4843
readFile = hdfsOpenFile(fs, rfile, O_RDONLY, bufferSize, 0, 0);
4944
if (!readFile) {
@@ -56,13 +51,13 @@ int main(int argc, char **argv) {
5651
if(buffer == NULL) {
5752
return -2;
5853
}
59-
54+
6055
// read from the file
6156
curSize = bufferSize;
6257
for (; curSize == bufferSize;) {
6358
curSize = hdfsRead(fs, readFile, (void*)buffer, curSize);
6459
}
65-
60+
6661

6762
free(buffer);
6863
hdfsCloseFile(fs, readFile);
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,13 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "hdfs/hdfs.h"
19+
#include "hdfs/hdfs.h"
2020

2121
#include <limits.h>
2222
#include <stdio.h>
2323
#include <stdlib.h>
2424
#include <sys/types.h>
2525

26-
/**
27-
* An example of using libhdfs to write files. The usage of this file is as follows:
28-
*
29-
* Usage: hdfs_write <filename> <filesize> <buffersize>
30-
*/
3126
int main(int argc, char **argv) {
3227
hdfsFS fs;
3328
const char *writeFileName = argv[1];
@@ -45,12 +40,12 @@ int main(int argc, char **argv) {
4540
fprintf(stderr, "Usage: hdfs_write <filename> <filesize> <buffersize>\n");
4641
exit(-1);
4742
}
48-
43+
4944
fs = hdfsConnect("default", 0);
5045
if (!fs) {
5146
fprintf(stderr, "Oops! Failed to connect to hdfs!\n");
5247
exit(-1);
53-
}
48+
}
5449

5550
// sanity check
5651
if(fileTotalSize == ULONG_MAX && errno == ERANGE) {
@@ -84,7 +79,7 @@ int main(int argc, char **argv) {
8479

8580
// write to the file
8681
for (nrRemaining = fileTotalSize; nrRemaining > 0; nrRemaining -= bufferSize ) {
87-
curSize = ( bufferSize < nrRemaining ) ? bufferSize : (tSize)nrRemaining;
82+
curSize = ( bufferSize < nrRemaining ) ? bufferSize : (tSize)nrRemaining;
8883
if ((written = hdfsWrite(fs, writeFile, (void*)buffer, curSize)) != curSize) {
8984
fprintf(stderr, "ERROR: hdfsWrite returned an error on write: %d\n", written);
9085
exit(-3);

hadoop-hdfs-project/hadoop-hdfs-native-client/src/main/native/libhdfs/CMakeLists.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ set_target_properties(hdfs PROPERTIES
5555
SOVERSION ${LIBHDFS_VERSION})
5656

5757
build_libhdfs_test(test_libhdfs_ops hdfs_static test_libhdfs_ops.c)
58-
link_libhdfs_test(test_libhdfs_ops hdfs_static native_mini_dfs ${JAVA_JVM_LIBRARY})
59-
add_libhdfs_test(test_libhdfs_ops hdfs_static)
60-
58+
link_libhdfs_test(test_libhdfs_ops hdfs_static ${JAVA_JVM_LIBRARY})
59+
build_libhdfs_test(test_libhdfs_reads hdfs_static test_libhdfs_read.c)
60+
link_libhdfs_test(test_libhdfs_reads hdfs_static ${JAVA_JVM_LIBRARY})
61+
build_libhdfs_test(test_libhdfs_write hdfs_static test_libhdfs_write.c)
62+
link_libhdfs_test(test_libhdfs_write hdfs_static ${JAVA_JVM_LIBRARY})
6163
build_libhdfs_test(test_libhdfs_threaded hdfs_static expect.c test_libhdfs_threaded.c ${OS_DIR}/thread.c)
6264
link_libhdfs_test(test_libhdfs_threaded hdfs_static native_mini_dfs)
6365
add_libhdfs_test(test_libhdfs_threaded hdfs_static)
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ $HADOOP_HOME/share/hadoop/common/
7070
$HADOOP_HOME/share/hadoop/hdfs
7171
$HADOOP_HOME/share/hadoop/hdfs/lib/"
7272

73-
for d in $JAR_DIRS; do
73+
for d in $JAR_DIRS; do
7474
for j in $d/*.jar; do
7575
CLASSPATH=${CLASSPATH}:$j
7676
done;
@@ -114,14 +114,14 @@ LIB_JVM_DIR=`findlibjvm`
114114
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
115115
echo LIB_JVM_DIR = $LIB_JVM_DIR
116116
echo "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
117-
# Put delays to ensure hdfs is up and running and also shuts down
117+
# Put delays to ensure hdfs is up and running and also shuts down
118118
# after the tests are complete
119119
rm $HDFS_TEST_CONF_DIR/core-site.xml
120120

121121
$HADOOP_HOME/bin/hadoop jar $HDFS_TEST_JAR \
122122
org.apache.hadoop.test.MiniDFSClusterManager \
123123
-format -nnport 20300 -writeConfig $HDFS_TEST_CONF_DIR/core-site.xml \
124-
> /tmp/libhdfs-test-cluster.out 2>&1 &
124+
> /tmp/libhdfs-test-cluster.out 2>&1 &
125125

126126
MINI_CLUSTER_PID=$!
127127
for i in {1..15}; do

0 commit comments

Comments
 (0)