private void resetCoordinatorData(CoordinatorClient coordinator,CassandraTokenManager tokenManager1,CassandraTokenManager tokenManager2,Base64TokenEncoder encoder1,Base64TokenEncoder encoder2,TokenKeyGenerator tokenKeyGenerator1,TokenKeyGenerator tokenKeyGenerator2) throws Exception {
  final long ROTATION_INTERVAL_MSECS=5000;
  DbClient dbClient=getDbClient();
  coordinator=new TestCoordinator();
  tokenManager1=new CassandraTokenManager();
  encoder1=new Base64TokenEncoder();
  tokenKeyGenerator1=new TokenKeyGenerator();
  TokenMaxLifeValuesHolder holder1=new TokenMaxLifeValuesHolder();
  holder1.setKeyRotationIntervalInMSecs(ROTATION_INTERVAL_MSECS);
  tokenManager1.setTokenMaxLifeValuesHolder(holder1);
  tokenManager1.setDbClient(dbClient);
  tokenManager1.setCoordinator(coordinator);
  encoder1.setCoordinator(coordinator);
  tokenKeyGenerator1.setTokenMaxLifeValuesHolder(holder1);
  encoder1.setTokenKeyGenerator(tokenKeyGenerator1);
  encoder1.managerInit();
  tokenManager1.setTokenEncoder(encoder1);
  tokenManager2=new CassandraTokenManager();
  encoder2=new Base64TokenEncoder();
  tokenKeyGenerator2=new TokenKeyGenerator();
  TokenMaxLifeValuesHolder holder2=new TokenMaxLifeValuesHolder();
  holder2.setKeyRotationIntervalInMSecs(ROTATION_INTERVAL_MSECS);
  tokenManager2.setTokenMaxLifeValuesHolder(holder2);
  tokenManager2.setDbClient(dbClient);
  tokenManager2.setCoordinator(coordinator);
  encoder2.setCoordinator(coordinator);
  tokenKeyGenerator2.setTokenMaxLifeValuesHolder(holder2);
  encoder2.setTokenKeyGenerator(tokenKeyGenerator2);
  encoder2.managerInit();
  tokenManager2.setTokenEncoder(encoder2);
  StorageOSUserDAO userDAO=new StorageOSUserDAO();
  userDAO.setUserName("user1");
  final String token1=tokenManager1.getToken(userDAO);
  Assert.assertNotNull(token1);
  TokenOnWire tw1=encoder1.decode(token1);
  String key1=tw1.getEncryptionKeyId();
  final String token2=tokenManager2.getToken(userDAO);
  Assert.assertNotNull(token2);
  TokenOnWire tw2=encoder2.decode(token2);
  String key2=tw2.getEncryptionKeyId();
  Assert.assertEquals(key1,key2);
}

private void resetCoordinatorData ( CoordinatorClient coordinator , CassandraTokenManager tokenManager1 , CassandraTokenManager tokenManager2 , Base64TokenEncoder encoder1 , Base64TokenEncoder encoder2 , TokenKeyGenerator tokenKeyGenerator1 , TokenKeyGenerator tokenKeyGenerator2 ) throws Exception { final long ROTATION_INTERVAL_MSECS = 5000 ; DbClient dbClient = getDbClient ( ) ; coordinator = new TestCoordinator ( ) ; tokenManager1 = new CassandraTokenManager ( ) ; encoder1 = new Base64TokenEncoder ( ) ; tokenKeyGenerator1 = new TokenKeyGenerator ( ) ; TokenMaxLifeValuesHolder holder1 = new TokenMaxLifeValuesHolder ( ) ; holder1 . setKeyRotationIntervalInMSecs ( ROTATION_INTERVAL_MSECS ) ; tokenManager1 . setTokenMaxLifeValuesHolder ( holder1 ) ; tokenManager1 . setDbClient ( dbClient ) ; tokenManager1 . setCoordinator ( coordinator ) ; encoder1 . setCoordinator ( coordinator ) ; tokenKeyGenerator1 . setTokenMaxLifeValuesHolder ( holder1 ) ; encoder1 . setTokenKeyGenerator ( tokenKeyGenerator1 ) ; encoder1 . managerInit ( ) ; tokenManager1 . setTokenEncoder ( encoder1 ) ; tokenManager2 = new CassandraTokenManager ( ) ; encoder2 = new Base64TokenEncoder ( ) ; tokenKeyGenerator2 = new TokenKeyGenerator ( ) ; TokenMaxLifeValuesHolder holder2 = new TokenMaxLifeValuesHolder ( ) ; holder2 . setKeyRotationIntervalInMSecs ( ROTATION_INTERVAL_MSECS ) ; tokenManager2 . setTokenMaxLifeValuesHolder ( holder2 ) ; tokenManager2 . setDbClient ( dbClient ) ; tokenManager2 . setCoordinator ( coordinator ) ; encoder2 . setCoordinator ( coordinator ) ; tokenKeyGenerator2 . setTokenMaxLifeValuesHolder ( holder2 ) ; encoder2 . setTokenKeyGenerator ( tokenKeyGenerator2 ) ; encoder2 . managerInit ( ) ; tokenManager2 . setTokenEncoder ( encoder2 ) ; StorageOSUserDAO userDAO = new StorageOSUserDAO ( ) ; userDAO . setUserName ( "user1" ) ; final String token1 = tokenManager1 . getToken ( userDAO ) ; Assert . assertNotNull ( token1 ) ; TokenOnWire tw1 = encoder1 . decode ( token1 ) ; String key1 = tw1 . getEncryptionKeyId ( ) ; final String token2 = tokenManager2 . getToken ( userDAO ) ; Assert . assertNotNull ( token2 ) ; TokenOnWire tw2 = encoder2 . decode ( token2 ) ; String key2 = tw2 . getEncryptionKeyId ( ) ; Assert . assertEquals ( key1 , key2 ) ; }
convenience function to reset the coordinator data , call init on the two involved nodes , and check they agree on the curent key id .
