Skip to content

Commit

Permalink
HDDS-11373. Log for EC reconstruction command lists the missing index…
Browse files Browse the repository at this point in the history
…es as ASCII control characters (apache#7123)
  • Loading branch information
adoroszlai authored Aug 28, 2024
1 parent dab1538 commit 8306290
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
*/
package org.apache.hadoop.ozone.protocol.commands;

import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import com.google.protobuf.ByteString;
import org.apache.hadoop.hdds.HddsIdFactory;
import org.apache.hadoop.hdds.StringUtils;
import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.protocol.DatanodeDetails;
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos;
Expand Down Expand Up @@ -140,7 +140,7 @@ public String toString() {
.collect(Collectors.joining(", "))).append("]")
.append(", targets: ").append(getTargetDatanodes())
.append(", missingIndexes: ").append(
StringUtils.bytes2String(missingContainerIndexes.asReadOnlyByteBuffer()));
Arrays.toString(missingContainerIndexes.toByteArray()));
return sb.toString();
}
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand All @@ -53,11 +55,8 @@ public void testExceptionIfSourceAndMissingNotSameLength() {

@Test
public void protobufConversion() {
final ByteString missingContainerIndexes = Proto2Utils.unsafeByteString(new byte[]{1, 2});
List<Long> srcNodesIndexes = new ArrayList<>();
for (int i = 0; i < srcNodesIndexes.size(); i++) {
srcNodesIndexes.add(i + 1L);
}
byte[] missingIndexes = {1, 2};
final ByteString missingContainerIndexes = Proto2Utils.unsafeByteString(missingIndexes);
ECReplicationConfig ecReplicationConfig = new ECReplicationConfig(3, 2);
final List<DatanodeDetails> dnDetails = getDNDetails(5);

Expand All @@ -70,6 +69,10 @@ public void protobufConversion() {
ReconstructECContainersCommand reconstructECContainersCommand =
new ReconstructECContainersCommand(1L, sources, targets,
missingContainerIndexes, ecReplicationConfig);

assertThat(reconstructECContainersCommand.toString())
.contains("missingIndexes: " + Arrays.toString(missingIndexes));

StorageContainerDatanodeProtocolProtos.ReconstructECContainersCommandProto
proto = reconstructECContainersCommand.getProto();

Expand Down

0 comments on commit 8306290

Please sign in to comment.