public NameNodeConnector(String name, URI nameNodeUri, Path idPath, List<Path> targetPaths, Configuration conf, int maxNotChangedIterations) throws IOException { this.nameNodeUri = nameNodeUri; this.idPath = idPath; this.targetPaths = targetPaths == null || targetPaths.isEmpty() ? Arrays .asList(new Path("/")) : targetPaths; this.maxNotChangedIterations = maxNotChangedIterations; this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri, NamenodeProtocol.class).getProxy(); this.client = NameNodeProxies.createProxy(conf, nameNodeUri, ClientProtocol.class, fallbackToSimpleAuth).getProxy(); this.fs = (DistributedFileSystem)FileSystem.get(nameNodeUri, conf); final NamespaceInfo namespaceinfo = namenode.versionRequest(); this.blockpoolID = namespaceinfo.getBlockPoolID(); final FsServerDefaults defaults = fs.getServerDefaults(new Path("/")); this.keyManager = new KeyManager(blockpoolID, namenode, defaults.getEncryptDataTransfer(), conf); // if it is for test, we do not create the id file if (checkOtherInstanceRunning) { out = checkAndMarkRunning(); if (out == null) { // Exit if there is another one running. throw new IOException("Another " + name + " is running."); } } }
@Override public void close() { keyManager.close(); // close the output file IOUtils.closeStream(out); if (fs != null) { try { if (checkOtherInstanceRunning) { fs.delete(idPath, true); } } catch(IOException ioe) { LOG.warn("Failed to delete " + idPath, ioe); } } }
reportedBlock.getBlock()); final KeyManager km = nnc.getKeyManager(); Token<BlockTokenIdentifier> accessToken = km.getAccessToken(eb, new StorageType[]{target.storageType}, new String[0]); IOStreamPair saslStreams = saslClient.socketSend(sock, unbufOut,
public static List<NameNodeConnector> newNameNodeConnectors( Map<URI, List<Path>> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (Map.Entry<URI, List<Path>> entry : namenodes.entrySet()) { NameNodeConnector nnc = new NameNodeConnector(name, entry.getKey(), idPath, entry.getValue(), conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }
KeyManager keyManager = new KeyManager(blockPoolId, namenode, true, conf); Whitebox.setInternalState(keyManager, "timer", fakeTimer); Whitebox.getInternalState(keyManager, "blockTokenSecretManager"), "timer", fakeTimer); final DataEncryptionKey dek = keyManager.newDataEncryptionKey(); final long remainingTime = dek.expiryDate - fakeTimer.now(); assertEquals("KeyManager dataEncryptionKey should expire in 2 seconds", keyManager.newDataEncryptionKey(); assertNotEquals("KeyManager should generate a new data encryption key", dek, dekAfterExpiration);
/** Create {@link NameNodeConnector} for the given namenodes. */ public static List<NameNodeConnector> newNameNodeConnectors( Collection<URI> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (URI uri : namenodes) { NameNodeConnector nnc = new NameNodeConnector(name, uri, idPath, null, conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }
public static List<NameNodeConnector> newNameNodeConnectors( Map<URI, List<Path>> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (Map.Entry<URI, List<Path>> entry : namenodes.entrySet()) { NameNodeConnector nnc = new NameNodeConnector(name, entry.getKey(), idPath, entry.getValue(), conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }
public NameNodeConnector(String name, URI nameNodeUri, Path idPath, List<Path> targetPaths, Configuration conf, int maxNotChangedIterations) throws IOException { this.nameNodeUri = nameNodeUri; this.idPath = idPath; this.targetPaths = targetPaths == null || targetPaths.isEmpty() ? Arrays .asList(new Path("/")) : targetPaths; this.maxNotChangedIterations = maxNotChangedIterations; this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri, NamenodeProtocol.class).getProxy(); this.client = NameNodeProxies.createProxy(conf, nameNodeUri, ClientProtocol.class, fallbackToSimpleAuth).getProxy(); this.fs = (DistributedFileSystem)FileSystem.get(nameNodeUri, conf); final NamespaceInfo namespaceinfo = namenode.versionRequest(); this.blockpoolID = namespaceinfo.getBlockPoolID(); final FsServerDefaults defaults = fs.getServerDefaults(new Path("/")); this.keyManager = new KeyManager(blockpoolID, namenode, defaults.getEncryptDataTransfer(), conf); // if it is for test, we do not create the id file out = checkAndMarkRunning(); if (out == null) { // Exit if there is another one running. throw new IOException("Another " + name + " is running."); } }
private BlockMovementStatus moveBlock() { ExtendedBlock eb = new ExtendedBlock(nnc.getBlockpoolID(), blkMovingInfo.getBlock()); final KeyManager km = nnc.getKeyManager(); Token<BlockTokenIdentifier> accessToken; try { accessToken = km.getAccessToken(eb, new StorageType[]{blkMovingInfo.getTargetStorageType()}, new String[0]); } catch (IOException e) { // TODO: handle failure retries LOG.warn( "Failed to move block:{} from src:{} to destin:{} to satisfy " + "storageType:{}", blkMovingInfo.getBlock(), blkMovingInfo.getSource(), blkMovingInfo.getTarget(), blkMovingInfo.getTargetStorageType(), e); return BlockMovementStatus.DN_BLK_STORAGE_MOVEMENT_FAILURE; } return blkDispatcher.moveBlock(blkMovingInfo, saslClient, eb, new Socket(), km, accessToken); } }
@Override public void close() { keyManager.close(); // close the output file IOUtils.closeStream(out); if (fs != null) { try { fs.delete(idPath, true); } catch(IOException ioe) { LOG.warn("Failed to delete " + idPath, ioe); } } }
public static List<NameNodeConnector> newNameNodeConnectors( Map<URI, List<Path>> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (Map.Entry<URI, List<Path>> entry : namenodes.entrySet()) { NameNodeConnector nnc = new NameNodeConnector(name, entry.getKey(), idPath, entry.getValue(), conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }
public NameNodeConnector(String name, URI nameNodeUri, Path idPath, List<Path> targetPaths, Configuration conf, int maxNotChangedIterations) throws IOException { this.nameNodeUri = nameNodeUri; this.idPath = idPath; this.targetPaths = targetPaths == null || targetPaths.isEmpty() ? Arrays .asList(new Path("/")) : targetPaths; this.maxNotChangedIterations = maxNotChangedIterations; this.namenode = NameNodeProxies.createProxy(conf, nameNodeUri, NamenodeProtocol.class).getProxy(); this.client = NameNodeProxies.createProxy(conf, nameNodeUri, ClientProtocol.class, fallbackToSimpleAuth).getProxy(); this.fs = (DistributedFileSystem)FileSystem.get(nameNodeUri, conf); final NamespaceInfo namespaceinfo = namenode.versionRequest(); this.blockpoolID = namespaceinfo.getBlockPoolID(); final FsServerDefaults defaults = fs.getServerDefaults(new Path("/")); this.keyManager = new KeyManager(blockpoolID, namenode, defaults.getEncryptDataTransfer(), conf); // if it is for test, we do not create the id file out = checkAndMarkRunning(); if (out == null) { // Exit if there is another one running. throw new IOException("Another " + name + " is running."); } }
block.getBlock()); final KeyManager km = nnc.getKeyManager(); Token<BlockTokenIdentifier> accessToken = km.getAccessToken(eb); IOStreamPair saslStreams = saslClient.socketSend(sock, unbufOut, unbufIn, km, accessToken, target.getDatanodeInfo());
@Override public void close() { keyManager.close(); // close the output file IOUtils.closeStream(out); if (fs != null) { try { fs.delete(idPath, true); } catch(IOException ioe) { LOG.warn("Failed to delete " + idPath, ioe); } } }
/** Create {@link NameNodeConnector} for the given namenodes. */ public static List<NameNodeConnector> newNameNodeConnectors( Collection<URI> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (URI uri : namenodes) { NameNodeConnector nnc = new NameNodeConnector(name, uri, idPath, null, conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }
block.getBlock()); final KeyManager km = nnc.getKeyManager(); Token<BlockTokenIdentifier> accessToken = km.getAccessToken(eb); IOStreamPair saslStreams = saslClient.socketSend(sock, unbufOut, unbufIn, km, accessToken, target.getDatanodeInfo());
/** Create {@link NameNodeConnector} for the given namenodes. */ public static List<NameNodeConnector> newNameNodeConnectors( Collection<URI> namenodes, String name, Path idPath, Configuration conf, int maxIdleIterations) throws IOException { final List<NameNodeConnector> connectors = new ArrayList<NameNodeConnector>( namenodes.size()); for (URI uri : namenodes) { NameNodeConnector nnc = new NameNodeConnector(name, uri, idPath, null, conf, maxIdleIterations); nnc.getKeyManager().startBlockKeyUpdater(); connectors.add(nnc); } return connectors; }