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


Java DelegationTokenInformation类代码示例

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


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

示例1: getAllTokens

import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation; //导入依赖的package包/类
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:4,代码来源:TestDelegationToken.java

示例2: testParallelDelegationTokenCreation

import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation; //导入依赖的package包/类
@Test
public void testParallelDelegationTokenCreation() throws Exception {
  final TestDelegationTokenSecretManager dtSecretManager = 
      new TestDelegationTokenSecretManager(2000, 24 * 60 * 60 * 1000, 
          7 * 24 * 60 * 60 * 1000, 2000);
  try {
    dtSecretManager.startThreads();
    int numThreads = 100;
    final int numTokensPerThread = 100;
    class tokenIssuerThread implements Runnable {

      @Override
      public void run() {
        for(int i =0;i <numTokensPerThread; i++) {
          generateDelegationToken(dtSecretManager, "auser", "arenewer");
          try {
            Thread.sleep(250); 
          } catch (Exception e) {
          }
        }
      }
    }
    Thread[] issuers = new Thread[numThreads];
    for (int i =0; i <numThreads; i++) {
      issuers[i] = new Daemon(new tokenIssuerThread());
      issuers[i].start();
    }
    for (int i =0; i <numThreads; i++) {
      issuers[i].join();
    }
    Map<TestDelegationTokenIdentifier, DelegationTokenInformation> tokenCache = dtSecretManager
        .getAllTokens();
    Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
    Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
    while (iter.hasNext()) {
      TestDelegationTokenIdentifier id = iter.next();
      DelegationTokenInformation info = tokenCache.get(id);
      Assert.assertTrue(info != null);
      DelegationKey key = dtSecretManager.getKey(id);
      Assert.assertTrue(key != null);
      byte[] storedPassword = dtSecretManager.retrievePassword(id);
      byte[] password = dtSecretManager.createPassword(id, key);
      Assert.assertTrue(Arrays.equals(password, storedPassword));
      //verify by secret manager api
      dtSecretManager.verifyToken(id, password);
    }
  } finally {
    dtSecretManager.stopThreads();
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:51,代码来源:TestDelegationToken.java

示例3: testParallelDelegationTokenCreation

import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation; //导入依赖的package包/类
@Test
public void testParallelDelegationTokenCreation() throws Exception {
  final TestDelegationTokenSecretManager dtSecretManager = 
      new TestDelegationTokenSecretManager(2000, 24 * 60 * 60 * 1000, 
          7 * 24 * 60 * 60 * 1000, 2000);
  try {
    dtSecretManager.startThreads();
    int numThreads = 100;
    final int numTokensPerThread = 100;
    class tokenIssuerThread implements Runnable {

      public void run() {
        for(int i =0;i <numTokensPerThread; i++) {
          generateDelegationToken(dtSecretManager, "auser", "arenewer");
          try {
            Thread.sleep(250); 
          } catch (Exception e) {
          }
        }
      }
    }
    Thread[] issuers = new Thread[numThreads];
    for (int i =0; i <numThreads; i++) {
      issuers[i] = new Daemon(new tokenIssuerThread());
      issuers[i].start();
    }
    for (int i =0; i <numThreads; i++) {
      issuers[i].join();
    }
    Map<TestDelegationTokenIdentifier, DelegationTokenInformation> tokenCache = dtSecretManager
        .getAllTokens();
    Assert.assertEquals(numTokensPerThread*numThreads, tokenCache.size());
    Iterator<TestDelegationTokenIdentifier> iter = tokenCache.keySet().iterator();
    while (iter.hasNext()) {
      TestDelegationTokenIdentifier id = iter.next();
      DelegationTokenInformation info = tokenCache.get(id);
      Assert.assertTrue(info != null);
      DelegationKey key = dtSecretManager.getKey(id);
      Assert.assertTrue(key != null);
      byte[] storedPassword = dtSecretManager.retrievePassword(id);
      byte[] password = dtSecretManager.createPassword(id, key);
      Assert.assertTrue(Arrays.equals(password, storedPassword));
      //verify by secret manager api
      dtSecretManager.verifyToken(id, password);
    }
  } finally {
    dtSecretManager.stopThreads();
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:50,代码来源:TestDelegationToken.java


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