timoninmaxim commented on code in PR #11840: URL: https://github.com/apache/ignite/pull/11840#discussion_r1938994434
########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER; + +/** + * Provides access to directories shared between all local nodes. + * <pre> + * ❯ tree + * . ← root (work directory, shared between all local nodes). + * ├── db ← db (shared between all local nodes). + * │ ├── binary_meta ← binaryMetaRoot (shared between all local nodes). + * │ ├── marshaller ← marshaller (shared between all local nodes). + * └── snapshots ← snapshotRoot (shared between all local nodes). + * </pre> + * + * @see NodeFileTree + */ +public class SharedFileTree { + /** Default path (relative to working directory) of binary metadata folder. */ Review Comment: Relative path is 'db/binary_meta'. This is just a name of directory ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER; + +/** + * Provides access to directories shared between all local nodes. + * <pre> + * ❯ tree + * . ← root (work directory, shared between all local nodes). + * ├── db ← db (shared between all local nodes). + * │ ├── binary_meta ← binaryMetaRoot (shared between all local nodes). + * │ ├── marshaller ← marshaller (shared between all local nodes). + * └── snapshots ← snapshotRoot (shared between all local nodes). + * </pre> + * + * @see NodeFileTree + */ +public class SharedFileTree { + /** Default path (relative to working directory) of binary metadata folder. */ + public static final String BINARY_METADATA_DIR = "binary_meta"; + + /** Default path (relative to working directory) of marshaller mappings folder. */ + public static final String MARSHALLER_DIR = "marshaller"; + + /** Root(work) directory. */ + protected final File root; + + /** db directory. */ + protected final File db; + + /** Path to the directory containing binary metadata. */ + protected final File binaryMetaRoot; + + /** Path to the directory containing marshaller files. */ + protected final File marshaller; + + /** + * @param root Root directory. + */ + public SharedFileTree(File root) { + A.notNull(root, "Root directory"); + + this.root = root; + db = new File(root, DB_DEFAULT_FOLDER); + marshaller = new File(db, MARSHALLER_DIR); + binaryMetaRoot = new File(db, BINARY_METADATA_DIR); + } + + /** + * @param root Root directory. + */ + public SharedFileTree(String root) { + this(new File(root)); + } + + /** + * @param cfg Config to get {@code root} directory from. + */ + SharedFileTree(IgniteConfiguration cfg) { + A.notNull(cfg, "config"); + + try { + root = new File(U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome())); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + + db = new File(root, DB_DEFAULT_FOLDER); + marshaller = new File(db, MARSHALLER_DIR); + binaryMetaRoot = new File(db, BINARY_METADATA_DIR); + } + + /** + * @return Path to the {@code root} directory. + */ + public File root() { + return root; + } + + /** + * @return Path to the {@code db} directory. + */ + public File db() { + return db; + } + + /** + * @return Path to common binary metadata directory. Note, directory can contain data from several nodes. + * Each node will create own directory inside this root. + */ + public File binaryMetaRoot() { + return binaryMetaRoot; + } + + /** @return Path to marshaller directory. */ + public File marshaller() { + return marshaller; + } + + /** + * Creates {@link #binaryMetaRoot()} directory. + * @return Created directory. + * @see SharedFileTree#binaryMetaRoot() + */ + public File mkdirBinaryMetaRoot() { Review Comment: The method is used only in tests. Let's the test call `mkdir` by itself. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER; + +/** + * Provides access to directories shared between all local nodes. + * <pre> + * ❯ tree + * . ← root (work directory, shared between all local nodes). + * ├── db ← db (shared between all local nodes). + * │ ├── binary_meta ← binaryMetaRoot (shared between all local nodes). + * │ ├── marshaller ← marshaller (shared between all local nodes). + * └── snapshots ← snapshotRoot (shared between all local nodes). + * </pre> + * + * @see NodeFileTree + */ +public class SharedFileTree { + /** Default path (relative to working directory) of binary metadata folder. */ + public static final String BINARY_METADATA_DIR = "binary_meta"; + + /** Default path (relative to working directory) of marshaller mappings folder. */ + public static final String MARSHALLER_DIR = "marshaller"; + + /** Root(work) directory. */ + protected final File root; + + /** db directory. */ + protected final File db; + + /** Path to the directory containing binary metadata. */ + protected final File binaryMetaRoot; + + /** Path to the directory containing marshaller files. */ + protected final File marshaller; + + /** + * @param root Root directory. + */ + public SharedFileTree(File root) { + A.notNull(root, "Root directory"); + + this.root = root; + db = new File(root, DB_DEFAULT_FOLDER); + marshaller = new File(db, MARSHALLER_DIR); + binaryMetaRoot = new File(db, BINARY_METADATA_DIR); + } + + /** + * @param root Root directory. + */ + public SharedFileTree(String root) { + this(new File(root)); + } + + /** + * @param cfg Config to get {@code root} directory from. + */ + SharedFileTree(IgniteConfiguration cfg) { + A.notNull(cfg, "config"); + + try { + root = new File(U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome())); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + + db = new File(root, DB_DEFAULT_FOLDER); + marshaller = new File(db, MARSHALLER_DIR); + binaryMetaRoot = new File(db, BINARY_METADATA_DIR); + } + + /** + * @return Path to the {@code root} directory. + */ + public File root() { + return root; + } + + /** + * @return Path to the {@code db} directory. + */ + public File db() { + return db; + } + + /** + * @return Path to common binary metadata directory. Note, directory can contain data from several nodes. + * Each node will create own directory inside this root. + */ + public File binaryMetaRoot() { + return binaryMetaRoot; + } + + /** @return Path to marshaller directory. */ + public File marshaller() { + return marshaller; + } + + /** + * Creates {@link #binaryMetaRoot()} directory. + * @return Created directory. + * @see SharedFileTree#binaryMetaRoot() + */ + public File mkdirBinaryMetaRoot() { + return mkdir(binaryMetaRoot, "root binary metadata"); + } + + /** + * Creates {@link #marshaller()} directory. + * @return Created directory. + * @see #marshaller() + */ + public File mkdirMarshaller() { + return mkdir(marshaller, "marshaller mappings"); + } + + /** + * @param f File to check. + * @return {@code True} if argument can be binary meta root directory. + */ + public static boolean isBinaryMetaRoot(File f) { Review Comment: Prefix `is` isn't used in method names in internal packages ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/dump/Dump.java: ########## @@ -86,6 +84,9 @@ public class Dump implements AutoCloseable { /** Dump directory. */ private final File dumpDir; + /** Dump directories. */ + private final List<NodeFileTree> dirs; Review Comment: trees? ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/PdsConsistentIdProcessor.java: ########## @@ -73,6 +77,27 @@ public PdsConsistentIdProcessor(final GridKernalContext ctx) { return settings; } + /** {@inheritDoc} */ + @Override public NodeFileTree fileTree() { + if (ft == null) { Review Comment: Looks like we can put initialization to constructor. I'm not sure, but this code might be non-thread safe, it's pretty unclear how to understand it. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/NodeFileTree.java: ########## @@ -0,0 +1,229 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +/** + * Provides access to Ignite node file tree. + * Note, that base path can be different for each usage: Review Comment: base path -> root path ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER; + +/** + * Provides access to directories shared between all local nodes. + * <pre> + * ❯ tree + * . ← root (work directory, shared between all local nodes). + * ├── db ← db (shared between all local nodes). + * │ ├── binary_meta ← binaryMetaRoot (shared between all local nodes). + * │ ├── marshaller ← marshaller (shared between all local nodes). + * └── snapshots ← snapshotRoot (shared between all local nodes). + * </pre> + * + * @see NodeFileTree + */ +public class SharedFileTree { + /** Default path (relative to working directory) of binary metadata folder. */ + public static final String BINARY_METADATA_DIR = "binary_meta"; + + /** Default path (relative to working directory) of marshaller mappings folder. */ Review Comment: Relative path is 'db/marshaller'. ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/SharedFileTree.java: ########## @@ -0,0 +1,196 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.persistence.filename; + +import java.io.File; +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.internal.util.typedef.internal.A; +import org.apache.ignite.internal.util.typedef.internal.S; +import org.apache.ignite.internal.util.typedef.internal.U; + +import static org.apache.ignite.internal.processors.cache.persistence.filename.PdsFolderResolver.DB_DEFAULT_FOLDER; + +/** + * Provides access to directories shared between all local nodes. + * <pre> + * ❯ tree + * . ← root (work directory, shared between all local nodes). + * ├── db ← db (shared between all local nodes). + * │ ├── binary_meta ← binaryMetaRoot (shared between all local nodes). + * │ ├── marshaller ← marshaller (shared between all local nodes). + * └── snapshots ← snapshotRoot (shared between all local nodes). + * </pre> + * + * @see NodeFileTree + */ +public class SharedFileTree { + /** Default path (relative to working directory) of binary metadata folder. */ + public static final String BINARY_METADATA_DIR = "binary_meta"; + + /** Default path (relative to working directory) of marshaller mappings folder. */ + public static final String MARSHALLER_DIR = "marshaller"; + + /** Root(work) directory. */ + protected final File root; + + /** db directory. */ + protected final File db; + + /** Path to the directory containing binary metadata. */ + protected final File binaryMetaRoot; + + /** Path to the directory containing marshaller files. */ + protected final File marshaller; + + /** + * @param root Root directory. + */ + public SharedFileTree(File root) { + A.notNull(root, "Root directory"); + + this.root = root; + db = new File(root, DB_DEFAULT_FOLDER); + marshaller = new File(db, MARSHALLER_DIR); + binaryMetaRoot = new File(db, BINARY_METADATA_DIR); + } + + /** + * @param root Root directory. + */ + public SharedFileTree(String root) { + this(new File(root)); + } + + /** + * @param cfg Config to get {@code root} directory from. + */ + SharedFileTree(IgniteConfiguration cfg) { + A.notNull(cfg, "config"); + + try { + root = new File(U.workDirectory(cfg.getWorkDirectory(), cfg.getIgniteHome())); Review Comment: call `this(new File...))` instead ########## modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/filename/PdsFoldersResolver.java: ########## @@ -31,4 +31,9 @@ public interface PdsFoldersResolver { * @throws IgniteCheckedException if failed. */ public PdsFolderSettings<NodeFileLockHolder> resolveFolders() throws IgniteCheckedException; + + /** + * @return Ignite node standart directories. Review Comment: Ignite node file tree? -- 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]
