本文整理汇总了Java中org.apache.hadoop.fs.FileSystem.getDelegationToken方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.getDelegationToken方法的具体用法?Java FileSystem.getDelegationToken怎么用?Java FileSystem.getDelegationToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.fs.FileSystem
的用法示例。
在下文中一共展示了FileSystem.getDelegationToken方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDTInInsecureCluster
import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testDTInInsecureCluster() throws Exception {
MiniDFSCluster cluster = null;
final Configuration conf = WebHdfsTestUtil.createConf();
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
final FileSystem webHdfs = WebHdfsTestUtil.getWebHdfsFileSystem(conf,
WebHdfsFileSystem.SCHEME);
webHdfs.getDelegationToken(null);
fail("No exception is thrown.");
} catch (AccessControlException ace) {
Assert.assertTrue(ace.getMessage().startsWith(
WebHdfsFileSystem.CANT_FALLBACK_TO_INSECURE_MSG));
} finally {
if (cluster != null) {
cluster.shutdown();
}
}
}
示例2: acquireDelegationToken
import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
/**
* Acquire the delegation token for the specified filesytem.
* Before requesting a new delegation token, tries to find one already available.
*
* @param fs the filesystem that requires the delegation token
* @throws IOException on fs.getDelegationToken() failure
*/
public void acquireDelegationToken(final FileSystem fs)
throws IOException {
if (userProvider.isHadoopSecurityEnabled()) {
this.fs = fs;
userToken = userProvider.getCurrent().getToken("HDFS_DELEGATION_TOKEN",
fs.getCanonicalServiceName());
if (userToken == null) {
hasForwardedToken = false;
try {
userToken = fs.getDelegationToken(renewer);
} catch (NullPointerException npe) {
// we need to handle NullPointerException in case HADOOP-10009 is missing
LOG.error("Failed to get token for " + renewer);
}
} else {
hasForwardedToken = true;
LOG.info("Use the existing token: " + userToken);
}
}
}
示例3: testEmptyDelegationToken
import org.apache.hadoop.fs.FileSystem; //导入方法依赖的package包/类
@Test
public void testEmptyDelegationToken() throws IOException {
Configuration conf = getTestConfiguration();
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
FileSystem fileSys = cluster.getFileSystem();
fileSys.getDelegationToken("");
} finally {
cluster.shutdown();
}
}