adoroszlai commented on code in PR #8251:
URL: https://github.com/apache/ozone/pull/8251#discussion_r2048231932
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -326,22 +336,35 @@ public ContainerWithPipeline
getContainerWithPipeline(long containerID)
public List<HddsProtos.SCMContainerReplicaProto> getContainerReplicas(
long containerId, int clientVersion) throws IOException {
List<HddsProtos.SCMContainerReplicaProto> results = new ArrayList<>();
+ Map<String, String> auditMap = new HashMap<>();
+ auditMap.put("containerId", String.valueOf(containerId));
+ auditMap.put("clientVersion", String.valueOf(clientVersion));
- Set<ContainerReplica> replicas = getScm().getContainerManager()
- .getContainerReplicas(ContainerID.valueOf(containerId));
- for (ContainerReplica r : replicas) {
- results.add(
- HddsProtos.SCMContainerReplicaProto.newBuilder()
- .setContainerID(containerId)
- .setState(r.getState().toString())
-
.setDatanodeDetails(r.getDatanodeDetails().toProto(clientVersion))
- .setBytesUsed(r.getBytesUsed())
- .setPlaceOfBirth(r.getOriginDatanodeId().toString())
- .setKeyCount(r.getKeyCount())
- .setSequenceID(r.getSequenceId())
- .setReplicaIndex(r.getReplicaIndex()).build()
- );
+ try {
+ Set<ContainerReplica> replicas = getScm().getContainerManager()
+ .getContainerReplicas(ContainerID.valueOf(containerId));
+ for (ContainerReplica r : replicas) {
+ results.add(
+ HddsProtos.SCMContainerReplicaProto.newBuilder()
+ .setContainerID(containerId)
+ .setState(r.getState().toString())
+
.setDatanodeDetails(r.getDatanodeDetails().toProto(clientVersion))
+ .setBytesUsed(r.getBytesUsed())
+ .setPlaceOfBirth(r.getOriginDatanodeId().toString())
+ .setKeyCount(r.getKeyCount())
+ .setSequenceID(r.getSequenceId())
+ .setReplicaIndex(r.getReplicaIndex()).build()
+ );
+ }
+ } catch (Exception ex) {
+ AUDIT.logReadFailure(buildAuditMessageForFailure(
+ SCMAction.GET_CONTAINER_REPLICAS,
+ auditMap, ex));
+ throw ex;
}
+ AUDIT.logReadSuccess(buildAuditMessageForSuccess(
+ SCMAction.GET_CONTAINER_WITH_PIPELINE_BATCH,
+ auditMap));
Review Comment:
I agree, it's better to move success log and `return` into the `try` block.
This makes it easier to spot problems where exception is not re-thrown
(HDDS-12703).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]