/** * Convenience method, which unwraps RemoteException. * @throws IOException not a RemoteException. */ private static ReplicaRecoveryInfo callInitReplicaRecovery( InterDatanodeProtocol datanode, RecoveringBlock rBlock) throws IOException { try { return datanode.initReplicaRecovery(rBlock); } catch(RemoteException re) { throw re.unwrapRemoteException(); } }
private void updateReplicaUnderRecovery(String bpid, long recoveryId, long newBlockId, long newLength) throws IOException { final ExtendedBlock b = new ExtendedBlock(bpid, rInfo); storageID = datanode.updateReplicaUnderRecovery(b, recoveryId, newBlockId, newLength); }
checkMetaInfo(b, datanode); long recoveryId = b.getGenerationStamp() + 1; idp.initReplicaRecovery( new RecoveringBlock(b, locatedblock.getLocations(), recoveryId)); idp.updateReplicaUnderRecovery(b, recoveryId, newblock.getNumBytes()); checkMetaInfo(newblock, datanode);
r.datanode.updateBlock(r.block, newblock, closeFile); successList.add(r.id); } catch (IOException e) {
: DataNode.createInterDataNodeProtocolProxy( id, getConf(), socketTimeout, connectToDnViaHostname); BlockRecoveryInfo info = datanode.startBlockRecovery(block); if (info == null) { LOG.info("No block metadata found for " + block + " on datanode "
public Boolean call() throws Exception { InterDatanodeProtocol remoteDatanode = null; try { File srcBlockFile = data.getBlockFile(srcNamespaceId, srcBlock); remoteDatanode = DataNode .createInterDataNodeProtocolProxy(target, getConf(), socketTimeout); remoteDatanode.copyBlockLocal(srcFileSystem, srcNamespaceId, srcBlock, dstNamespaceId, dstBlock, srcBlockFile.getAbsolutePath()); } catch (IOException e) { LOG.warn("Cross datanode local block copy failed", e); throw e; } finally { if (remoteDatanode != null) { stopDatanodeProxy(remoteDatanode); } } return true; } }
InterDatanodeProtocol datanode = dnRegistration.equals(id)? this: DataNode.createInterDataNodeProtocolProxy(id, getConf()); BlockMetaDataInfo info = datanode.getBlockMetaDataInfo(block); if (info != null && info.getGenerationStamp() >= block.getGenerationStamp()) { if (keepLength) {
checkMetaInfo(b, datanode); long recoveryId = b.getGenerationStamp() + 1; idp.initReplicaRecovery( new RecoveringBlock(b, locatedblock.getLocations(), recoveryId)); idp.updateReplicaUnderRecovery(b, recoveryId, b.getBlockId(), newblock.getNumBytes()); checkMetaInfo(newblock, datanode); assertNull(idp.initReplicaRecovery( new RecoveringBlock(badBlock, locatedblock.getLocations(), recoveryId)));
throwIfAfterTime(deadline); LOG.info("Updating block " + r + " to " + newblock); r.datanode.updateBlock(namespaceId, r.info.getBlock(), newblock, closeFile); successList.add(r.id); } catch (BlockRecoveryTimeoutException e) {
BlockRecoveryInfo info = datanode.startBlockRecovery(namespaceId, block); if (info == null) { LOG.info("No block metadata found for block " + block + " on datanode "
@Override public UpdateReplicaUnderRecoveryResponseProto updateReplicaUnderRecovery( RpcController unused, UpdateReplicaUnderRecoveryRequestProto request) throws ServiceException { final String storageID; try { storageID = impl.updateReplicaUnderRecovery( PBHelperClient.convert(request.getBlock()), request.getRecoveryId(), request.getNewBlockId(), request.getNewLength()); } catch (IOException e) { throw new ServiceException(e); } return UpdateReplicaUnderRecoveryResponseProto.newBuilder() .setStorageUuid(storageID).build(); } }
@Override public InitReplicaRecoveryResponseProto initReplicaRecovery( RpcController unused, InitReplicaRecoveryRequestProto request) throws ServiceException { RecoveringBlock b = PBHelper.convert(request.getBlock()); ReplicaRecoveryInfo r; try { r = impl.initReplicaRecovery(b); } catch (IOException e) { throw new ServiceException(e); } if (r == null) { return InitReplicaRecoveryResponseProto.newBuilder() .setReplicaFound(false) .build(); } else { return InitReplicaRecoveryResponseProto.newBuilder() .setReplicaFound(true) .setBlock(PBHelperClient.convert(r)) .setState(PBHelper.convert(r.getOriginalReplicaState())).build(); } }
r.datanode.updateBlock(r.info.getBlock(), newblock, closeFile); successList.add(r.id); } catch (IOException e) {
void updateReplicaUnderRecovery(String bpid, long recoveryId, long newBlockId, long newLength) throws IOException { final ExtendedBlock b = new ExtendedBlock(bpid, rInfo); storageID = datanode.updateReplicaUnderRecovery(b, recoveryId, newBlockId, newLength); }
/** * Convenience method, which unwraps RemoteException. * @throws IOException not a RemoteException. */ private static ReplicaRecoveryInfo callInitReplicaRecovery( InterDatanodeProtocol datanode, RecoveringBlock rBlock) throws IOException { try { return datanode.initReplicaRecovery(rBlock); } catch(RemoteException re) { throw re.unwrapRemoteException(); } }
void updateReplicaUnderRecovery(String bpid, long recoveryId, long newBlockId, long newLength) throws IOException { final ExtendedBlock b = new ExtendedBlock(bpid, rInfo); storageID = datanode.updateReplicaUnderRecovery(b, recoveryId, newBlockId, newLength); }
/** * Convenience method, which unwraps RemoteException. * @throws IOException not a RemoteException. */ private static ReplicaRecoveryInfo callInitReplicaRecovery( InterDatanodeProtocol datanode, RecoveringBlock rBlock) throws IOException { try { return datanode.initReplicaRecovery(rBlock); } catch(RemoteException re) { throw re.unwrapRemoteException(); } }
/** * BlockRecovery_02.12. * One replica is RBW and another is RWR. * @throws IOException in case of an error */ @Test public void testRBW_RWRReplicas() throws IOException { if(LOG.isDebugEnabled()) { LOG.debug("Running " + GenericTestUtils.getMethodName()); } ReplicaRecoveryInfo replica1 = new ReplicaRecoveryInfo(BLOCK_ID, REPLICA_LEN1, GEN_STAMP-1, ReplicaState.RBW); ReplicaRecoveryInfo replica2 = new ReplicaRecoveryInfo(BLOCK_ID, REPLICA_LEN1, GEN_STAMP-2, ReplicaState.RWR); InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class); InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class); testSyncReplicas(replica1, replica2, dn1, dn2, REPLICA_LEN1); verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, REPLICA_LEN1); verify(dn2, never()).updateReplicaUnderRecovery( block, RECOVERY_ID, REPLICA_LEN1); }
@Override public InitReplicaRecoveryResponseProto initReplicaRecovery( RpcController unused, InitReplicaRecoveryRequestProto request) throws ServiceException { RecoveringBlock b = PBHelper.convert(request.getBlock()); ReplicaRecoveryInfo r; try { r = impl.initReplicaRecovery(b); } catch (IOException e) { throw new ServiceException(e); } if (r == null) { return InitReplicaRecoveryResponseProto.newBuilder() .setReplicaFound(false) .build(); } else { return InitReplicaRecoveryResponseProto.newBuilder() .setReplicaFound(true) .setBlock(PBHelper.convert(r)) .setState(PBHelper.convert(r.getOriginalReplicaState())).build(); } }
/** * BlockRecovery_02.11. * Two replicas are RBW. * @throws IOException in case of an error */ @Test public void testRBWReplicas() throws IOException { if(LOG.isDebugEnabled()) { LOG.debug("Running " + GenericTestUtils.getMethodName()); } ReplicaRecoveryInfo replica1 = new ReplicaRecoveryInfo(BLOCK_ID, REPLICA_LEN1, GEN_STAMP-1, ReplicaState.RBW); ReplicaRecoveryInfo replica2 = new ReplicaRecoveryInfo(BLOCK_ID, REPLICA_LEN2, GEN_STAMP-2, ReplicaState.RBW); InterDatanodeProtocol dn1 = mock(InterDatanodeProtocol.class); InterDatanodeProtocol dn2 = mock(InterDatanodeProtocol.class); long minLen = Math.min(REPLICA_LEN1, REPLICA_LEN2); testSyncReplicas(replica1, replica2, dn1, dn2, minLen); verify(dn1).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen); verify(dn2).updateReplicaUnderRecovery(block, RECOVERY_ID, minLen); }