/** * Setter for the user name. * @param userName the user name. */ public final void userName(String userName) { this.userName = IgfsUtils.fixUserName(userName); } }
/** * Gets non-null user name as per the Hadoop file system viewpoint. * @return the user name, never null. * @throws IOException On error. */ public static String getFsHadoopUser() throws IOException { UserGroupInformation currUgi = UserGroupInformation.getCurrentUser(); String user = currUgi.getShortUserName(); user = IgfsUtils.fixUserName(user); assert user != null; return user; }
/** {@inheritDoc} */ @Nullable @Override public String map(String name) { assert state != null; name = IgfsUtils.fixUserName(name); switch (state) { case NAME: return name; case NAME_REALM: return name + '@' + realm; case NAME_INSTANCE: return name + '/' + instance; default: assert state == State.NAME_INSTANCE_REALM; return name + '/' + instance + '@' + realm; } }
/** {@inheritDoc} */ @Override public FileSystem get(String name) throws IOException { String name0 = IgfsUtils.fixUserName(name); if (usrNameMapper != null) name0 = IgfsUtils.fixUserName(usrNameMapper.map(name0)); return getWithMappedName(name0); }
/** * Constructor. * * @param igfs Target IGFS. * @param log Log. * @param userName User name. */ private HadoopIgfsInProc(IgfsEx igfs, Log log, String userName) { this.igfs = igfs; this.log = log; bufSize = igfs.configuration().getBlockSize() * 2; user = IgfsUtils.fixUserName(userName); }
/** * Constructor. * * @param host Host. * @param port Port. * @param igfs IGFS name. * @param shmem Shared memory flag. * @param log Client logger. * @param user User name. * @throws IOException If failed. */ private HadoopIgfsOutProc(String host, int port, String igfs, boolean shmem, Log log, String user) throws IOException { assert host != null && !shmem || host == null && shmem : "Invalid arguments [host=" + host + ", port=" + port + ", shmem=" + shmem + ']'; String endpoint = host != null ? host + ":" + port : "shmem:" + port; this.igfs = igfs; this.log = log; this.userName = IgfsUtils.fixUserName(user); io = HadoopIgfsIpcIo.get(log, endpoint); io.addEventListener(this); }
/** * Constructor. * * @param proxy Proxy. */ public HadoopIgfsSecondaryFileSystemDelegateImpl(IgniteHadoopIgfsSecondaryFileSystem proxy) { assert proxy.getFileSystemFactory() != null; dfltUsrName = IgfsUtils.fixUserName(proxy.getDefaultUserName()); HadoopFileSystemFactory factory0 = proxy.getFileSystemFactory(); if (factory0 == null) factory0 = new CachingHadoopFileSystemFactory(); factory = HadoopDelegateUtils.fileSystemFactoryDelegate(getClass().getClassLoader(), factory0); }
user = IgfsUtils.fixUserName(user);
/** * Gets the FileSystem for the current context user. * @return the FileSystem instance, never null. */ private FileSystem fileSystemForUser() { String user = IgfsUserContext.currentUser(); if (F.isEmpty(user)) user = IgfsUtils.fixUserName(dfltUsrName); assert !F.isEmpty(user); try { return (FileSystem)factory.get(user); } catch (IOException ioe) { throw new IgniteException(ioe); } }
String user = job.info().user(); user = IgfsUtils.fixUserName(user);
/** * Test mapper with instance component. * * @throws Exception If failed. */ @Test public void testMapperInstance() throws Exception { KerberosUserNameMapper mapper = create(INSTANCE, null); assertEquals(IgfsUtils.fixUserName(null) + "/" + INSTANCE, mapper.map(null)); assertEquals("test" + "/" + INSTANCE, mapper.map("test")); }
/** * Test mapper without instance and realm components. * * @throws Exception If failed. */ @Test public void testMapper() throws Exception { KerberosUserNameMapper mapper = create(null, null); assertEquals(IgfsUtils.fixUserName(null), mapper.map(null)); assertEquals("test", mapper.map("test")); }
/** * Test mapper with realm. * * @throws Exception If failed. */ @Test public void testMapperRealm() throws Exception { KerberosUserNameMapper mapper = create(null, REALM); assertEquals(IgfsUtils.fixUserName(null) + "@" + REALM, mapper.map(null)); assertEquals("test" + "@" + REALM, mapper.map("test")); }
/** * Test mapper with instance and realm components. * * @throws Exception If failed. */ @Test public void testMapperInstanceAndRealm() throws Exception { KerberosUserNameMapper mapper = create(INSTANCE, REALM); assertEquals(IgfsUtils.fixUserName(null) + "/" + INSTANCE + "@" + REALM, mapper.map(null)); assertEquals("test" + "/" + INSTANCE + "@" + REALM, mapper.map("test")); }
/** * Test actual chaining logic. * * @throws Exception If failed. */ @Test public void testChaining() throws Exception { BasicUserNameMapper mapper1 = new BasicUserNameMapper(); mapper1.setMappings(Collections.singletonMap("1", "101")); KerberosUserNameMapper mapper2 = new KerberosUserNameMapper(); mapper2.setInstance(INSTANCE); mapper2.setRealm(REALM); ChainedUserNameMapper mapper = create(mapper1, mapper2); assertEquals("101" + "/" + INSTANCE + "@" + REALM, mapper.map("1")); assertEquals("2" + "/" + INSTANCE + "@" + REALM, mapper.map("2")); assertEquals(IgfsUtils.fixUserName(null) + "/" + INSTANCE + "@" + REALM, mapper.map(null)); }
/** * Setter for the user name. * @param userName the user name. */ public final void userName(String userName) { this.userName = IgfsUtils.fixUserName(userName); } }