HDFS-7026. Introduce a string constant for "Failed to obtain user group info...". Contributed by Yongjun Zhang.

This commit is contained in:
Aaron T. Myers 2014-10-09 18:52:28 -07:00
parent e532ed8faa
commit cbd21fd13b
5 changed files with 10 additions and 3 deletions

View File

@ -57,6 +57,8 @@ import com.google.common.annotations.VisibleForTesting;
public class SecurityUtil {
public static final Log LOG = LogFactory.getLog(SecurityUtil.class);
public static final String HOSTNAME_PATTERN = "_HOST";
public static final String FAILED_TO_GET_UGI_MSG_HEADER =
"Failed to obtain user group information:";
// controls whether buildTokenService will use an ip or host/ip as given
// by the user

View File

@ -376,6 +376,9 @@ Release 2.7.0 - UNRELEASED
HDFS-7202. Should be able to omit package name of SpanReceiver on "hadoop
trace -add" (iwasakims via cmccabe)
HDFS-7026. Introduce a string constant for "Failed to obtain user group
info...". (Yongjun Zhang via atm)
OPTIMIZATIONS
BUG FIXES

View File

@ -354,7 +354,8 @@ public class WebHdfsFileSystem extends FileSystem
// extract UGI-related exceptions and unwrap InvalidToken
// the NN mangles these exceptions but the DN does not and may need
// to re-fetch a token if either report the token is expired
if (re.getMessage().startsWith("Failed to obtain user group information:")) {
if (re.getMessage().startsWith(
SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER)) {
String[] parts = re.getMessage().split(":\\s+", 3);
re = new RemoteException(parts[1], parts[2]);
re = ((RemoteException)re).unwrapRemoteException(InvalidToken.class);

View File

@ -27,6 +27,7 @@ import javax.ws.rs.ext.Provider;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hdfs.server.common.JspHelper;
import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.UserGroupInformation.AuthenticationMethod;
@ -54,7 +55,7 @@ public class UserProvider
AuthenticationMethod.KERBEROS, false);
} catch (IOException e) {
throw new SecurityException(
"Failed to obtain user group information: " + e, e);
SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER + " " + e, e);
}
}

View File

@ -416,7 +416,7 @@ public class TestDelegationTokensWithHA {
// Mimic the UserProvider class logic (server side) by throwing
// SecurityException here
throw new SecurityException(
"Failed to obtain user group information: " + e, e);
SecurityUtil.FAILED_TO_GET_UGI_MSG_HEADER + " " + e, e);
}
} catch (Exception oe) {
//