HDDS-1293. ExcludeList#getProtoBuf throws ArrayIndexOutOfBoundsException. Contributed by Shashikant Banerjee.

This commit is contained in:
Shashikant Banerjee 2019-03-29 00:43:28 +05:30
parent ca5e4ce036
commit ac4010bb22
1 changed files with 7 additions and 5 deletions

View File

@ -23,7 +23,9 @@ import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.container.ContainerID; import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID; import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import java.util.*; import java.util.ArrayList;
import java.util.List;
import java.util.Collection;
/** /**
* This class contains set of dns and containers which ozone client provides * This class contains set of dns and containers which ozone client provides
@ -73,12 +75,12 @@ public class ExcludeList {
public HddsProtos.ExcludeListProto getProtoBuf() { public HddsProtos.ExcludeListProto getProtoBuf() {
HddsProtos.ExcludeListProto.Builder builder = HddsProtos.ExcludeListProto.Builder builder =
HddsProtos.ExcludeListProto.newBuilder(); HddsProtos.ExcludeListProto.newBuilder();
containerIds.parallelStream() containerIds
.forEach(id -> builder.addContainerIds(id.getId())); .forEach(id -> builder.addContainerIds(id.getId()));
datanodes.parallelStream().forEach(dn -> { datanodes.forEach(dn -> {
builder.addDatanodes(dn.getUuidString()); builder.addDatanodes(dn.getUuidString());
}); });
pipelineIds.parallelStream().forEach(pipelineID -> { pipelineIds.forEach(pipelineID -> {
builder.addPipelineIds(pipelineID.getProtobuf()); builder.addPipelineIds(pipelineID.getProtobuf());
}); });
return builder.build(); return builder.build();
@ -87,7 +89,7 @@ public class ExcludeList {
public static ExcludeList getFromProtoBuf( public static ExcludeList getFromProtoBuf(
HddsProtos.ExcludeListProto excludeListProto) { HddsProtos.ExcludeListProto excludeListProto) {
ExcludeList excludeList = new ExcludeList(); ExcludeList excludeList = new ExcludeList();
excludeListProto.getContainerIdsList().parallelStream().forEach(id -> { excludeListProto.getContainerIdsList().forEach(id -> {
excludeList.addConatinerId(ContainerID.valueof(id)); excludeList.addConatinerId(ContainerID.valueof(id));
}); });
DatanodeDetails.Builder builder = DatanodeDetails.newBuilder(); DatanodeDetails.Builder builder = DatanodeDetails.newBuilder();