HDFS-3214. InterDatanodeProtocolServerSideTranslatorPB doesn't handle null response from initReplicaRecovery. Contributed by Todd Lipcon.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1311125 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
74b4b45651
commit
ee5daee1b7
|
@ -453,6 +453,9 @@ Release 2.0.0 - UNRELEASED
|
||||||
HDFS-3136. Remove SLF4J dependency as HDFS does not need it to fix
|
HDFS-3136. Remove SLF4J dependency as HDFS does not need it to fix
|
||||||
unnecessary warnings. (Jason Lowe via suresh)
|
unnecessary warnings. (Jason Lowe via suresh)
|
||||||
|
|
||||||
|
HDFS-3214. InterDatanodeProtocolServerSideTranslatorPB doesn't handle
|
||||||
|
null response from initReplicaRecovery (todd)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-1623 SUBTASKS
|
BREAKDOWN OF HDFS-1623 SUBTASKS
|
||||||
|
|
||||||
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)
|
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)
|
||||||
|
|
|
@ -56,9 +56,17 @@ public class InterDatanodeProtocolServerSideTranslatorPB implements
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ServiceException(e);
|
throw new ServiceException(e);
|
||||||
}
|
}
|
||||||
return InitReplicaRecoveryResponseProto.newBuilder()
|
|
||||||
.setBlock(PBHelper.convert(r))
|
if (r == null) {
|
||||||
.setState(PBHelper.convert(r.getOriginalReplicaState())).build();
|
return InitReplicaRecoveryResponseProto.newBuilder()
|
||||||
|
.setReplicaFound(false)
|
||||||
|
.build();
|
||||||
|
} else {
|
||||||
|
return InitReplicaRecoveryResponseProto.newBuilder()
|
||||||
|
.setReplicaFound(true)
|
||||||
|
.setBlock(PBHelper.convert(r))
|
||||||
|
.setState(PBHelper.convert(r.getOriginalReplicaState())).build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -85,6 +85,17 @@ public class InterDatanodeProtocolTranslatorPB implements
|
||||||
} catch (ServiceException e) {
|
} catch (ServiceException e) {
|
||||||
throw ProtobufHelper.getRemoteException(e);
|
throw ProtobufHelper.getRemoteException(e);
|
||||||
}
|
}
|
||||||
|
if (!resp.getReplicaFound()) {
|
||||||
|
// No replica found on the remote node.
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (!resp.hasBlock() || !resp.hasState()) {
|
||||||
|
throw new IOException("Replica was found but missing fields. " +
|
||||||
|
"Req: " + req + "\n" +
|
||||||
|
"Resp: " + resp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BlockProto b = resp.getBlock();
|
BlockProto b = resp.getBlock();
|
||||||
return new ReplicaRecoveryInfo(b.getBlockId(), b.getNumBytes(),
|
return new ReplicaRecoveryInfo(b.getBlockId(), b.getNumBytes(),
|
||||||
b.getGenStamp(), PBHelper.convert(resp.getState()));
|
b.getGenStamp(), PBHelper.convert(resp.getState()));
|
||||||
|
|
|
@ -38,8 +38,11 @@ message InitReplicaRecoveryRequestProto {
|
||||||
* Repica recovery information
|
* Repica recovery information
|
||||||
*/
|
*/
|
||||||
message InitReplicaRecoveryResponseProto {
|
message InitReplicaRecoveryResponseProto {
|
||||||
required ReplicaStateProto state = 1; // State of the replica
|
required bool replicaFound = 1;
|
||||||
required BlockProto block = 2; // block information
|
|
||||||
|
// The following entries are not set if there was no replica found.
|
||||||
|
optional ReplicaStateProto state = 2; // State of the replica
|
||||||
|
optional BlockProto block = 3; // block information
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
|
package org.apache.hadoop.hdfs.server.datanode.fsdataset.impl;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.*;
|
||||||
import static org.junit.Assert.fail;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
|
@ -172,6 +171,13 @@ public class TestInterDatanodeProtocol {
|
||||||
b.getBlockId(), b.getNumBytes()/2, b.getGenerationStamp()+1);
|
b.getBlockId(), b.getNumBytes()/2, b.getGenerationStamp()+1);
|
||||||
idp.updateReplicaUnderRecovery(b, recoveryId, newblock.getNumBytes());
|
idp.updateReplicaUnderRecovery(b, recoveryId, newblock.getNumBytes());
|
||||||
checkMetaInfo(newblock, datanode);
|
checkMetaInfo(newblock, datanode);
|
||||||
|
|
||||||
|
// Verify correct null response trying to init recovery for a missing block
|
||||||
|
ExtendedBlock badBlock = new ExtendedBlock("fake-pool",
|
||||||
|
b.getBlockId(), 0, 0);
|
||||||
|
assertNull(idp.initReplicaRecovery(
|
||||||
|
new RecoveringBlock(badBlock,
|
||||||
|
locatedblock.getLocations(), recoveryId)));
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if (cluster != null) {cluster.shutdown();}
|
if (cluster != null) {cluster.shutdown();}
|
||||||
|
|
Loading…
Reference in New Issue