adoroszlai commented on code in PR #5710:
URL: https://github.com/apache/ozone/pull/5710#discussion_r1412355463
##########
hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto:
##########
@@ -302,7 +302,11 @@ message SCMCloseContainerRequestProto {
}
message SCMCloseContainerResponseProto {
- // Empty response
+ enum Error {
+ OK = 1;
+ CONTAINER_ALREADY_CLOSED = 2;
+ }
+ required Error errorCode = 1;
Review Comment:
I think we can try to be backwards compatible.
```suggestion
optional Error errorCode = 1;
```
Also, since `OK` is also part of the enum, `Status` might be a better name.
##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java:
##########
@@ -576,8 +576,17 @@ public void closeContainer(long containerID) throws
IOException {
.setTraceID(TracingUtil.exportCurrentSpan())
.setContainerID(containerID)
.build();
- submitRequest(Type.CloseContainer,
- builder -> builder.setScmCloseContainerRequest(request));
+ StorageContainerLocationProtocolProtos.SCMCloseContainerResponseProto
+ response = submitRequest(Type.CloseContainer,
+ builder -> builder.setScmCloseContainerRequest(
+ request)).getScmCloseContainerResponse();
+ if (response.getErrorCode().equals(
+ StorageContainerLocationProtocolProtos.SCMCloseContainerResponseProto.
+ Error.CONTAINER_ALREADY_CLOSED)) {
+ String errorMessage =
+ String.format("Container %s already closed", containerID);
+ throw new IOException(errorMessage);
+ }
Review Comment:
If changing `errorCode` to `optional`, check for `hasErrorCode()` here.
Nit: please import `SCMCloseContainerResponseProto` for brevity and to be
consistent with other code in the same file.
--
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]