rich7420 opened a new pull request, #11151:
URL: https://github.com/apache/ozone/pull/11151

   ## What changes were proposed in this pull request?
   
   `ContainerUtils.getChunkDir` built a `new File(chunksPath)` and called 
`exists()` on the container's chunks directory on every WriteChunk and 
ReadChunk (reached via `ContainerLayoutVersion.getChunkFile`). The chunks 
directory is fixed for the container's lifetime, and on the read path this stat 
is pure added work.
   
   This resolves and validates the chunks directory once, caches the `File` on 
`ContainerData`, and reuses it on the data plane. `setChunksPath` invalidates 
the cache, so create / import / move still re-resolve. The cache field is 
`transient` and not in the YAML whitelist, so it is never serialized. It is 
`volatile` because `getChunkDir` is called concurrently from 
WriteChunk/ReadChunk threads (the memoization would be correct as a plain field 
too, since `File`'s fields are final, but `volatile` avoids repeated resolves 
under contention). The public getter/setter pair mirrors the existing `dbFile` 
accessor on `KeyValueContainerData`.
   
   Behavior is preserved: the first access still throws 
`UNABLE_TO_FIND_DATA_DIR` on a null path or a missing directory; a directory 
that disappears mid-life is still caught by the subsequent `open()`. The 
container scanner (`KeyValueContainerCheck`) stats the path independently and 
is unaffected.
   
   ## What is the link to the Apache JIRA
   
   https://issues.apache.org/jira/browse/HDDS-16326
   
   ## How was this patch tested?
   
   - Unit: `mvn -pl :hdds-container-service test 
-Dtest=TestContainerUtils,TestFilePerBlockStrategy,TestFilePerChunkStrategy` — 
`TestContainerUtils` 16 run, 0 failed; `TestFilePerBlockStrategy` 19, 0 failed; 
`TestFilePerChunkStrategy` 11, 0 failed
   - New in `TestContainerUtils`: `getChunkDirCachesResolvedDirectory` (caching 
+ invalidation on `setChunksPath`) and `getChunkDirThrowsWhenChunksDirMissing` 
(`UNABLE_TO_FIND_DATA_DIR` on first resolve)
   - `checkstyle` and `pmd` clean
   


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