szetszwo commented on code in PR #8207:
URL: https://github.com/apache/ozone/pull/8207#discussion_r2025359536


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerReportHandler.java:
##########
@@ -47,16 +47,17 @@ public class ContainerReportHandler extends 
AbstractContainerReportHandler
   private static final Logger LOG =
       LoggerFactory.getLogger(ContainerReportHandler.class);
 
-  private final NodeManager nodeManager;
-  private final ContainerManager containerManager;
-  private final String unknownContainerHandleAction;
+  enum UnknownContainerAction {
+    WARN, DELETE;
 
-  /**
-   * The action taken by ContainerReportHandler to handle
-   * unknown containers.
-   */
-  static final String UNKNOWN_CONTAINER_ACTION_WARN = "WARN";
-  static final String UNKNOWN_CONTAINER_ACTION_DELETE = "DELETE";
+    static UnknownContainerAction parse(String s) {
+      return s.equals(WARN.name()) ? WARN
+          : s.equals(DELETE.name()) ? DELETE
+          : null;
+    }

Review Comment:
   valueOf will throw IllegalArgumentException.
   ```
   Exception in thread "main" java.lang.IllegalArgumentException: No enum 
constant 
org.apache.hadoop.hdds.scm.container.ContainerReportHandler.UnknownContainerAction.abc
        at java.base/java.lang.Enum.valueOf(Enum.java:240)
   ```
   
   BTW, the original code below will do nothing if the conf is neither WARN nor 
DELETE.  Let me change it WARN as default.
   
https://github.com/apache/ozone/blob/30e4aa44d862b0cfc607360bb7f9df1e013955ed/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerReportHandler.java#L227-L237



-- 
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]

Reply via email to