Author: tucu
Date: Sat Jun 2 02:34:38 2012
New Revision: 1345421
URL: http://svn.apache.org/viewvc?rev=1345421&view=rev
Log:
HADOOP-8368. Use CMake rather than autotools to build native code (ccccabe via
tucu)
Added:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/config.h.cmake
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.h
Removed:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/.autom4te.cfg
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/Makefile.am
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/acinclude.m4
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/configure.ac
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/lib/Makefile.am
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/Makefile.am
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/Makefile.in
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/configure
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/configure.ac
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.h.in
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Decompressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/org_apache_hadoop_io_compress_snappy.h
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibDecompressor.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/org_apache_hadoop_io_compress_zlib.h
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCrc32.c
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org_apache_hadoop.h
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.c
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
(original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Sat Jun
2 02:34:38 2012
@@ -226,6 +226,8 @@ Release 2.0.1-alpha - UNRELEASED
HADOOP-8358. Config-related WARN for dfs.web.ugi can be avoided. (harsh)
+ HADOOP-8368. Use CMake rather than autotools to build native code (ccccabe
via tucu)
+
BUG FIXES
HADOOP-8372. NetUtils.normalizeHostName() incorrectly handles hostname
Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/pom.xml Sat Jun 2
02:34:38 2012
@@ -536,32 +536,11 @@
<snappy.prefix>/usr/local</snappy.prefix>
<snappy.lib>${snappy.prefix}/lib</snappy.lib>
<snappy.include>${snappy.prefix}/include</snappy.include>
+ <runas.home></runas.home>
</properties>
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>compile</id>
- <phase>compile</phase>
- <goals>
- <goal>run</goal>
- </goals>
- <configuration>
- <target>
- <mkdir dir="${project.build.directory}/native/javah"/>
- <copy toDir="${project.build.directory}/native">
- <fileset dir="${basedir}/src/main/native"/>
- </copy>
- <mkdir dir="${project.build.directory}/native/m4"/>
- </target>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>native-maven-plugin</artifactId>
<executions>
@@ -590,73 +569,27 @@
</executions>
</plugin>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>make-maven-plugin</artifactId>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
- <id>compile</id>
+ <id>make</id>
<phase>compile</phase>
- <goals>
- <goal>autoreconf</goal>
- <goal>configure</goal>
- <goal>make-install</goal>
- </goals>
+ <goals><goal>run</goal></goals>
+ <configuration>
+ <target>
+ <exec executable="cmake"
dir="${project.build.directory}/native" failonerror="true">
+ <arg line="${basedir}/src/
-DGENERATED_JAVAH=${project.build.directory}/native/javah
-DHADOOP_RUNAS_HOME=${runas.home}
-DJVM_ARCH_DATA_MODEL=${sun.arch.data.model}"/>
+ <env key="CFLAGS" value="-I${snappy.include}"/>
+ <env key="LDFLAGS" value="-L${snappy.lib}"/>
+ </exec>
+ <exec executable="make"
dir="${project.build.directory}/native" failonerror="true">
+ <arg line="VERBOSE=1"/>
+ </exec>
+ </target>
+ </configuration>
</execution>
</executions>
- <configuration>
- <!-- autoreconf settings -->
- <workDir>${project.build.directory}/native</workDir>
- <arguments>
- <argument>-i</argument>
- <argument>-f</argument>
- </arguments>
-
- <!-- configure settings -->
- <configureEnvironment>
- <property>
- <name>OS_NAME</name>
- <value>${os.name}</value>
- </property>
- <property>
- <name>OS_ARCH</name>
- <value>${os.arch}</value>
- </property>
- <property>
- <name>JVM_DATA_MODEL</name>
- <value>${sun.arch.data.model}</value>
- </property>
- </configureEnvironment>
- <configureOptions>
- <configureOption>CPPFLAGS=-I${snappy.include}</configureOption>
- <configureOption>LDFLAGS=-L${snappy.lib}</configureOption>
- </configureOptions>
-
<configureWorkDir>${project.build.directory}/native</configureWorkDir>
- <prefix>/usr/local</prefix>
-
- <!-- make settings -->
- <installEnvironment>
- <property>
- <name>OS_NAME</name>
- <value>${os.name}</value>
- </property>
- <property>
- <name>OS_ARCH</name>
- <value>${os.arch}</value>
- </property>
- <property>
- <name>JVM_DATA_MODEL</name>
- <value>${sun.arch.data.model}</value>
- </property>
- <property>
- <name>HADOOP_NATIVE_SRCDIR</name>
- <value>${project.build.directory}/native</value>
- </property>
- </installEnvironment>
-
- <!-- configure & make settings -->
- <destDir>${project.build.directory}/native/target</destDir>
-
- </configuration>
</plugin>
</plugins>
</build>
@@ -700,7 +633,7 @@
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
- <id>compile</id>
+ <id>kdc</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
Added:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt?rev=1345421&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt
(added)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/CMakeLists.txt
Sat Jun 2 02:34:38 2012
@@ -0,0 +1,131 @@
+#
+# 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.
+#
+
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+# Default to release builds
+set(CMAKE_BUILD_TYPE, Release)
+
+# If JVM_ARCH_DATA_MODEL is 32, compile all binaries as 32-bit.
+# This variable is set by maven.
+if (JVM_ARCH_DATA_MODEL EQUAL 32)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
+ set(CMAKE_LD_FLAGS "${CMAKE_LD_FLAGS} -m32")
+endif (JVM_ARCH_DATA_MODEL EQUAL 32)
+
+# Compile a library with both shared and static variants
+function(add_dual_library LIBNAME)
+ add_library(${LIBNAME} SHARED ${ARGN})
+ add_library(${LIBNAME}_static STATIC ${ARGN})
+ set_target_properties(${LIBNAME}_static PROPERTIES OUTPUT_NAME ${LIBNAME})
+endfunction(add_dual_library)
+
+# Link both a static and a dynamic target against some libraries
+function(target_link_dual_libraries LIBNAME)
+ target_link_libraries(${LIBNAME} ${ARGN})
+ target_link_libraries(${LIBNAME}_static ${ARGN})
+endfunction(target_link_dual_libraries)
+
+function(output_directory TGT DIR)
+ SET_TARGET_PROPERTIES(${TGT} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
+ SET_TARGET_PROPERTIES(${TGT} PROPERTIES
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
+ SET_TARGET_PROPERTIES(${TGT} PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${DIR}")
+endfunction(output_directory TGT DIR)
+
+function(dual_output_directory TGT DIR)
+ output_directory(${TGT} "${DIR}")
+ output_directory(${TGT}_static "${DIR}")
+endfunction(dual_output_directory TGT DIR)
+
+if (NOT GENERATED_JAVAH)
+ # Must identify where the generated headers have been placed
+ MESSAGE(FATAL_ERROR "You must set the cmake variable GENERATED_JAVAH")
+endif (NOT GENERATED_JAVAH)
+find_package(JNI REQUIRED)
+find_package(ZLIB REQUIRED)
+
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Wall -O2")
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_REENTRANT -D_FILE_OFFSET_BITS=64")
+set(D main/native/src/org/apache/hadoop)
+
+GET_FILENAME_COMPONENT(HADOOP_ZLIB_LIBRARY ${ZLIB_LIBRARIES} NAME)
+
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckCSourceCompiles)
+CHECK_FUNCTION_EXISTS(sync_file_range HAVE_SYNC_FILE_RANGE)
+CHECK_FUNCTION_EXISTS(posix_fadvise HAVE_POSIX_FADVISE)
+
+find_library(SNAPPY_LIBRARY NAMES snappy PATHS)
+find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h PATHS)
+if (SNAPPY_LIBRARY)
+ GET_FILENAME_COMPONENT(HADOOP_SNAPPY_LIBRARY ${SNAPPY_LIBRARY} NAME)
+ set(SNAPPY_SOURCE_FILES
+ "${D}/io/compress/snappy/SnappyCompressor.c"
+ "${D}/io/compress/snappy/SnappyDecompressor.c")
+else (${SNAPPY_LIBRARY})
+ set(SNAPPY_INCLUDE_DIR "")
+ set(SNAPPY_SOURCE_FILES "")
+endif (SNAPPY_LIBRARY)
+
+include_directories(
+ ${GENERATED_JAVAH}
+ main/native/src
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
+ ${CMAKE_BINARY_DIR}
+ ${JNI_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIRS}
+ ${SNAPPY_INCLUDE_DIR}
+)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
+
+add_dual_library(hadoop
+ ${D}/io/compress/lz4/Lz4Compressor.c
+ ${D}/io/compress/lz4/Lz4Decompressor.c
+ ${D}/io/compress/lz4/lz4.c
+ ${SNAPPY_SOURCE_FILES}
+ ${D}/io/compress/zlib/ZlibCompressor.c
+ ${D}/io/compress/zlib/ZlibDecompressor.c
+ ${D}/io/nativeio/NativeIO.c
+ ${D}/io/nativeio/errno_enum.c
+ ${D}/io/nativeio/file_descriptor.c
+ ${D}/security/JniBasedUnixGroupsMapping.c
+ ${D}/security/JniBasedUnixGroupsNetgroupMapping.c
+ ${D}/security/getGroup.c
+ ${D}/util/NativeCrc32.c
+ ${D}/util/bulk_crc32.c
+)
+target_link_dual_libraries(hadoop
+ dl
+ ${JAVA_JVM_LIBRARY}
+)
+SET(LIBHADOOP_VERSION "1.0.0")
+SET_TARGET_PROPERTIES(hadoop PROPERTIES
+ SOVERSION ${LIBHADOOP_VERSION})
+dual_output_directory(hadoop target/usr/local/lib)
+
+if (HADOOP_RUNAS_HOME)
+ add_executable(runAs
+ test/system/c++/runAs/runAs.c
+ test/system/c++/runAs/main.c
+ )
+ output_directory(runAs target/usr/local/bin)
+endif (HADOOP_RUNAS_HOME)
Added:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/config.h.cmake
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/config.h.cmake?rev=1345421&view=auto
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/config.h.cmake
(added)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/config.h.cmake
Sat Jun 2 02:34:38 2012
@@ -0,0 +1,10 @@
+#ifndef CONFIG_H
+#define CONFIG_H
+
+#cmakedefine HADOOP_ZLIB_LIBRARY "@HADOOP_ZLIB_LIBRARY@"
+#cmakedefine HADOOP_RUNAS_HOME "@HADOOP_RUNAS_HOME@"
+#cmakedefine HADOOP_SNAPPY_LIBRARY "@HADOOP_SNAPPY_LIBRARY@"
+#cmakedefine HAVE_SYNC_FILE_RANGE
+#cmakedefine HAVE_POSIX_FADVISE
+
+#endif
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Compressor.c
Sat Jun 2 02:34:38 2012
@@ -16,10 +16,7 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
+#include "config.h"
#include "org_apache_hadoop.h"
#include "org_apache_hadoop_io_compress_lz4_Lz4Compressor.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Decompressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Decompressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Decompressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/lz4/Lz4Decompressor.c
Sat Jun 2 02:34:38 2012
@@ -16,10 +16,7 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
+#include "config.h"
#include "org_apache_hadoop.h"
#include "org_apache_hadoop_io_compress_lz4_Lz4Decompressor.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyCompressor.c
Sat Jun 2 02:34:38 2012
@@ -16,36 +16,12 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HADOOP_SNAPPY_LIBRARY
-
-#if defined HAVE_STDIO_H
- #include <stdio.h>
-#else
- #error 'stdio.h not found'
-#endif
-
-#if defined HAVE_STDLIB_H
- #include <stdlib.h>
-#else
- #error 'stdlib.h not found'
-#endif
-
-#if defined HAVE_STRING_H
- #include <string.h>
-#else
- #error 'string.h not found'
-#endif
-
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error 'dlfcn.h not found'
-#endif
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
#include "org_apache_hadoop_io_compress_snappy.h"
#include "org_apache_hadoop_io_compress_snappy_SnappyCompressor.h"
@@ -123,5 +99,3 @@ JNIEXPORT jint JNICALL Java_org_apache_h
return (jint)compressed_direct_buf_len;
}
-
-#endif //define HADOOP_SNAPPY_LIBRARY
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/SnappyDecompressor.c
Sat Jun 2 02:34:38 2012
@@ -16,36 +16,12 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HADOOP_SNAPPY_LIBRARY
-
-#if defined HAVE_STDIO_H
- #include <stdio.h>
-#else
- #error 'stdio.h not found'
-#endif
-
-#if defined HAVE_STDLIB_H
- #include <stdlib.h>
-#else
- #error 'stdlib.h not found'
-#endif
-
-#if defined HAVE_STRING_H
- #include <string.h>
-#else
- #error 'string.h not found'
-#endif
-
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error 'dlfcn.h not found'
-#endif
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
#include "org_apache_hadoop_io_compress_snappy.h"
#include "org_apache_hadoop_io_compress_snappy_SnappyDecompressor.h"
@@ -127,5 +103,3 @@ JNIEXPORT jint JNICALL Java_org_apache_h
return (jint)uncompressed_direct_buf_len;
}
-
-#endif //define HADOOP_SNAPPY_LIBRARY
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/org_apache_hadoop_io_compress_snappy.h
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/org_apache_hadoop_io_compress_snappy.h?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/org_apache_hadoop_io_compress_snappy.h
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/snappy/org_apache_hadoop_io_compress_snappy.h
Sat Jun 2 02:34:38 2012
@@ -17,42 +17,13 @@
*/
-#if !defined ORG_APACHE_HADOOP_IO_COMPRESS_SNAPPY_SNAPPY_H
+#ifndef ORG_APACHE_HADOOP_IO_COMPRESS_SNAPPY_SNAPPY_H
#define ORG_APACHE_HADOOP_IO_COMPRESS_SNAPPY_SNAPPY_H
-
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HADOOP_SNAPPY_LIBRARY
-
- #if defined HAVE_STDDEF_H
- #include <stddef.h>
- #else
- #error 'stddef.h not found'
- #endif
-
- #if defined HAVE_SNAPPY_C_H
- #include <snappy-c.h>
- #else
- #error 'Please install snappy-development packages for your platform.'
- #endif
-
- #if defined HAVE_DLFCN_H
- #include <dlfcn.h>
- #else
- #error "dlfcn.h not found"
- #endif
-
- #if defined HAVE_JNI_H
- #include <jni.h>
- #else
- #error 'jni.h not found'
- #endif
-
- #include "org_apache_hadoop.h"
-
-#endif //define HADOOP_SNAPPY_LIBRARY
+#include "org_apache_hadoop.h"
+#include <dlfcn.h>
+#include <jni.h>
+#include <snappy-c.h>
+#include <stddef.h>
#endif //ORG_APACHE_HADOOP_IO_COMPRESS_SNAPPY_SNAPPY_H
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibCompressor.c
Sat Jun 2 02:34:38 2012
@@ -16,34 +16,12 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HAVE_STDIO_H
- #include <stdio.h>
-#else
- #error 'stdio.h not found'
-#endif
-
-#if defined HAVE_STDLIB_H
- #include <stdlib.h>
-#else
- #error 'stdlib.h not found'
-#endif
-
-#if defined HAVE_STRING_H
- #include <string.h>
-#else
- #error 'string.h not found'
-#endif
-
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error 'dlfcn.h not found'
-#endif
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
#include "org_apache_hadoop_io_compress_zlib.h"
#include "org_apache_hadoop_io_compress_zlib_ZlibCompressor.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibDecompressor.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibDecompressor.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibDecompressor.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/ZlibDecompressor.c
Sat Jun 2 02:34:38 2012
@@ -16,34 +16,12 @@
* limitations under the License.
*/
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HAVE_STDIO_H
- #include <stdio.h>
-#else
- #error 'stdio.h not found'
-#endif
-
-#if defined HAVE_STDLIB_H
- #include <stdlib.h>
-#else
- #error 'stdlib.h not found'
-#endif
-
-#if defined HAVE_STRING_H
- #include <string.h>
-#else
- #error 'string.h not found'
-#endif
-
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error 'dlfcn.h not found'
-#endif
+#include <dlfcn.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "config.h"
#include "org_apache_hadoop_io_compress_zlib.h"
#include "org_apache_hadoop_io_compress_zlib_ZlibDecompressor.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/org_apache_hadoop_io_compress_zlib.h
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/org_apache_hadoop_io_compress_zlib.h?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/org_apache_hadoop_io_compress_zlib.h
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/compress/zlib/org_apache_hadoop_io_compress_zlib.h
Sat Jun 2 02:34:38 2012
@@ -19,40 +19,13 @@
#if !defined ORG_APACHE_HADOOP_IO_COMPRESS_ZLIB_ZLIB_H
#define ORG_APACHE_HADOOP_IO_COMPRESS_ZLIB_ZLIB_H
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
-
-#if defined HAVE_STDDEF_H
- #include <stddef.h>
-#else
- #error 'stddef.h not found'
-#endif
-
-#if defined HAVE_ZLIB_H
- #include <zlib.h>
-#else
- #error 'Please install zlib-development packages for your platform.'
-#endif
-
-#if defined HAVE_ZCONF_H
- #include <zconf.h>
-#else
- #error 'Please install zlib-development packages for your platform.'
-#endif
-
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error "dlfcn.h not found"
-#endif
-
-#if defined HAVE_JNI_H
- #include <jni.h>
-#else
- #error 'jni.h not found'
-#endif
+#include <dlfcn.h>
+#include <jni.h>
+#include <stddef.h>
+#include <zconf.h>
+#include <zlib.h>
+#include "config.h"
#include "org_apache_hadoop.h"
/* A helper macro to convert the java 'stream-handle' to a z_stream pointer. */
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/io/nativeio/NativeIO.c
Sat Jun 2 02:34:38 2012
@@ -16,9 +16,6 @@
* limitations under the License.
*/
-// get the autoconf settings
-#include "config.h"
-
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
@@ -32,6 +29,7 @@
#include <sys/syscall.h>
#include <unistd.h>
+#include "config.h"
#include "org_apache_hadoop.h"
#include "org_apache_hadoop_io_nativeio_NativeIO.h"
#include "file_descriptor.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCrc32.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCrc32.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCrc32.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/util/NativeCrc32.c
Sat Jun 2 02:34:38 2012
@@ -16,9 +16,6 @@
* limitations under the License.
*/
-// get the autoconf settings
-#include "config.h"
-
#include <arpa/inet.h>
#include <assert.h>
#include <stdlib.h>
@@ -26,6 +23,7 @@
#include <string.h>
#include <unistd.h>
+#include "config.h"
#include "org_apache_hadoop.h"
#include "org_apache_hadoop_util_NativeCrc32.h"
#include "gcc_optimizations.h"
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org_apache_hadoop.h
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org_apache_hadoop.h?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org_apache_hadoop.h
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/native/src/org_apache_hadoop.h
Sat Jun 2 02:34:38 2012
@@ -24,21 +24,10 @@
#if !defined ORG_APACHE_HADOOP_H
#define ORG_APACHE_HADOOP_H
-#if defined HAVE_CONFIG_H
- #include <config.h>
-#endif
+#include <dlfcn.h>
+#include <jni.h>
-#if defined HAVE_DLFCN_H
- #include <dlfcn.h>
-#else
- #error "dlfcn.h not found"
-#endif
-
-#if defined HAVE_JNI_H
- #include <jni.h>
-#else
- #error 'jni.h not found'
-#endif
+#include "config.h"
/* A helper macro to 'throw' a java exception. */
#define THROW(env, exception_name, message) \
Modified:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.c
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c%2B%2B/runAs/runAs.c?rev=1345421&r1=1345420&r2=1345421&view=diff
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.c
(original)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.c
Sat Jun 2 02:34:38 2012
@@ -18,6 +18,8 @@
#include "runAs.h"
+#include "config.h"
+
/*
* Function to get the user details populated given a user name.
*/
@@ -77,28 +79,22 @@ int switchuser(char *user) {
* command.
*/
int process_cluster_command(char * user, char * node , char *command) {
- char *finalcommandstr;
+ char cmd[4096];
int len;
int errorcode = 0;
if (strncmp(command, "", strlen(command)) == 0) {
fprintf(stderr, "Invalid command passed\n");
return INVALID_COMMAND_PASSED;
}
- len = STRLEN + strlen(command);
- finalcommandstr = (char *) malloc((len + 1) * sizeof(char));
- snprintf(finalcommandstr, len, SCRIPT_DIR_PATTERN, HADOOP_PREFIX,
- command);
- finalcommandstr[len + 1] = '\0';
+ snprintf(cmd, sizeof(cmd), "%s/bin/hadoop-daemon.sh %s",
+ HADOOP_RUNAS_HOME, command);
errorcode = switchuser(user);
if (errorcode != 0) {
fprintf(stderr, "switch user failed\n");
return errorcode;
}
- errno = 0;
- execlp(SSH_COMMAND, SSH_COMMAND, node, finalcommandstr, NULL);
- if (errno != 0) {
- fprintf(stderr, "Excelp failed dude to : %s\n", strerror(errno));
- }
+ execlp(SSH_COMMAND, SSH_COMMAND, node, cmd, NULL);
+ fprintf(stderr, "Excelp failed dude to : %s\n", strerror(errno));
return 0;
}
Added:
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.h
URL:
http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c%2B%2B/runAs/runAs.h?rev=1345421&view=auto
==============================================================================
---
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.h
(added)
+++
hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/system/c++/runAs/runAs.h
Sat Jun 2 02:34:38 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <pwd.h>
+#include <assert.h>
+#include <getopt.h>
+#include <grp.h>
+
+/*
+* List of possible error codes.
+*/
+enum errorcodes {
+ INVALID_ARGUMENT_NUMER = 1,
+ INVALID_USER_NAME, //2
+ SUPER_USER_NOT_ALLOWED_TO_RUN_COMMANDS, //3
+ INITGROUPS_FAILED, //4
+ SETUID_OPER_FAILED, //5
+ INVALID_COMMAND_PASSED, //6
+};
+
+#define SSH_COMMAND "ssh"
+
+/*
+ * Function to get the user details populated given a user name.
+ */
+int getuserdetails(char *user, struct passwd *user_detail);
+
+ /*
+ * Process cluster controller command the API exposed to the
+ * main in order to execute the cluster commands.
+ */
+int process_controller_command(char *user, char *node, char *command);