diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index d083c1ec907..e597c6268bd 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -53,6 +53,9 @@ Release 2.0.5-beta - UNRELEASED HADOOP-9322. LdapGroupsMapping doesn't seem to set a timeout for its directory search. (harsh) + HADOOP-9523. Provide a generic IBM java vendor flag in PlatformName.java + to support non-Sun JREs. (Tian Hong Wang via suresh) + OPTIMIZATIONS HADOOP-9150. Avoid unnecessary DNS resolution attempts for logical URIs diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/GzipCodec.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/GzipCodec.java index 520205e1660..460559f5718 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/GzipCodec.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/compress/GzipCodec.java @@ -25,6 +25,7 @@ import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.io.compress.DefaultCodec; import org.apache.hadoop.io.compress.zlib.*; +import static org.apache.hadoop.util.PlatformName.IBM_JAVA; /** * This class creates gzip compressors/decompressors. @@ -40,7 +41,11 @@ public class GzipCodec extends DefaultCodec { protected static class GzipOutputStream extends CompressorStream { private static class ResetableGZIPOutputStream extends GZIPOutputStream { - + private static final int TRAILER_SIZE = 8; + public static final String JVMVersion= System.getProperty("java.version"); + private static final boolean HAS_BROKEN_FINISH = + (IBM_JAVA && JVMVersion.contains("1.6.0")); + public ResetableGZIPOutputStream(OutputStream out) throws IOException { super(out); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java index b080528e35e..16b34a8f4e2 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/UserGroupInformation.java @@ -62,6 +62,7 @@ import org.apache.hadoop.security.token.Token; import org.apache.hadoop.security.token.TokenIdentifier; import org.apache.hadoop.util.Shell; import org.apache.hadoop.util.Time; +import static org.apache.hadoop.util.PlatformName.IBM_JAVA; import com.google.common.annotations.VisibleForTesting; @@ -294,12 +295,11 @@ public class UserGroupInformation { System.getProperty("os.name").startsWith("Windows"); private static final boolean is64Bit = System.getProperty("os.arch").contains("64"); - private static final boolean ibmJava = System.getProperty("java.vendor").contains("IBM"); private static final boolean aix = System.getProperty("os.name").equals("AIX"); /* Return the OS login module class name */ private static String getOSLoginModuleName() { - if (ibmJava) { + if (IBM_JAVA) { if (windows) { return is64Bit ? "com.ibm.security.auth.module.Win64LoginModule" : "com.ibm.security.auth.module.NTLoginModule"; @@ -321,7 +321,7 @@ public class UserGroupInformation { ClassLoader cl = ClassLoader.getSystemClassLoader(); try { String principalClass = null; - if (ibmJava) { + if (IBM_JAVA) { if (is64Bit) { principalClass = "com.ibm.security.auth.UsernamePrincipal"; } else { @@ -418,7 +418,7 @@ public class UserGroupInformation { private static final Map USER_KERBEROS_OPTIONS = new HashMap(); static { - if (ibmJava) { + if (IBM_JAVA) { USER_KERBEROS_OPTIONS.put("useDefaultCcache", "true"); } else { USER_KERBEROS_OPTIONS.put("doNotPrompt", "true"); @@ -427,7 +427,7 @@ public class UserGroupInformation { } String ticketCache = System.getenv("KRB5CCNAME"); if (ticketCache != null) { - if (ibmJava) { + if (IBM_JAVA) { // The first value searched when "useDefaultCcache" is used. System.setProperty("KRB5CCNAME", ticketCache); } else { @@ -443,7 +443,7 @@ public class UserGroupInformation { private static final Map KEYTAB_KERBEROS_OPTIONS = new HashMap(); static { - if (ibmJava) { + if (IBM_JAVA) { KEYTAB_KERBEROS_OPTIONS.put("credsType", "both"); } else { KEYTAB_KERBEROS_OPTIONS.put("doNotPrompt", "true"); @@ -475,7 +475,7 @@ public class UserGroupInformation { } else if (USER_KERBEROS_CONFIG_NAME.equals(appName)) { return USER_KERBEROS_CONF; } else if (KEYTAB_KERBEROS_CONFIG_NAME.equals(appName)) { - if (ibmJava) { + if (IBM_JAVA) { KEYTAB_KERBEROS_OPTIONS.put("useKeytab", prependFileAuthority(keytabFile)); } else { diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java index 7f82f6aab3c..c118948c82d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/ssl/SSLFactory.java @@ -22,6 +22,7 @@ import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.security.authentication.client.ConnectionConfigurator; import org.apache.hadoop.util.ReflectionUtils; +import static org.apache.hadoop.util.PlatformName.IBM_JAVA; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.HttpsURLConnection; @@ -58,9 +59,7 @@ public class SSLFactory implements ConnectionConfigurator { "hadoop.ssl.client.conf"; public static final String SSL_SERVER_CONF_KEY = "hadoop.ssl.server.conf"; - private static final boolean IBMJAVA = - System.getProperty("java.vendor").contains("IBM"); - public static final String SSLCERTIFICATE = IBMJAVA?"ibmX509":"SunX509"; + public static final String SSLCERTIFICATE = IBM_JAVA?"ibmX509":"SunX509"; public static final boolean DEFAULT_SSL_REQUIRE_CLIENT_CERT = false; diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PlatformName.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PlatformName.java index 5e3522c99e7..3c08505890a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PlatformName.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/PlatformName.java @@ -32,19 +32,23 @@ public class PlatformName { * The complete platform 'name' to identify the platform as * per the java-vm. */ - private static final String platformName = System.getProperty("os.name") + "-" + + private static final String PLATFORM_NAME = System.getProperty("os.name") + "-" + System.getProperty("os.arch") + "-" + System.getProperty("sun.arch.data.model"); /** - * Get the complete platform as per the java-vm. - * @return returns the complete platform as per the java-vm. + * The java vendor name used in this platform. */ - public static String getPlatformName() { - return platformName; - } + public static final String JAVA_VENDOR_NAME = System.getProperty("java.vendor"); + + /** + * A public static variable to indicate the current java vendor is + * IBM java or not. + */ + public static final boolean IBM_JAVA = JAVA_VENDOR_NAME.contains("IBM"); public static void main(String[] args) { - System.out.println(platformName); + System.out.println("platform name: " + PLATFORM_NAME); + System.out.println("java vendor name: " + JAVA_VENDOR_NAME); } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java index 299301427e4..1bd791e41cc 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/conf/TestConfiguration.java @@ -43,6 +43,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.hadoop.conf.Configuration.IntegerRanges; import org.apache.hadoop.fs.Path; import org.apache.hadoop.net.NetUtils; +import static org.apache.hadoop.util.PlatformName.IBM_JAVA; import org.codehaus.jackson.map.ObjectMapper; public class TestConfiguration extends TestCase { @@ -51,9 +52,8 @@ public class TestConfiguration extends TestCase { final static String CONFIG = new File("./test-config.xml").getAbsolutePath(); final static String CONFIG2 = new File("./test-config2.xml").getAbsolutePath(); final static Random RAN = new Random(); - final static boolean IBMJAVA = System.getProperty("java.vendor").contains("IBM"); final static String XMLHEADER = - IBMJAVA?"": + IBM_JAVA?"": ""; @Override