Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
package org.apache.hadoop.ozone.debug.ldb;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.apache.hadoop.hdds.scm.block.DeletedBlockLogStateManagerImpl.SERVICE_NAME;
import static org.apache.hadoop.hdds.scm.metadata.SCMDBDefinition.STATEFUL_SERVICE_CONFIG;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand All @@ -28,6 +30,8 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
Expand All @@ -54,6 +58,7 @@
import java.util.regex.Pattern;
import org.apache.hadoop.hdds.cli.AbstractSubcommand;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.container.ContainerID;
import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
import org.apache.hadoop.hdds.utils.IOUtils;
Expand Down Expand Up @@ -730,9 +735,9 @@ public Void call() {
// one, to ensure valid JSON format.
sb.append(", ");
}
Object key = dbColumnFamilyDefinition.getKeyCodec()
.fromPersistedFormat(byteArrayKeyValue.getKey());
if (withKey) {
Object key = dbColumnFamilyDefinition.getKeyCodec()
.fromPersistedFormat(byteArrayKeyValue.getKey());
if (schemaV3) {
int index =
DatanodeSchemaThreeDBDefinition.getContainerKeyPrefixLength();
Expand All @@ -758,9 +763,11 @@ public Void call() {
Object o = dbColumnFamilyDefinition.getValueCodec()
.fromPersistedFormat(byteArrayKeyValue.getValue());

o = parseStatefulServiceConfig(key, o, dbColumnFamilyDefinition);

if (valueFields != null) {
Map<String, Object> filteredValue = new HashMap<>();
filteredValue.putAll(getFieldsFilteredObject(o, dbColumnFamilyDefinition.getValueType(), fieldsSplitMap));
filteredValue.putAll(getFieldsFilteredObject(o, o.getClass(), fieldsSplitMap));
sb.append(writer.writeValueAsString(filteredValue));
} else {
sb.append(writer.writeValueAsString(o));
Expand Down Expand Up @@ -829,6 +836,20 @@ List<Object> getFieldsFilteredObjectCollection(Collection<?> valueObject, Map<St
}
}

private Object parseStatefulServiceConfig(Object key, Object value, DBColumnFamilyDefinition dbColumnFamily) {
if (dbColumnFamily.getName().equals(STATEFUL_SERVICE_CONFIG.getName()) && key.equals(SERVICE_NAME) &&
value instanceof ByteString) {
try {
return HddsProtos.DeletedBlocksTransactionSummary.parseFrom((ByteString) value);
} catch (InvalidProtocolBufferException e) {
LOG.error("Failed to parse {} for key {}", STATEFUL_SERVICE_CONFIG.getName(), SERVICE_NAME, e);
} catch (IOException e) {
LOG.error("Failed to parse {} for key {}", STATEFUL_SERVICE_CONFIG.getName(), SERVICE_NAME, e);
Comment on lines +844 to +847

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate catch blocks, please merge them.

}
}
return value;
}

private static class ByteArrayKeyValue {
private final byte[] key;
private final byte[] value;
Expand Down