/** * See {@link BlockTokenSecretManager#addKeys(ExportedBlockKeys)} */ public void addKeys(String bpid, ExportedBlockKeys exportedKeys) throws IOException { get(bpid).addKeys(exportedKeys); }
@Override public void run() { try { while (shouldRun) { try { blockTokenSecretManager.addKeys(namenode.getBlockKeys()); } catch (IOException e) { LOG.error("Failed to set keys", e); } Thread.sleep(sleepInterval); } } catch (InterruptedException e) { LOG.debug("InterruptedException in block key updater thread", e); } catch (Throwable e) { LOG.error("Exception in block key updater thread", e); shouldRun = false; } }
updateInterval, tokenLifetime, blockpoolID, encryptionAlgorithm, enableProtobuf); this.blockTokenSecretManager.addKeys(keys);
/** * See {@link BlockTokenSecretManager#addKeys(ExportedBlockKeys)} */ public void addKeys(String bpid, ExportedBlockKeys exportedKeys) throws IOException { get(bpid).addKeys(exportedKeys); }
/** * See {@link BlockTokenSecretManager#addKeys(ExportedBlockKeys)} */ public void addKeys(String bpid, ExportedBlockKeys exportedKeys) throws IOException { get(bpid).addKeys(exportedKeys); }
@Override public void run() { try { while (shouldRun) { try { blockTokenSecretManager.addKeys(namenode.getBlockKeys()); } catch (IOException e) { LOG.error("Failed to set keys", e); } Thread.sleep(sleepInterval); } } catch (InterruptedException e) { LOG.debug("InterruptedException in block key updater thread", e); } catch (Throwable e) { LOG.error("Exception in block key updater thread", e); shouldRun = false; } }
@Override public void run() { try { while (shouldRun) { try { blockTokenSecretManager.addKeys(namenode.getBlockKeys()); } catch (IOException e) { LOG.error("Failed to set keys", e); } Thread.sleep(sleepInterval); } } catch (InterruptedException e) { LOG.debug("InterruptedException in block key updater thread", e); } catch (Throwable e) { LOG.error("Exception in block key updater thread", e); shouldRun = false; } }
public KeyManager(String blockpoolID, NamenodeProtocol namenode, boolean encryptDataTransfer, Configuration conf) throws IOException { this.namenode = namenode; this.encryptDataTransfer = encryptDataTransfer; this.timer = new Timer(); final ExportedBlockKeys keys = namenode.getBlockKeys(); this.isBlockTokenEnabled = keys.isBlockTokenEnabled(); if (isBlockTokenEnabled) { long updateInterval = keys.getKeyUpdateInterval(); long tokenLifetime = keys.getTokenLifetime(); LOG.info("Block token params received from NN: update interval=" + StringUtils.formatTime(updateInterval) + ", token lifetime=" + StringUtils.formatTime(tokenLifetime)); String encryptionAlgorithm = conf.get( DFSConfigKeys.DFS_DATA_ENCRYPTION_ALGORITHM_KEY); this.blockTokenSecretManager = new BlockTokenSecretManager( updateInterval, tokenLifetime, blockpoolID, encryptionAlgorithm); this.blockTokenSecretManager.addKeys(keys); // sync block keys with NN more frequently than NN updates its block keys this.blockKeyUpdater = new BlockKeyUpdater(updateInterval / 4); this.shouldRun = true; } else { this.blockTokenSecretManager = null; this.blockKeyUpdater = null; } }
public KeyManager(String blockpoolID, NamenodeProtocol namenode, boolean encryptDataTransfer, Configuration conf) throws IOException { this.namenode = namenode; this.encryptDataTransfer = encryptDataTransfer; this.timer = new Timer(); final ExportedBlockKeys keys = namenode.getBlockKeys(); this.isBlockTokenEnabled = keys.isBlockTokenEnabled(); if (isBlockTokenEnabled) { long updateInterval = keys.getKeyUpdateInterval(); long tokenLifetime = keys.getTokenLifetime(); LOG.info("Block token params received from NN: update interval=" + StringUtils.formatTime(updateInterval) + ", token lifetime=" + StringUtils.formatTime(tokenLifetime)); String encryptionAlgorithm = conf.get( DFSConfigKeys.DFS_DATA_ENCRYPTION_ALGORITHM_KEY); this.blockTokenSecretManager = new BlockTokenSecretManager( updateInterval, tokenLifetime, blockpoolID, encryptionAlgorithm); this.blockTokenSecretManager.addKeys(keys); // sync block keys with NN more frequently than NN updates its block keys this.blockKeyUpdater = new BlockKeyUpdater(updateInterval / 4); this.shouldRun = true; } else { this.blockTokenSecretManager = null; this.blockKeyUpdater = null; } }
/** test block key and token handling */ @Test public void testBlockTokenSecretManager() throws Exception { BlockTokenSecretManager masterHandler = new BlockTokenSecretManager( blockKeyUpdateInterval, blockTokenLifetime, 0, "fake-pool", null); BlockTokenSecretManager slaveHandler = new BlockTokenSecretManager( blockKeyUpdateInterval, blockTokenLifetime, "fake-pool", null); ExportedBlockKeys keys = masterHandler.exportKeys(); slaveHandler.addKeys(keys); tokenGenerationAndVerification(masterHandler, slaveHandler); // key updating masterHandler.updateKeys(); tokenGenerationAndVerification(masterHandler, slaveHandler); keys = masterHandler.exportKeys(); slaveHandler.addKeys(keys); tokenGenerationAndVerification(masterHandler, slaveHandler); }