nizhikovprivate commented on code in PR #12081:
URL: https://github.com/apache/ignite/pull/12081#discussion_r2135455309
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/file/FilePageStoreManager.java:
##########
@@ -627,47 +628,47 @@ private CacheStoreHolder initDir(
* @param cft Cache file tree.
*/
public static boolean checkAndInitCacheWorkDir(CacheFileTree cft) throws
IgniteCheckedException {
- File cacheWorkDir = cft.storage();
-
boolean dirExisted = false;
- ReadWriteLock lock =
initDirLock.getLock(cacheWorkDir.getName().hashCode());
+ for (File cacheWorkDir : cft.storages()) {
+ ReadWriteLock lock =
initDirLock.getLock(cacheWorkDir.getName().hashCode());
- lock.writeLock().lock();
+ lock.writeLock().lock();
- try {
- if (!Files.exists(cacheWorkDir.toPath())) {
- try {
- Files.createDirectory(cacheWorkDir.toPath());
- }
- catch (IOException e) {
- throw new IgniteCheckedException("Failed to initialize
cache working directory " +
- "(failed to create, make sure the work folder has
correct permissions): " +
- cacheWorkDir.getAbsolutePath(), e);
+ try {
+ if (!Files.exists(cacheWorkDir.toPath())) {
+ try {
+ Files.createDirectory(cacheWorkDir.toPath());
+ }
+ catch (IOException e) {
+ throw new IgniteCheckedException("Failed to initialize
cache working directory " +
+ "(failed to create, make sure the work folder has
correct permissions): " +
+ cacheWorkDir.getAbsolutePath(), e);
+ }
}
- }
- else {
- if (cacheWorkDir.isFile())
- throw new IgniteCheckedException("Failed to initialize
cache working directory " +
- "(a file with the same name already exists): " +
cacheWorkDir.getAbsolutePath());
+ else {
+ if (cacheWorkDir.isFile())
+ throw new IgniteCheckedException("Failed to initialize
cache working directory " +
+ "(a file with the same name already exists): " +
cacheWorkDir.getAbsolutePath());
- Path cacheWorkDirPath = cacheWorkDir.toPath();
+ Path cacheWorkDirPath = cacheWorkDir.toPath();
- Path tmp =
cacheWorkDirPath.getParent().resolve(cacheWorkDir.getName() + TMP_SUFFIX);
+ Path tmp =
cacheWorkDirPath.getParent().resolve(cacheWorkDir.getName() + TMP_SUFFIX);
- dirExisted = true;
+ dirExisted = true;
Review Comment:
> I suspect this flag is excessive ... From what I see the method either
checks/creates necessary directory or throws an exception if something goes
wrong.
In case all directories from `cft.storages()` was created in
`checkAndInitCacheWorkDir` method will return `false`.
If some directory was created earlier then method will return `true`.
So, it seems to me flag required.
--
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]