HBASE-14594 Use new DNS API introduced in HADOOP-12437 (Josh Elser)
This commit is contained in:
parent
68fc130a20
commit
be04ede5b9
|
@ -27,8 +27,8 @@ import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
|||
import org.apache.hadoop.hbase.HConstants;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.util.StringUtils;
|
||||
import org.apache.zookeeper.server.ServerConfig;
|
||||
import org.apache.zookeeper.server.ZooKeeperServerMain;
|
||||
|
|
|
@ -27,8 +27,8 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.security.UserProvider;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
|
||||
/**
|
||||
* Wrapper around Hadoop's DNS class to hide reflection.
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
public final class DNS {
|
||||
private static boolean HAS_NEW_DNS_GET_DEFAULT_HOST_API;
|
||||
private static Method GET_DEFAULT_HOST_METHOD;
|
||||
|
||||
static {
|
||||
try {
|
||||
GET_DEFAULT_HOST_METHOD = org.apache.hadoop.net.DNS.class
|
||||
.getMethod("getDefaultHost", String.class, String.class, boolean.class);
|
||||
HAS_NEW_DNS_GET_DEFAULT_HOST_API = true;
|
||||
} catch (Exception e) {
|
||||
HAS_NEW_DNS_GET_DEFAULT_HOST_API = false;
|
||||
}
|
||||
}
|
||||
|
||||
private DNS() {}
|
||||
|
||||
/**
|
||||
* Wrapper around DNS.getDefaultHost(String, String), calling
|
||||
* DNS.getDefaultHost(String, String, boolean) when available.
|
||||
*
|
||||
* @param strInterface The network interface to query.
|
||||
* @param nameserver The DNS host name.
|
||||
* @return The default host names associated with IPs bound to the network interface.
|
||||
*/
|
||||
public static String getDefaultHost(String strInterface, String nameserver)
|
||||
throws UnknownHostException {
|
||||
if (HAS_NEW_DNS_GET_DEFAULT_HOST_API) {
|
||||
try {
|
||||
// Hadoop-2.8 includes a String, String, boolean variant of getDefaultHost
|
||||
// which properly handles multi-homed systems with Kerberos.
|
||||
return (String) GET_DEFAULT_HOST_METHOD.invoke(null, strInterface, nameserver, true);
|
||||
} catch (Exception e) {
|
||||
// If we can't invoke the method as it should exist, throw an exception
|
||||
throw new RuntimeException("Failed to invoke DNS.getDefaultHost via reflection", e);
|
||||
}
|
||||
} else {
|
||||
return org.apache.hadoop.net.DNS.getDefaultHost(strInterface, nameserver);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,10 +38,10 @@ import org.apache.hadoop.hbase.HBaseInterfaceAudience;
|
|||
import org.apache.hadoop.hbase.http.InfoServer;
|
||||
import org.apache.hadoop.hbase.rest.filter.AuthFilter;
|
||||
import org.apache.hadoop.hbase.security.UserProvider;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.HttpServerUtil;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.hbase.util.VersionInfo;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.mortbay.jetty.Connector;
|
||||
import org.mortbay.jetty.Server;
|
||||
import org.mortbay.jetty.nio.SelectChannelConnector;
|
||||
|
|
|
@ -32,8 +32,8 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.security.SecurityUtil;
|
||||
import org.apache.hadoop.security.authentication.server.AuthenticationFilter;
|
||||
|
||||
|
|
|
@ -169,6 +169,7 @@ import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
|
|||
import org.apache.hadoop.hbase.security.User;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.Counter;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
|
||||
import org.apache.hadoop.hbase.util.Pair;
|
||||
import org.apache.hadoop.hbase.util.ServerRegionReplicaUtil;
|
||||
|
@ -176,7 +177,6 @@ import org.apache.hadoop.hbase.util.Strings;
|
|||
import org.apache.hadoop.hbase.wal.WALKey;
|
||||
import org.apache.hadoop.hbase.wal.WALSplitter;
|
||||
import org.apache.hadoop.hbase.zookeeper.ZKSplitLog;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.zookeeper.KeeperException;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
|
|
@ -98,8 +98,8 @@ import org.apache.hadoop.hbase.thrift.generated.TRowResult;
|
|||
import org.apache.hadoop.hbase.thrift.generated.TScan;
|
||||
import org.apache.hadoop.hbase.util.Bytes;
|
||||
import org.apache.hadoop.hbase.util.ConnectionCache;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.security.SaslRpcServer.SaslGssCallbackHandler;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.security.authorize.ProxyUsers;
|
||||
|
|
|
@ -60,8 +60,8 @@ import org.apache.hadoop.hbase.thrift.CallQueue;
|
|||
import org.apache.hadoop.hbase.thrift.CallQueue.Call;
|
||||
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
|
||||
import org.apache.hadoop.hbase.thrift2.generated.THBaseService;
|
||||
import org.apache.hadoop.hbase.util.DNS;
|
||||
import org.apache.hadoop.hbase.util.Strings;
|
||||
import org.apache.hadoop.net.DNS;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.security.SaslRpcServer.SaslGssCallbackHandler;
|
||||
import org.apache.hadoop.util.GenericOptionsParser;
|
||||
|
|
Loading…
Reference in New Issue