public ExportedBlockKeys(boolean isBlockTokenEnabled, long keyUpdateInterval, long tokenLifetime, BlockKey currentKey, BlockKey[] allKeys) { this.isBlockTokenEnabled = isBlockTokenEnabled; this.keyUpdateInterval = keyUpdateInterval; this.tokenLifetime = tokenLifetime; this.currentKey = currentKey == null ? new BlockKey() : currentKey; this.allKeys = allKeys == null ? new BlockKey[0] : allKeys; }
public ExportedBlockKeys() { this(false, 0, 0, new BlockKey(), new BlockKey[0]); }
/** */ @Override public void readFields(DataInput in) throws IOException { isBlockTokenEnabled = in.readBoolean(); keyUpdateInterval = in.readLong(); tokenLifetime = in.readLong(); currentKey.readFields(in); this.allKeys = new BlockKey[in.readInt()]; for (int i = 0; i < allKeys.length; i++) { allKeys[i] = new BlockKey(); allKeys[i].readFields(in); } }
public static BlockKey convert(BlockKeyProto k) { return new BlockKey(k.getKeyId(), k.getExpiryDate(), k.getKeyBytes() .toByteArray()); }
/** * Update block keys, only to be used in master mode */ synchronized boolean updateKeys() throws IOException { if (!isMaster) { return false; } LOG.info("Updating block keys"); removeExpiredKeys(); // set final expiry date of retiring currentKey allKeys.put(currentKey.getKeyId(), new BlockKey(currentKey.getKeyId(), timer.now() + keyUpdateInterval + tokenLifetime, currentKey.getKey())); // update the estimated expiry date of new currentKey currentKey = new BlockKey(nextKey.getKeyId(), timer.now() + 2 * keyUpdateInterval + tokenLifetime, nextKey.getKey()); allKeys.put(currentKey.getKeyId(), currentKey); // generate a new nextKey setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(nextKey.getKeyId(), nextKey); return true; }
/** Initialize block keys */ private synchronized void generateKeys() { if (!isMaster) { return; } /* * Need to set estimated expiry dates for currentKey and nextKey so that if * NN crashes, DN can still expire those keys. NN will stop using the newly * generated currentKey after the first keyUpdateInterval, however it may * still be used by DN and Balancer to generate new tokens before they get a * chance to sync their keys with NN. Since we require keyUpdInterval to be * long enough so that all live DN's and Balancer will sync their keys with * NN at least once during the period, the estimated expiry date for * currentKey is set to now() + 2 * keyUpdateInterval + tokenLifetime. * Similarly, the estimated expiry date for nextKey is one keyUpdateInterval * more. */ setSerialNo(serialNo + 1); currentKey = new BlockKey(serialNo, timer.now() + 2 * keyUpdateInterval + tokenLifetime, generateSecret()); setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(currentKey.getKeyId(), currentKey); allKeys.put(nextKey.getKeyId(), nextKey); }
public ExportedBlockKeys() { this(false, 0, 0, new BlockKey(), new BlockKey[0]); }
public ExportedBlockKeys(boolean isBlockTokenEnabled, long keyUpdateInterval, long tokenLifetime, BlockKey currentKey, BlockKey[] allKeys) { this.isBlockTokenEnabled = isBlockTokenEnabled; this.keyUpdateInterval = keyUpdateInterval; this.tokenLifetime = tokenLifetime; this.currentKey = currentKey == null ? new BlockKey() : currentKey; this.allKeys = allKeys == null ? new BlockKey[0] : allKeys; }
public ExportedBlockKeys(boolean isBlockTokenEnabled, long keyUpdateInterval, long tokenLifetime, BlockKey currentKey, BlockKey[] allKeys) { this.isBlockTokenEnabled = isBlockTokenEnabled; this.keyUpdateInterval = keyUpdateInterval; this.tokenLifetime = tokenLifetime; this.currentKey = currentKey == null ? new BlockKey() : currentKey; this.allKeys = allKeys == null ? new BlockKey[0] : allKeys; }
public ExportedBlockKeys() { this(false, 0, 0, new BlockKey(), new BlockKey[0]); }
/** */ @Override public void readFields(DataInput in) throws IOException { isBlockTokenEnabled = in.readBoolean(); keyUpdateInterval = in.readLong(); tokenLifetime = in.readLong(); currentKey.readFields(in); this.allKeys = new BlockKey[in.readInt()]; for (int i = 0; i < allKeys.length; i++) { allKeys[i] = new BlockKey(); allKeys[i].readFields(in); } }
/** */ @Override public void readFields(DataInput in) throws IOException { isBlockTokenEnabled = in.readBoolean(); keyUpdateInterval = in.readLong(); tokenLifetime = in.readLong(); currentKey.readFields(in); this.allKeys = new BlockKey[in.readInt()]; for (int i = 0; i < allKeys.length; i++) { allKeys[i] = new BlockKey(); allKeys[i].readFields(in); } }
private static BlockKey getBlockKey(int keyId) { return new BlockKey(keyId, 10, "encodedKey".getBytes()); }
public static BlockKey convert(BlockKeyProto k) { return new BlockKey(k.getKeyId(), k.getExpiryDate(), k.getKeyBytes() .toByteArray()); }
public static BlockKey convert(BlockKeyProto k) { return new BlockKey(k.getKeyId(), k.getExpiryDate(), k.getKeyBytes() .toByteArray()); }
/** Initialize block keys */ private synchronized void generateKeys() { if (!isMaster) return; /* * Need to set estimated expiry dates for currentKey and nextKey so that if * NN crashes, DN can still expire those keys. NN will stop using the newly * generated currentKey after the first keyUpdateInterval, however it may * still be used by DN and Balancer to generate new tokens before they get a * chance to sync their keys with NN. Since we require keyUpdInterval to be * long enough so that all live DN's and Balancer will sync their keys with * NN at least once during the period, the estimated expiry date for * currentKey is set to now() + 2 * keyUpdateInterval + tokenLifetime. * Similarly, the estimated expiry date for nextKey is one keyUpdateInterval * more. */ setSerialNo(serialNo + 1); currentKey = new BlockKey(serialNo, timer.now() + 2 * keyUpdateInterval + tokenLifetime, generateSecret()); setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(currentKey.getKeyId(), currentKey); allKeys.put(nextKey.getKeyId(), nextKey); }
/** * Update block keys, only to be used in master mode */ synchronized boolean updateKeys() throws IOException { if (!isMaster) return false; LOG.info("Updating block keys"); removeExpiredKeys(); // set final expiry date of retiring currentKey allKeys.put(currentKey.getKeyId(), new BlockKey(currentKey.getKeyId(), timer.now() + keyUpdateInterval + tokenLifetime, currentKey.getKey())); // update the estimated expiry date of new currentKey currentKey = new BlockKey(nextKey.getKeyId(), timer.now() + 2 * keyUpdateInterval + tokenLifetime, nextKey.getKey()); allKeys.put(currentKey.getKeyId(), currentKey); // generate a new nextKey setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(nextKey.getKeyId(), nextKey); return true; }
/** Initialize block keys */ private synchronized void generateKeys() { if (!isMaster) return; /* * Need to set estimated expiry dates for currentKey and nextKey so that if * NN crashes, DN can still expire those keys. NN will stop using the newly * generated currentKey after the first keyUpdateInterval, however it may * still be used by DN and Balancer to generate new tokens before they get a * chance to sync their keys with NN. Since we require keyUpdInterval to be * long enough so that all live DN's and Balancer will sync their keys with * NN at least once during the period, the estimated expiry date for * currentKey is set to now() + 2 * keyUpdateInterval + tokenLifetime. * Similarly, the estimated expiry date for nextKey is one keyUpdateInterval * more. */ setSerialNo(serialNo + 1); currentKey = new BlockKey(serialNo, timer.now() + 2 * keyUpdateInterval + tokenLifetime, generateSecret()); setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(currentKey.getKeyId(), currentKey); allKeys.put(nextKey.getKeyId(), nextKey); }
/** * Update block keys, only to be used in master mode */ synchronized boolean updateKeys() throws IOException { if (!isMaster) return false; LOG.info("Updating block keys"); removeExpiredKeys(); // set final expiry date of retiring currentKey allKeys.put(currentKey.getKeyId(), new BlockKey(currentKey.getKeyId(), timer.now() + keyUpdateInterval + tokenLifetime, currentKey.getKey())); // update the estimated expiry date of new currentKey currentKey = new BlockKey(nextKey.getKeyId(), timer.now() + 2 * keyUpdateInterval + tokenLifetime, nextKey.getKey()); allKeys.put(currentKey.getKeyId(), currentKey); // generate a new nextKey setSerialNo(serialNo + 1); nextKey = new BlockKey(serialNo, timer.now() + 3 * keyUpdateInterval + tokenLifetime, generateSecret()); allKeys.put(nextKey.getKeyId(), nextKey); return true; }