• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DelegationTokenFetcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



DelegationTokenFetcher类属于org.apache.hadoop.hdfs.tools包,在下文中一共展示了DelegationTokenFetcher类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: renewDelegationToken

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public long renewDelegationToken(final Token<?> token) throws IOException {
  // update the kerberos credentials, if they are coming from a keytab
  UserGroupInformation connectUgi = ugi.getRealUser();
  if (connectUgi == null) {
    connectUgi = ugi;
  }
  try {
    return connectUgi.doAs(new PrivilegedExceptionAction<Long>() {
      @Override
      public Long run() throws Exception {
        InetSocketAddress serviceAddr = SecurityUtil
            .getTokenServiceAddr(token);
        return DelegationTokenFetcher.renewDelegationToken(connectionFactory,
            DFSUtil.createUri(getUnderlyingProtocol(), serviceAddr),
            (Token<DelegationTokenIdentifier>) token);
      }
    });
  } catch (InterruptedException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:HftpFileSystem.java


示例2: cancelDelegationToken

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void cancelDelegationToken(final Token<?> token) throws IOException {
  UserGroupInformation connectUgi = ugi.getRealUser();
  if (connectUgi == null) {
    connectUgi = ugi;
  }
  try {
    connectUgi.doAs(new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        InetSocketAddress serviceAddr = SecurityUtil
            .getTokenServiceAddr(token);
        DelegationTokenFetcher.cancelDelegationToken(connectionFactory,
            DFSUtil.createUri(getUnderlyingProtocol(), serviceAddr),
            (Token<DelegationTokenIdentifier>) token);
        return null;
      }
    });
  } catch (InterruptedException e) {
    throw new IOException(e);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:HftpFileSystem.java


示例3: 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


示例4: cancelDelegationTokenOverHttps

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
protected static void cancelDelegationTokenOverHttps(
    final Token<DelegationTokenIdentifier> token, final Configuration conf) 
throws InterruptedException, IOException{
  final String httpAddress = getHttpAddressForToken(token, conf);
  // will be chaged to debug
  LOG.info("address to cancel=" + httpAddress + "; tok=" + token.getService());
  
  UserGroupInformation.getLoginUser().doAs(
      new PrivilegedExceptionAction<Void>() {
        public Void run() throws IOException {
          DelegationTokenFetcher.cancelDelegationToken(httpAddress, token);
          return null;
        }
      });
  LOG.info("Cancel over HTTP done. addr="+httpAddress);
}
 
开发者ID:rekhajoshm,项目名称:mapreduce-fork,代码行数:17,代码来源:DelegationTokenRenewal.java


示例5: 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


示例6: testTokenRenewFail

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
/**
 * try to fetch token without http server with IOException
 */
@Test
public void testTokenRenewFail() throws AuthenticationException {
  try {
    DelegationTokenFetcher.renewDelegationToken(connectionFactory, serviceUrl, testToken);
    fail("Token fetcher shouldn't be able to renew tokens in absense of NN");
  } catch (IOException ex) {
  } 
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestDelegationTokenRemoteFetcher.java


示例7: expectedTokenCancelFail

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
/**
 * try cancel token without http server with IOException
 */
@Test
public void expectedTokenCancelFail() throws AuthenticationException {
  try {
    DelegationTokenFetcher.cancelDelegationToken(connectionFactory, serviceUrl, testToken);
    fail("Token fetcher shouldn't be able to cancel tokens in absense of NN");
  } catch (IOException ex) {
  } 
}
 
开发者ID:naver,项目名称:hadoop,代码行数:12,代码来源:TestDelegationTokenRemoteFetcher.java


示例8: expectedTokenRenewErrorHttpResponse

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
/**
 * try fetch token and get http response with error
 */
@Test  
public void expectedTokenRenewErrorHttpResponse()
    throws AuthenticationException, URISyntaxException {
  bootstrap = startHttpServer(httpPort, testToken, serviceUrl);
  try {
    DelegationTokenFetcher.renewDelegationToken(connectionFactory, new URI(
        serviceUrl.toString() + "/exception"), createToken(serviceUrl));
    fail("Token fetcher shouldn't be able to renew tokens using an invalid"
        + " NN URL");
  } catch (IOException ex) {
  } 
  if (assertionError != null)
    throw assertionError;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:TestDelegationTokenRemoteFetcher.java


示例9: testCancelTokenFromHttp

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
/**
 *
 */
@Test
public void testCancelTokenFromHttp() throws IOException,
    AuthenticationException {
  bootstrap = startHttpServer(httpPort, testToken, serviceUrl);
  DelegationTokenFetcher.cancelDelegationToken(connectionFactory, serviceUrl,
      testToken);
  if (assertionError != null)
    throw assertionError;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestDelegationTokenRemoteFetcher.java


示例10: testRenewTokenFromHttp

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
/**
 * Call renew token using http server return new expiration time
 */
@Test
public void testRenewTokenFromHttp() throws IOException,
    NumberFormatException, AuthenticationException {
  bootstrap = startHttpServer(httpPort, testToken, serviceUrl);
  assertTrue("testRenewTokenFromHttp error",
      Long.parseLong(EXP_DATE) == DelegationTokenFetcher.renewDelegationToken(
          connectionFactory, serviceUrl, testToken));
  if (assertionError != null)
    throw assertionError;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:14,代码来源:TestDelegationTokenRemoteFetcher.java


示例11: checkOutput

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
private void checkOutput(String[] args, String pattern, PrintStream out,
    Class<?> clazz) {       
  ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
  try {
    PipedOutputStream pipeOut = new PipedOutputStream();
    PipedInputStream pipeIn = new PipedInputStream(pipeOut, PIPE_BUFFER_SIZE);
    if (out == System.out) {
      System.setOut(new PrintStream(pipeOut));
    } else if (out == System.err) {
      System.setErr(new PrintStream(pipeOut));
    }

    if (clazz == DelegationTokenFetcher.class) {
      expectDelegationTokenFetcherExit(args);
    } else if (clazz == JMXGet.class) {
      expectJMXGetExit(args);
    } else if (clazz == DFSAdmin.class) {
      expectDfsAdminPrint(args);
    }
    pipeOut.close();
    ByteStreams.copy(pipeIn, outBytes);      
    pipeIn.close();
    assertTrue(new String(outBytes.toByteArray()).contains(pattern));            
  } catch (Exception ex) {
    fail("checkOutput error " + ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:28,代码来源:TestTools.java


示例12: 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


示例13: checkOutput

import org.apache.hadoop.hdfs.tools.DelegationTokenFetcher; //导入依赖的package包/类
private void checkOutput(String[] args, String pattern, PrintStream out,
    Class<?> clazz) {       
  ByteArrayOutputStream outBytes = new ByteArrayOutputStream();
  PrintStream oldOut = System.out;
  PrintStream oldErr = System.err;
  try {
    PipedOutputStream pipeOut = new PipedOutputStream();
    PipedInputStream pipeIn = new PipedInputStream(pipeOut, PIPE_BUFFER_SIZE);
    if (out == System.out) {
      System.setOut(new PrintStream(pipeOut));
    } else if (out == System.err) {
      System.setErr(new PrintStream(pipeOut));
    }

    if (clazz == DelegationTokenFetcher.class) {
      expectDelegationTokenFetcherExit(args);
    } else if (clazz == JMXGet.class) {
      expectJMXGetExit(args);
    } else if (clazz == DFSAdmin.class) {
      expectDfsAdminPrint(args);
    }
    pipeOut.close();
    ByteStreams.copy(pipeIn, outBytes);      
    pipeIn.close();
    assertTrue(new String(outBytes.toByteArray()).contains(pattern));            
  } catch (Exception ex) {
    fail("checkOutput error " + ex);
  } finally {
    System.setOut(oldOut);
    System.setErr(oldErr);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:33,代码来源:TestTools.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Attr类代码示例发布时间:2022-05-21
下一篇:
Java BaseTokenStreamTestCase类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap