/** * set access token lifetime. */ public static void setBlockTokenLifetime(BlockTokenSecretManager handler, long tokenLifetime) { handler.setTokenLifetime(tokenLifetime); }
/** * set access token lifetime. */ public static void setBlockTokenLifetime(BlockTokenSecretManager handler, long tokenLifetime) { handler.setTokenLifetime(tokenLifetime); }
private static void lowerKeyUpdateIntervalAndClearKeys(FSNamesystem namesystem) { BlockTokenSecretManager btsm = namesystem.getBlockManager() .getBlockTokenSecretManager(); btsm.setKeyUpdateIntervalForTesting(2 * 1000); btsm.setTokenLifetime(2 * 1000); btsm.clearAllKeysForTesting(); }
+ blockKeyUpdateInterval / (60 * 1000) + " min(s), tokenLifetime=" + blockTokenLifetime / (60 * 1000) + " min(s)"); blockTokenSecretManager.setTokenLifetime(blockTokenLifetime);
@Test public void testLongLivedClient() throws IOException, InterruptedException { FileChecksum checksum = writeUnencryptedAndThenRestartEncryptedCluster(); BlockTokenSecretManager btsm = cluster.getNamesystem().getBlockManager() .getBlockTokenSecretManager(); btsm.setKeyUpdateIntervalForTesting(2 * 1000); btsm.setTokenLifetime(2 * 1000); btsm.clearAllKeysForTesting(); assertEquals(PLAIN_TEXT, DFSTestUtil.readFile(fs, TEST_PATH)); assertEquals(checksum, fs.getFileChecksum(TEST_PATH)); // Sleep for 15 seconds, after which the encryption key will no longer be // valid. It needs to be a few multiples of the block token lifetime, // since several block tokens are valid at any given time (the current // and the last two, by default.) LOG.info("Sleeping so that encryption keys expire..."); Thread.sleep(15 * 1000); LOG.info("Done sleeping."); assertEquals(PLAIN_TEXT, DFSTestUtil.readFile(fs, TEST_PATH)); assertEquals(checksum, fs.getFileChecksum(TEST_PATH)); }
btsm.setTokenLifetime(2 * 1000); btsm.clearAllKeysForTesting();