本文整理汇总了Java中org.apache.hadoop.classification.InterfaceStability类的典型用法代码示例。如果您正苦于以下问题:Java InterfaceStability类的具体用法?Java InterfaceStability怎么用?Java InterfaceStability使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InterfaceStability类属于org.apache.hadoop.classification包,在下文中一共展示了InterfaceStability类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProxyUser
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Create a proxy user using username of the effective user and the ugi of the
* real user.
* @param user
* @param realUser
* @return proxyUser ugi
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation createProxyUser(String user,
UserGroupInformation realUser) {
if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("Null user");
}
if (realUser == null) {
throw new IllegalArgumentException("Null real user");
}
Subject subject = new Subject();
Set<Principal> principals = subject.getPrincipals();
principals.add(new User(user));
principals.add(new RealUser(realUser));
UserGroupInformation result =new UserGroupInformation(subject);
result.setAuthenticationMethod(AuthenticationMethod.PROXY);
return result;
}
示例2: getServerPrincipal
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Convert Kerberos principal name pattern to valid Kerberos principal names.
* This method is similar to {@link #getServerPrincipal(String, String)},
* except 1) the reverse DNS lookup from addr to hostname is done only when
* necessary, 2) param addr can't be null (no default behavior of using local
* hostname when addr is null).
*
* @param principalConfig
* Kerberos principal name pattern to convert
* @param addr
* InetAddress of the host used for substitution
* @return converted Kerberos principal name
* @throws IOException if the client address cannot be determined
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static String getServerPrincipal(String principalConfig,
InetAddress addr) throws IOException {
String[] components = getComponents(principalConfig);
if (components == null || components.length != 3
|| !components[1].equals(HOSTNAME_PATTERN)) {
return principalConfig;
} else {
if (addr == null) {
throw new IOException("Can't replace " + HOSTNAME_PATTERN
+ " pattern since client address is null");
}
return replacePattern(components, addr.getCanonicalHostName());
}
}
示例3: login
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Login as a principal specified in config. Substitute $host in user's Kerberos principal
* name with hostname. If non-secure mode - return. If no keytab available -
* bail out with an exception
*
* @param conf
* conf to use
* @param keytabFileKey
* the key to look for keytab file in conf
* @param userNameKey
* the key to look for user's Kerberos principal name in conf
* @param hostname
* hostname to use for substitution
* @throws IOException if the config doesn't specify a keytab
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static void login(final Configuration conf,
final String keytabFileKey, final String userNameKey, String hostname)
throws IOException {
if(! UserGroupInformation.isSecurityEnabled())
return;
String keytabFilename = conf.get(keytabFileKey);
if (keytabFilename == null || keytabFilename.length() == 0) {
throw new IOException("Running in secure mode, but config doesn't have a keytab");
}
String principalConfig = conf.get(userNameKey, System
.getProperty("user.name"));
String principalName = SecurityUtil.getServerPrincipal(principalConfig,
hostname);
UserGroupInformation.loginUserFromKeytab(principalName, keytabFilename);
}
示例4: getPropertySources
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Gets information about why a property was set. Typically this is the
* path to the resource objects (file, URL, etc.) the property came from, but
* it can also indicate that it was set programmatically, or because of the
* command line.
*
* @param name - The property name to get the source of.
* @return null - If the property or its source wasn't found. Otherwise,
* returns a list of the sources of the resource. The older sources are
* the first ones in the list. So for example if a configuration is set from
* the command line, and then written out to a file that is read back in the
* first entry would indicate that it was set from the command line, while
* the second one would indicate the file that the new configuration was read
* in from.
*/
@InterfaceStability.Unstable
public synchronized String[] getPropertySources(String name) {
if (properties == null) {
// If properties is null, it means a resource was newly added
// but the props were cleared so as to load it upon future
// requests. So lets force a load by asking a properties list.
getProps();
}
// Return a null right away if our properties still
// haven't loaded or the resource mapping isn't defined
if (properties == null || updatingResource == null) {
return null;
} else {
String[] source = updatingResource.get(name);
if(source == null) {
return null;
} else {
return Arrays.copyOf(source, source.length);
}
}
}
示例5: doAs
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Run the given action as the user, potentially throwing an exception.
* @param <T> the return type of the run method
* @param action the method to execute
* @return the value from the run method
* @throws IOException if the action throws an IOException
* @throws Error if the action throws an Error
* @throws RuntimeException if the action throws a RuntimeException
* @throws InterruptedException if the action throws an InterruptedException
* @throws UndeclaredThrowableException if the action throws something else
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public <T> T doAs(PrivilegedExceptionAction<T> action
) throws IOException, InterruptedException {
try {
logPrivilegedAction(subject, action);
return Subject.doAs(subject, action);
} catch (PrivilegedActionException pae) {
Throwable cause = pae.getCause();
if (LOG.isDebugEnabled()) {
LOG.debug("PrivilegedActionException as:" + this + " cause:" + cause);
}
if (cause instanceof IOException) {
throw (IOException) cause;
} else if (cause instanceof Error) {
throw (Error) cause;
} else if (cause instanceof RuntimeException) {
throw (RuntimeException) cause;
} else if (cause instanceof InterruptedException) {
throw (InterruptedException) cause;
} else {
throw new UndeclaredThrowableException(cause);
}
}
}
示例6: getPropertySources
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Gets information about why a property was set. Typically this is the
* path to the resource objects (file, URL, etc.) the property came from, but
* it can also indicate that it was set programatically, or because of the
* command line.
*
* @param name - The property name to get the source of.
* @return null - If the property or its source wasn't found. Otherwise,
* returns a list of the sources of the resource. The older sources are
* the first ones in the list. So for example if a configuration is set from
* the command line, and then written out to a file that is read back in the
* first entry would indicate that it was set from the command line, while
* the second one would indicate the file that the new configuration was read
* in from.
*/
@InterfaceStability.Unstable
public synchronized String[] getPropertySources(String name) {
if (properties == null) {
// If properties is null, it means a resource was newly added
// but the props were cleared so as to load it upon future
// requests. So lets force a load by asking a properties list.
getProps();
}
// Return a null right away if our properties still
// haven't loaded or the resource mapping isn't defined
if (properties == null || updatingResource == null) {
return null;
} else {
String[] source = updatingResource.get(name);
if(source == null) {
return null;
} else {
return Arrays.copyOf(source, source.length);
}
}
}
示例7: newInstance
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
@InterfaceAudience.Private
@InterfaceStability.Unstable
public static QueueStatistics newInstance(long submitted, long running,
long pending, long completed, long killed, long failed, long activeUsers,
long availableMemoryMB, long allocatedMemoryMB, long pendingMemoryMB,
long reservedMemoryMB, long availableVCores, long allocatedVCores,
long pendingVCores, long reservedVCores) {
QueueStatistics statistics = Records.newRecord(QueueStatistics.class);
statistics.setNumAppsSubmitted(submitted);
statistics.setNumAppsRunning(running);
statistics.setNumAppsPending(pending);
statistics.setNumAppsCompleted(completed);
statistics.setNumAppsKilled(killed);
statistics.setNumAppsFailed(failed);
statistics.setNumActiveUsers(activeUsers);
statistics.setAvailableMemoryMB(availableMemoryMB);
statistics.setAllocatedMemoryMB(allocatedMemoryMB);
statistics.setPendingMemoryMB(pendingMemoryMB);
statistics.setReservedMemoryMB(reservedMemoryMB);
statistics.setAvailableVCores(availableVCores);
statistics.setAllocatedVCores(allocatedVCores);
statistics.setPendingVCores(pendingVCores);
statistics.setReservedVCores(reservedVCores);
return statistics;
}
示例8: toString
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
@Override
@InterfaceStability.Unstable
public String toString() {
StringBuilder content = new StringBuilder();
content.append("CreateEvent [INodeType=").append(iNodeType)
.append(", path=").append(path)
.append(", ctime=").append(ctime)
.append(", replication=").append(replication)
.append(", ownerName=").append(ownerName)
.append(", groupName=").append(groupName)
.append(", perms=").append(perms).append(", ");
if (symlinkTarget != null) {
content.append("symlinkTarget=").append(symlinkTarget).append(", ");
}
content.append("overwrite=").append(overwrite)
.append(", defaultBlockSize=").append(defaultBlockSize)
.append("]");
return content.toString();
}
示例9: toString
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* String value includes statistics as well as stream state.
* <b>Important: there are no guarantees as to the stability
* of this value.</b>
* @return a string value for printing in logs/diagnostics
*/
@Override
@InterfaceStability.Unstable
public String toString() {
synchronized (this) {
final StringBuilder sb = new StringBuilder(
"COSInputStream{");
sb.append(uri);
sb.append(" wrappedStream=")
.append(wrappedStream != null ? "open" : "closed");
sb.append(" read policy=").append(inputPolicy);
sb.append(" pos=").append(pos);
sb.append(" nextReadPos=").append(nextReadPos);
sb.append(" contentLength=").append(contentLength);
sb.append(" contentRangeStart=").append(contentRangeStart);
sb.append(" contentRangeFinish=").append(contentRangeFinish);
sb.append(" remainingInCurrentRequest=")
.append(remainingInCurrentRequest());
sb.append('\n');
sb.append('}');
return sb.toString();
}
}
示例10: getPropertySources
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Gets information about why a property was set. Typically this is the
* path to the resource objects (file, URL, etc.) the property came from, but
* it can also indicate that it was set programatically, or because of the
* command line.
*
* @param name - The property name to get the source of.
* @return null - If the property or its source wasn't found. Otherwise,
* returns a list of the sources of the resource. The older sources are
* the first ones in the list. So for example if a configuration is set from
* the command line, and then written out to a file that is read back in the
* first entry would indicate that it was set from the command line, while
* the second one would indicate the file that the new configuration was read
* in from.
*/
@InterfaceStability.Unstable
public synchronized String[] getPropertySources(String name) {
if (properties == null) {
// If properties is null, it means a resource was newly added
// but the props were cleared so as to load it upon future
// requests. So lets force a load by asking a properties list.
getProps();
}
// Return a null right away if our properties still
// haven't loaded or the resource mapping isn't defined
if (properties == null || updatingResource == null) {
return null;
} else {
String[] source = updatingResource.get(name);
if(source == null) {
return null;
} else {
return Arrays.copyOf(source, source.length);
}
}
}
示例11: createRemoteUser
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Create a user from a login name. It is intended to be used for remote
* users in RPC, since it won't have any credentials.
* @param user the full user principal name, must not be empty or null
* @param authMethod the authentication method to use
* @param createHops add user to hdfs_users or not
* @return the UserGroupInformation for the remote user.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation createRemoteUser(String user, AuthMethod authMethod,
boolean createHops) {
if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("Null user");
}
Subject subject = new Subject();
subject.getPrincipals().add(new User(user));
UserGroupInformation result = new UserGroupInformation(subject);
result.setAuthenticationMethod(authMethod);
if(createHops){
createHopsUser(user);
}
return result;
}
示例12: createProxyUser
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Create a proxy user using username of the effective user and the ugi of the
* real user.
* @param user
* @param realUser
* @return proxyUser ugi
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation createProxyUser(String user,
UserGroupInformation realUser) {
if (user == null || "".equals(user)) {
throw new IllegalArgumentException("Null user");
}
if (realUser == null) {
throw new IllegalArgumentException("Null real user");
}
Subject subject = new Subject();
Set<Principal> principals = subject.getPrincipals();
principals.add(new User(user));
principals.add(new RealUser(realUser));
UserGroupInformation result =new UserGroupInformation(subject);
result.setAuthenticationMethod(AuthenticationMethod.PROXY);
return result;
}
示例13: createProxyUser
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Create a proxy user using username of the effective user and the ugi of the
* real user.
* @param user
* @param realUser
* @param createHops
* @return proxyUser ugi
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public static UserGroupInformation createProxyUser(String user,
UserGroupInformation realUser, boolean createHops) {
if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("Null user");
}
if (realUser == null) {
throw new IllegalArgumentException("Null real user");
}
Subject subject = new Subject();
Set<Principal> principals = subject.getPrincipals();
principals.add(new User(user));
principals.add(new RealUser(realUser));
UserGroupInformation result =new UserGroupInformation(subject);
result.setAuthenticationMethod(AuthenticationMethod.PROXY);
if(createHops){
createHopsUser(user);
}
return result;
}
示例14: SaslRpcServer
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
@InterfaceAudience.Private
@InterfaceStability.Unstable
public SaslRpcServer(AuthMethod authMethod) throws IOException {
this.authMethod = authMethod;
mechanism = authMethod.getMechanismName();
switch (authMethod) {
case SIMPLE: {
return; // no sasl for simple
}
case TOKEN: {
protocol = "";
serverId = SaslRpcServer.SASL_DEFAULT_REALM;
break;
}
case KERBEROS: {
String fullName = UserGroupInformation.getCurrentUser().getUserName();
if (LOG.isDebugEnabled())
LOG.debug("Kerberos principal name is " + fullName);
// don't use KerberosName because we don't want auth_to_local
String[] parts = fullName.split("[/@]", 3);
protocol = parts[0];
// should verify service host is present here rather than in create()
// but lazy tests are using a UGI that isn't a SPN...
serverId = (parts.length < 2) ? "" : parts[1];
break;
}
default:
// we should never be able to get here
throw new AccessControlException(
"Server does not support SASL " + authMethod);
}
}
示例15: getCurrentUser
import org.apache.hadoop.classification.InterfaceStability; //导入依赖的package包/类
/**
* Return the current user, including any doAs in the current stack.
* @return the current user
* @throws IOException if login fails
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public synchronized
static UserGroupInformation getCurrentUser() throws IOException {
AccessControlContext context = AccessController.getContext();
Subject subject = Subject.getSubject(context);
if (subject == null || subject.getPrincipals(User.class).isEmpty()) {
return getLoginUser();
} else {
return new UserGroupInformation(subject);
}
}