當前位置: 首頁>>代碼示例>>Java>>正文


Java FileSystem.getDelegationToken方法代碼示例

本文整理匯總了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();
    }
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:20,代碼來源:TestWebHDFS.java

示例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);
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:FsDelegationToken.java

示例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();
  }
}
 
開發者ID:naver,項目名稱:hadoop,代碼行數:13,代碼來源:TestDistributedFileSystem.java


注:本文中的org.apache.hadoop.fs.FileSystem.getDelegationToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。