adoroszlai commented on code in PR #5576:
URL: https://github.com/apache/ozone/pull/5576#discussion_r1391519528
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ContainerImporter.java:
##########
@@ -79,6 +79,16 @@ public ContainerImporter(ConfigurationSource conf,
ContainerSet containerSet,
ScmConfigKeys.OZONE_SCM_CONTAINER_SIZE_DEFAULT, StorageUnit.BYTES);
}
+ public boolean isAllowedContainerImport(long containerID) {
+ if (importContainerProgress.contains(containerID)) {
+ return false;
+ }
+ if (containerSet.getContainer(containerID) != null) {
+ return false;
+ }
+ return true;
Review Comment:
Nit: can be simplified.
```suggestion
return !importContainerProgress.contains(containerID) &&
containerSet.getContainer(containerID) == null;
```
Also, please add `<>` in `new HashSet()`, missed in last change
(1cf54f34af3).
https://github.com/apache/ozone/blob/4e95b702a996ec65f9be6f4d50a4025e55991d89/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/ContainerImporter.java#L63-L64
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/replication/SendContainerRequestHandler.java:
##########
@@ -80,6 +82,14 @@ public void onNext(SendContainerRequest req) {
LOG.info("Accepting container {}", req.getContainerID());
}
+ // check and avoid download of container file if target already have
+ // container data and import in progress
+ if (!importer.isAllowedContainerImport(containerId)) {
+ throw new StorageContainerException("Container exists or " +
+ "import in progress with container Id " + containerId,
+ ContainerProtos.Result.CONTAINER_EXISTS);
+ }
Review Comment:
We can move this check before the `if` block (and change it to use
`req.getContainerID()`) to avoid creating some resources unnecessarily.
--
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]