Skip to content

Commit

Permalink
HDDS-10472. Audit log should include EC replication config (apache#6338)
Browse files Browse the repository at this point in the history
  • Loading branch information
adoroszlai authored Mar 6, 2024
1 parent 418528a commit 309e459
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public String getReplication() {
+ chunkKB();
}

/** Similar to {@link #getReplication()}, but applies to proto structure, without any validation. */
public static String toString(HddsProtos.ECReplicationConfig proto) {
return proto.getCodec() + EC_REPLICATION_PARAMS_DELIMITER
+ proto.getData() + EC_REPLICATION_PARAMS_DELIMITER
+ proto.getParity() + EC_REPLICATION_PARAMS_DELIMITER
+ proto.getEcChunkSize();
}

public HddsProtos.ECReplicationConfig toProto() {
return HddsProtos.ECReplicationConfig.newBuilder()
.setData(data)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.hadoop.hdds.client.ECReplicationConfig;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.ozone.OzoneConsts;
import org.apache.hadoop.ozone.audit.AuditAction;
import org.apache.hadoop.ozone.audit.AuditMessage;
Expand Down Expand Up @@ -68,10 +70,16 @@ default Map<String, String> buildKeyArgsAuditMap(KeyArgs keyArgs) {
auditMap.put(OzoneConsts.KEY, keyArgs.getKeyName());
auditMap.put(OzoneConsts.DATA_SIZE,
String.valueOf(keyArgs.getDataSize()));
auditMap.put(OzoneConsts.REPLICATION_TYPE,
(keyArgs.getType() != null) ? keyArgs.getType().name() : null);
auditMap.put(OzoneConsts.REPLICATION_FACTOR,
(keyArgs.getFactor() != null) ? keyArgs.getFactor().name() : null);
if (keyArgs.hasType()) {
auditMap.put(OzoneConsts.REPLICATION_TYPE, keyArgs.getType().name());
}
if (keyArgs.hasFactor() && keyArgs.getFactor() != HddsProtos.ReplicationFactor.ZERO) {
auditMap.put(OzoneConsts.REPLICATION_FACTOR, keyArgs.getFactor().name());
}
if (keyArgs.hasEcReplicationConfig()) {
auditMap.put(OzoneConsts.REPLICATION_CONFIG,
ECReplicationConfig.toString(keyArgs.getEcReplicationConfig()));
}
return auditMap;
}
}
Expand Down

0 comments on commit 309e459

Please sign in to comment.