protected synchronized Token<?> getDelegationToken() throws IOException { if (canRefreshDelegationToken && delegationToken == null) { Token<?> token = tokenSelector.selectToken( new Text(getCanonicalServiceName()), ugi.getTokens()); // ugi tokens are usually indicative of a task which can't // refetch tokens. even if ugi has credentials, don't attempt // to get another token to match hdfs/rpc behavior if (token != null) { LOG.debug("Using UGI token: " + token); canRefreshDelegationToken = false; } else { token = getDelegationToken(null); if (token != null) { LOG.debug("Fetched new token: " + token); } else { // security is disabled canRefreshDelegationToken = false; } } setDelegationToken(token); } return delegationToken; }
protected synchronized Token<?> getDelegationToken() throws IOException { if (delegationToken == null) { Token<?> token = tokenSelector.selectToken( new Text(getCanonicalServiceName()), ugi.getTokens()); // ugi tokens are usually indicative of a task which can't // refetch tokens. even if ugi has credentials, don't attempt // to get another token to match hdfs/rpc behavior if (token != null) { LOG.debug("Using UGI token: {}", token); canRefreshDelegationToken = false; } else { if (canRefreshDelegationToken) { token = getDelegationToken(null); if (token != null) { LOG.debug("Fetched new token: {}", token); } else { // security is disabled canRefreshDelegationToken = false; } } } setDelegationToken(token); } return delegationToken; }
protected synchronized Token<?> getDelegationToken() throws IOException { if (canRefreshDelegationToken && delegationToken == null) { Token<?> token = tokenSelector.selectToken( new Text(getCanonicalServiceName()), ugi.getTokens()); // ugi tokens are usually indicative of a task which can't // refetch tokens. even if ugi has credentials, don't attempt // to get another token to match hdfs/rpc behavior if (token != null) { LOG.debug("Using UGI token: " + token); canRefreshDelegationToken = false; } else { token = getDelegationToken(null); if (token != null) { LOG.debug("Fetched new token: " + token); } else { // security is disabled canRefreshDelegationToken = false; } } setDelegationToken(token); } return delegationToken; }
@Test public void testWebHdfsCustomUriPortWithCustomDefaultPorts() throws IOException { URI uri = URI.create("webhdfs://localhost:789"); WebHdfsFileSystem fs = (WebHdfsFileSystem) FileSystem.get(uri, conf); assertEquals(123, fs.getDefaultPort()); assertEquals(uri, fs.getUri()); assertEquals("127.0.0.1:789", fs.getCanonicalServiceName()); }
@Test public void testWebHdfsCustomDefaultPorts() throws IOException { URI uri = URI.create("webhdfs://localhost"); WebHdfsFileSystem fs = (WebHdfsFileSystem) FileSystem.get(uri, conf); assertEquals(123, fs.getDefaultPort()); assertEquals(uri, fs.getUri()); assertEquals("127.0.0.1:123", fs.getCanonicalServiceName()); }