peterxcli commented on code in PR #8360:
URL: https://github.com/apache/ozone/pull/8360#discussion_r2066198130
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/ContainerReader.java:
##########
@@ -202,50 +202,52 @@ public void verifyAndFixupContainerData(ContainerData
containerData)
throws IOException {
switch (containerData.getContainerType()) {
case KeyValueContainer:
- if (containerData instanceof KeyValueContainerData) {
- KeyValueContainerData kvContainerData = (KeyValueContainerData)
- containerData;
- containerData.setVolume(hddsVolume);
- KeyValueContainerUtil.parseKVContainerData(kvContainerData, config);
- KeyValueContainer kvContainer = new KeyValueContainer(kvContainerData,
- config);
- if (kvContainer.getContainerState() == RECOVERING) {
- if (shouldDelete) {
- // delete Ratis replicated RECOVERING containers
- if (kvContainer.getContainerData().getReplicaIndex() == 0) {
- cleanupContainer(hddsVolume, kvContainer);
- } else {
- kvContainer.markContainerUnhealthy();
- LOG.info("Stale recovering container {} marked UNHEALTHY",
- kvContainerData.getContainerID());
- containerSet.addContainer(kvContainer);
- }
- }
- return;
- }
- if (kvContainer.getContainerState() == DELETED) {
- if (shouldDelete) {
- cleanupContainer(hddsVolume, kvContainer);
- }
- return;
- }
- try {
- containerSet.addContainer(kvContainer);
- } catch (StorageContainerException e) {
- if (e.getResult() != ContainerProtos.Result.CONTAINER_EXISTS) {
- throw e;
- }
- if (shouldDelete) {
- resolveDuplicate((KeyValueContainer) containerSet.getContainer(
- kvContainer.getContainerData().getContainerID()), kvContainer);
- }
- }
- } else {
+ if (!(containerData instanceof KeyValueContainerData)) {
throw new StorageContainerException("Container File is corrupted. " +
"ContainerType is KeyValueContainer but cast to " +
"KeyValueContainerData failed. ",
ContainerProtos.Result.CONTAINER_METADATA_ERROR);
}
+
+ KeyValueContainerData kvContainerData = (KeyValueContainerData)
+ containerData;
+ containerData.setVolume(hddsVolume);
+ KeyValueContainerUtil.parseKVContainerData(kvContainerData, config);
+ KeyValueContainer kvContainer = new KeyValueContainer(kvContainerData,
+ config);
+ if (kvContainer.getContainerState() == RECOVERING) {
+ if (shouldDelete) {
+ // delete Ratis replicated RECOVERING containers
+ if (kvContainer.getContainerData().getReplicaIndex() == 0) {
+ cleanupContainer(hddsVolume, kvContainer);
+ } else {
+ kvContainer.markContainerUnhealthy();
+ LOG.info("Stale recovering container {} marked UNHEALTHY",
+ kvContainerData.getContainerID());
+ containerSet.addContainer(kvContainer);
+ }
+ }
+ return;
+ } else if (kvContainer.getContainerState() == DELETED) {
+ if (shouldDelete) {
+ cleanupContainer(hddsVolume, kvContainer);
+ }
+ return;
+ }
+
+ try {
+ containerData.commitSpace();
Review Comment:
Sorry this diff may hard to read, but what I'm doing here is just:
1. Move the `containerData` instance check up to reduce the indent level of
the block.
2. Commit space before adding container. **But I have one question here,
IIRC, only containers in RECOVERING or OPEN will receive new write, so would it
be better to only commit the space for RECOVERING/OPEN containers?**
--
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]