adoroszlai commented on code in PR #8251:
URL: https://github.com/apache/ozone/pull/8251#discussion_r2048224531
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -230,43 +230,55 @@ public void join() throws InterruptedException {
public ContainerWithPipeline allocateContainer(HddsProtos.ReplicationType
replicationType, HddsProtos.ReplicationFactor factor,
String owner) throws IOException {
- if (scm.getScmContext().isInSafeMode()) {
- throw new SCMException("SafeModePrecheck failed for allocateContainer",
- ResultCodes.SAFE_MODE_EXCEPTION);
+
+ Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("replicationType", String.valueOf(replicationType));
+ auditMap.put("factor", String.valueOf(factor));
+ auditMap.put("owner", String.valueOf(owner));
+
+ try {
+ if (scm.getScmContext().isInSafeMode()) {
+ throw new SCMException("SafeModePrecheck failed for allocateContainer",
+ ResultCodes.SAFE_MODE_EXCEPTION);
+ }
+ getScm().checkAdminAccess(getRemoteUser(), false);
+ final ContainerInfo container = scm.getContainerManager()
+ .allocateContainer(
+ ReplicationConfig.fromProtoTypeAndFactor(replicationType,
factor),
+ owner);
+ final Pipeline pipeline = scm.getPipelineManager()
+ .getPipeline(container.getPipelineID());
+ ContainerWithPipeline cp = new ContainerWithPipeline(container,
pipeline);
+ AUDIT.logWriteSuccess(buildAuditMessageForSuccess(
+ SCMAction.ALLOCATE_CONTAINER, auditMap)
+ );
+ return cp;
+ } catch (Exception ex) {
Review Comment:
Let's keep catching `Exception`, which is better because it handles
unchecked exceptions, too. We may want to change occurrences of `catch
(IOException)` to `catch (Exception)` instead.
--
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]