HDFS-4369. GetBlockKeysResponseProto does not handle null response. Contributed by Suresh Srinivas.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1433206 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Suresh Srinivas 2013-01-14 23:13:27 +00:00
parent 0671176111
commit 6dbc7e03e5
4 changed files with 13 additions and 5 deletions

View File

@ -311,6 +311,8 @@ Release 2.0.3-alpha - Unreleased
HDFS-4364. GetLinkTargetResponseProto does not handle null path. (suresh) HDFS-4364. GetLinkTargetResponseProto does not handle null path. (suresh)
HDFS-4369. GetBlockKeysResponseProto does not handle null response.
(suresh)
NEW FEATURES NEW FEATURES

View File

@ -91,8 +91,12 @@ public class NamenodeProtocolServerSideTranslatorPB implements
} catch (IOException e) { } catch (IOException e) {
throw new ServiceException(e); throw new ServiceException(e);
} }
return GetBlockKeysResponseProto.newBuilder() GetBlockKeysResponseProto.Builder builder =
.setKeys(PBHelper.convert(keys)).build(); GetBlockKeysResponseProto.newBuilder();
if (keys != null) {
builder.setKeys(PBHelper.convert(keys));
}
return builder.build();
} }
@Override @Override

View File

@ -29,6 +29,7 @@ import org.apache.hadoop.hdfs.protocol.proto.HdfsProtos.VersionRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.EndCheckpointRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.ErrorReportRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.ErrorReportRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlockKeysRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlockKeysRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlockKeysResponseProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlocksRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetBlocksRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetEditLogManifestRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetEditLogManifestRequestProto;
import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetMostRecentCheckpointTxIdRequestProto; import org.apache.hadoop.hdfs.protocol.proto.NamenodeProtocolProtos.GetMostRecentCheckpointTxIdRequestProto;
@ -104,8 +105,9 @@ public class NamenodeProtocolTranslatorPB implements NamenodeProtocol,
@Override @Override
public ExportedBlockKeys getBlockKeys() throws IOException { public ExportedBlockKeys getBlockKeys() throws IOException {
try { try {
return PBHelper.convert(rpcProxy.getBlockKeys(NULL_CONTROLLER, GetBlockKeysResponseProto rsp = rpcProxy.getBlockKeys(NULL_CONTROLLER,
GET_BLOCKKEYS).getKeys()); GET_BLOCKKEYS);
return rsp.hasKeys() ? PBHelper.convert(rsp.getKeys()) : null;
} catch (ServiceException e) { } catch (ServiceException e) {
throw ProtobufHelper.getRemoteException(e); throw ProtobufHelper.getRemoteException(e);
} }

View File

@ -56,7 +56,7 @@ message GetBlockKeysRequestProto {
* keys - Information about block keys at the active namenode * keys - Information about block keys at the active namenode
*/ */
message GetBlockKeysResponseProto { message GetBlockKeysResponseProto {
required ExportedBlockKeysProto keys = 1; optional ExportedBlockKeysProto keys = 1;
} }
/** /**