Java 类org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager.DelegationTokenInformation 实例源码

项目:hadoop-oss    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-oss    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop    文件:TestDelegationToken.java   
@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();
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:aliyun-oss-hadoop-fs    文件:TestDelegationToken.java   
@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();
  }
}
项目:big-c    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:big-c    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop-plus    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-plus    文件:TestDelegationToken.java   
@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();
  }
}
项目:hops    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hops    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop-TCP    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-TCP    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop-on-lustre    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-on-lustre    文件:TestDelegationToken.java   
@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();
  }
}
项目:hardfs    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hardfs    文件:TestDelegationToken.java   
@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();
  }
}
项目:hadoop-on-lustre2    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hadoop-on-lustre2    文件:TestDelegationToken.java   
@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();
  }
}
项目:hortonworks-extension    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hortonworks-extension    文件:TestDelegationToken.java   
@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();
  }
}
项目:hortonworks-extension    文件:TestDelegationToken.java   
public Map<TestDelegationTokenIdentifier, DelegationTokenInformation> getAllTokens() {
  return currentTokens;
}
项目:hortonworks-extension    文件:TestDelegationToken.java   
@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();
  }
}