You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2019/11/13 17:42:27 UTC

[GitHub] [hadoop-ozone] nandakumar131 commented on a change in pull request #153: HDDS-1940. Closing open container via scmcli gives false error message.

nandakumar131 commented on a change in pull request #153: HDDS-1940. Closing open container via scmcli gives false error message.
URL: https://github.com/apache/hadoop-ozone/pull/153#discussion_r345903437
 
 

 ##########
 File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java
 ##########
 @@ -366,33 +367,29 @@ public void deleteContainer(long containerID) throws IOException {
   }
 
   @Override
-  public void notifyObjectStageChange(StorageContainerLocationProtocolProtos
-      .ObjectStageChangeRequestProto.Type type, long id,
-      StorageContainerLocationProtocolProtos.ObjectStageChangeRequestProto.Op
-          op, StorageContainerLocationProtocolProtos
-      .ObjectStageChangeRequestProto.Stage stage) throws IOException {
-
-    LOG.info("Object type {} id {} op {} new stage {}", type, id, op,
-        stage);
-    if (type == StorageContainerLocationProtocolProtos
-        .ObjectStageChangeRequestProto.Type.container) {
-      if (op == StorageContainerLocationProtocolProtos
-          .ObjectStageChangeRequestProto.Op.close) {
-        if (stage == StorageContainerLocationProtocolProtos
-            .ObjectStageChangeRequestProto.Stage.begin) {
-          scm.getContainerManager()
-              .updateContainerState(ContainerID.valueof(id),
-                  HddsProtos.LifeCycleEvent.FINALIZE);
-        } else {
-          scm.getContainerManager()
-              .updateContainerState(ContainerID.valueof(id),
-                  HddsProtos.LifeCycleEvent.CLOSE);
-        }
+  public void closeContainer(long containerID) throws IOException {
+    final String remoteUser = getRpcRemoteUsername();
+    final Map<String, String> auditMap = Maps.newHashMap();
+    auditMap.put("containerID", String.valueOf(containerID));
+    auditMap.put("remoteUser", remoteUser);
+    try {
+      scm.checkAdminAccess(remoteUser);
+      final ContainerID cid = ContainerID.valueof(containerID);
+      final HddsProtos.LifeCycleState state = scm.getContainerManager()
+          .getContainer(cid).getState();
+      if (!state.equals(HddsProtos.LifeCycleState.OPEN)) {
+        throw new SCMException("Cannot close an " + state + " container.",
 
 Review comment:
   Thanks for the catch.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: ozone-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: ozone-issues-help@hadoop.apache.org