当前位置: 首页>>代码示例>>Java>>正文


Java DelegationTokenFetcher.main方法代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.tools.DelegationTokenFetcher.main方法的典型用法代码示例。如果您正苦于以下问题:Java DelegationTokenFetcher.main方法的具体用法?Java DelegationTokenFetcher.main怎么用?Java DelegationTokenFetcher.main使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hdfs.tools.DelegationTokenFetcher的用法示例。


在下文中一共展示了DelegationTokenFetcher.main方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: expectedTokenIsRetrievedFromHttp

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入方法依赖的package包/类
/**
 * Call fetch token using http server 
 */
@Test
public void expectedTokenIsRetrievedFromHttp() throws Exception {
  bootstrap = startHttpServer(httpPort, testToken, serviceUrl);
  DelegationTokenFetcher.main(new String[] { "-webservice=" + serviceUrl,
      tokenFile });
  Path p = new Path(fileSys.getWorkingDirectory(), tokenFile);
  Credentials creds = Credentials.readTokenStorageFile(p, conf);
  Iterator<Token<?>> itr = creds.getAllTokens().iterator();
  assertTrue("token not exist error", itr.hasNext());
  Token<?> fetchedToken = itr.next();
  Assert.assertArrayEquals("token wrong identifier error",
      testToken.getIdentifier(), fetchedToken.getIdentifier());
  Assert.assertArrayEquals("token wrong password error",
      testToken.getPassword(), fetchedToken.getPassword());
  if (assertionError != null)
    throw assertionError;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestDelegationTokenRemoteFetcher.java

示例2: testTokenFetchFail

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入方法依赖的package包/类
/**
 * try to fetch token without http server with IOException
 */
@Test
public void testTokenFetchFail() throws Exception {
  try {
    DelegationTokenFetcher.main(new String[] { "-webservice=" + serviceUrl,
        tokenFile });
    fail("Token fetcher shouldn't start in absense of NN");
  } catch (IOException ex) {
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestDelegationTokenRemoteFetcher.java

示例3: expectDelegationTokenFetcherExit

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入方法依赖的package包/类
private static void expectDelegationTokenFetcherExit(String[] args) {
  try {
    DelegationTokenFetcher.main(args);
    fail("should call exit");
  } catch (ExitException e) {
    ExitUtil.resetFirstExitException();
  } catch (Exception ex) {
    fail("expectDelegationTokenFetcherExit ex error " + ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:TestTools.java

示例4: expectedTokenIsRetrievedFromDFS

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入方法依赖的package包/类
/**
 * Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
 * pulls out the correct user's token and successfully serializes it to disk.
 */
@Test
public void expectedTokenIsRetrievedFromDFS() throws Exception {
  final byte[] ident = new byte[]{1,2,3,4};
  final byte[] pw = new byte[]{42};
  final Text service = new Text(uri.toString());
  final String user = 
      UserGroupInformation.getCurrentUser().getShortUserName();

  // Create a token for the fetcher to fetch, wire NN to return it when asked
  // for this particular user.
  Token<DelegationTokenIdentifier> t = 
    new Token<DelegationTokenIdentifier>(ident, pw, KIND, service);
  when(dfs.getDelegationToken(eq(user))).thenReturn(t);
  when(dfs.renewDelegationToken(eq(t))).thenReturn(1000L);
  FakeRenewer.reset();
  
  DelegationTokenFetcher.main(new String[]{"-fs", uri.toString(), 
                                           "file.dta"});
  FileSystem fs = FileSystem.getLocal(conf);
  Path p = new Path(fs.getWorkingDirectory(), "file.dta");
  Credentials creds = Credentials.readTokenStorageFile(p , conf);
  Iterator<Token<?>> itr = creds.getAllTokens().iterator();
  // make sure we got back exactly the 1 token we expected
  assertTrue(itr.hasNext());
  assertEquals(t, itr.next());
  assertTrue(!itr.hasNext());

  DelegationTokenFetcher.main(new String[]{"--renew", "file.dta"});
  assertEquals(t, FakeRenewer.lastRenewed);
  FakeRenewer.reset();

  DelegationTokenFetcher.main(new String[]{"--cancel", "file.dta"});
  assertEquals(t, FakeRenewer.lastCanceled);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:39,代码来源:TestDelegationTokenFetcher.java

示例5: expectedTokenIsRetrievedFromDFS

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入方法依赖的package包/类
/**
 * Verify that when the DelegationTokenFetcher runs, it talks to the Namenode,
 * pulls out the correct user's token and successfully serializes it to disk.
 */
@Test
public void expectedTokenIsRetrievedFromDFS() throws Exception {
  final byte[] ident = new DelegationTokenIdentifier(new Text("owner"),
      new Text("renewer"), new Text("realuser")).getBytes();
  final byte[] pw = new byte[] { 42 };
  final Text kind = new Text("MY-KIND");
  final Text service = new Text(uri.toString());

  // Create a token for the fetcher to fetch, wire NN to return it when asked
  // for this particular user.
  Token<DelegationTokenIdentifier> t = new Token<DelegationTokenIdentifier>(
      ident, pw, kind, service);
  when(dfs.getDelegationToken((String) null)).thenReturn(t);
  when(dfs.renewDelegationToken(eq(t))).thenReturn(1000L);
  when(dfs.getUri()).thenReturn(uri);

  FileSystem fileSys = FileSystem.getLocal(conf);
  try {
    DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(),
        tokenFile });
    Path p = new Path(fileSys.getWorkingDirectory(), tokenFile);
    Credentials creds = Credentials.readTokenStorageFile(p, conf);
    Iterator<Token<?>> itr = creds.getAllTokens().iterator();
    // make sure we got back exactly the 1 token we expected
    assertTrue(itr.hasNext());
    assertEquals(t, itr.next());
    assertTrue(!itr.hasNext());

    DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(),
        "--print", tokenFile });
    DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(),
        "--renew", tokenFile });
    DelegationTokenFetcher.main(new String[] { "-fs", uri.toString(),
        "--cancel", tokenFile });
    verify(dfs).renewDelegationToken(eq(t));
    verify(dfs).cancelDelegationToken(eq(t));
  } finally {
    fileSys.delete(new Path(tokenFile), true);
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:45,代码来源:TestDelegationTokenFetcher.java


注:本文中的org.apache.hadoop.hdfs.tools.DelegationTokenFetcher.main方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。