/** * Get the path to a user's home dir * @param username username * @return a path for services underneath */ protected String homeDir(String username) { return RegistryUtils.homePathForUser(username); }
/** * Get the path to a user's home dir * @param username username * @return a path for services underneath */ protected String homeDir(String username) { return RegistryUtils.homePathForUser(username); }
/** * Get the home path of the current user. * <p> * In an insecure cluster, the environment variable * <code>HADOOP_USER_NAME</code> is queried <i>first</i>. * <p> * This means that in a YARN container where the creator set this * environment variable to propagate their identity, the defined * user name is used in preference to the actual user. * <p> * In a secure cluster, the kerberos identity of the current user is used. * @return a path for the current user's home dir. * @throws RuntimeException if the current user identity cannot be determined * from the OS/kerberos. */ public static String homePathForCurrentUser() { String shortUserName = currentUsernameUnencoded(); return homePathForUser(shortUserName); }
/** * Get the home path of the current user. * <p> * In an insecure cluster, the environment variable * <code>HADOOP_USER_NAME</code> is queried <i>first</i>. * <p> * This means that in a YARN container where the creator set this * environment variable to propagate their identity, the defined * user name is used in preference to the actual user. * <p> * In a secure cluster, the kerberos identity of the current user is used. * @return a path for the current user's home dir. * @throws RuntimeException if the current user identity cannot be determined * from the OS/kerberos. */ public static String homePathForCurrentUser() { String shortUserName = currentUsernameUnencoded(); return homePathForUser(shortUserName); }
/** * Create a service classpath * @param user username or "" * @param serviceClass service name * @return a full path */ public static String serviceclassPath(String user, String serviceClass) { String services = join(homePathForUser(user), RegistryConstants.PATH_USER_SERVICES); return join(services, serviceClass); }
/** * Create a service classpath * @param user username or "" * @param serviceClass service name * @return a full path */ public static String serviceclassPath(String user, String serviceClass) { String services = join(homePathForUser(user), RegistryConstants.PATH_USER_SERVICES); return join(services, serviceClass); }
@Test public void testComplexUsernames() throws Throwable { operations.mknode("/users/user with spaces", true); operations.mknode("/users/user-with_underscores", true); operations.mknode("/users/000000", true); operations.mknode("/users/-storm", true); operations.mknode("/users/windows\\ user", true); String home = RegistryUtils.homePathForUser("\u0413PA\u0414_3"); operations.mknode(home, true); operations.mknode( RegistryUtils.servicePath(home, "service.class", "service 4_5"), true); operations.mknode( RegistryUtils.homePathForUser("hbase@HADOOP.APACHE.ORG"), true); operations.mknode( RegistryUtils.homePathForUser("hbase/localhost@HADOOP.APACHE.ORG"), true); home = RegistryUtils.homePathForUser("ADMINISTRATOR/127.0.0.1"); assertTrue("No 'administrator' in " + home, home.contains("administrator")); operations.mknode( home, true); } }
@Test public void testComplexUsernames() throws Throwable { operations.mknode("/users/user with spaces", true); operations.mknode("/users/user-with_underscores", true); operations.mknode("/users/000000", true); operations.mknode("/users/-storm", true); operations.mknode("/users/windows\\ user", true); String home = RegistryUtils.homePathForUser("\u0413PA\u0414_3"); operations.mknode(home, true); operations.mknode( RegistryUtils.servicePath(home, "service.class", "service 4_5"), true); operations.mknode( RegistryUtils.homePathForUser("hbase@HADOOP.APACHE.ORG"), true); operations.mknode( RegistryUtils.homePathForUser("hbase/localhost@HADOOP.APACHE.ORG"), true); home = RegistryUtils.homePathForUser("ADMINISTRATOR/127.0.0.1"); assertTrue("No 'administrator' in " + home, home.contains("administrator")); operations.mknode( home, true); } }