alievmirza commented on code in PR #4119: URL: https://github.com/apache/ignite-3/pull/4119#discussion_r1691704178
########## modules/system-configuration/src/main/java/org/apache/ignite/internal/configuration/SystemConfigurationModule.java: ########## @@ -0,0 +1,43 @@ +/* + * 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.configuration; + +import com.google.auto.service.AutoService; +import java.util.Collection; +import java.util.Collections; +import org.apache.ignite.configuration.ConfigurationModule; +import org.apache.ignite.configuration.RootKey; +import org.apache.ignite.configuration.annotation.ConfigurationType; + +/** + * {@link ConfigurationModule} for node-local system configuration. + */ +@AutoService(ConfigurationModule.class) +public class SystemConfigurationModule implements ConfigurationModule { + + @Override + public ConfigurationType type() { + return ConfigurationType.LOCAL; + } + + @Override + public Collection<RootKey<?, ?>> rootKeys() { + return Collections.singleton(SystemConfiguration.KEY); + } + Review Comment: redundant lines in this class ########## modules/system-configuration/src/main/java/org/apache/ignite/internal/configuration/IgnitePaths.java: ########## @@ -0,0 +1,126 @@ +/* + * 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.configuration; + + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.Supplier; +import org.apache.ignite.configuration.ConfigurationValue; +import org.apache.ignite.internal.lang.IgniteInternalException; +import org.apache.ignite.internal.util.LazyPath; + +/** + * Manages storage paths for Ignite. + */ +public class IgnitePaths { + + /** + * Path to the base directory of the partitions data. + */ + private static final Path PARTITIONS_BASE_PATH = Paths.get("partitions"); + + /** + * Path to the persistent storage used by the VaultService component. + */ + private static final Path VAULT_DB_PATH = Paths.get("vault"); + + /** + * Path to the persistent storage used by the MetaStorageManager component. + */ + private static final Path METASTORAGE_DB_PATH = Paths.get("metastorage"); + + /** + * Path to the persistent storage used by the ClusterManagementGroupManager component. + */ + private static final Path CMG_DB_PATH = Paths.get("cmg"); + + /** + * Path for the persistent storage. + */ + private static final Path STORAGE_PATH = Paths.get("db"); + + /** + * Path for the raft log. + */ + private static final Path RAFT_LOG_PATH = Paths.get("log"); + + /** + * Path for the metadata. + */ + private static final Path METADATA_PATH = Paths.get("meta"); + + public static LazyPath partitionsBasePath(SystemConfiguration systemConfiguration, Path workDir) { + return lazy(systemConfiguration.partitionsBasePath(), () -> workDir.resolve(PARTITIONS_BASE_PATH), true); + } + + public static LazyPath partitionsMetaPath(LazyPath partitionsBaseDir) { + return partitionsBaseDir.resolveLazy(METADATA_PATH, true); + } + + public static LazyPath partitionsRaftLogPath(LazyPath partitionsBaseDir) { + return partitionsBaseDir.resolveLazy(RAFT_LOG_PATH); + } + + public static LazyPath partitionsRaftLogPath(SystemConfiguration systemConfiguration, Path workDir) { + return partitionsRaftLogPath(partitionsBasePath(systemConfiguration, workDir)); + } + + /** + * Returns a path to the partitions store directory. Creates a directory if it doesn't exist. + * + * @param partitionsBaseDir Partitions base directory, {@link #partitionsBasePath(SystemConfiguration, Path)}. + * @return Partitions store path. + */ + public static LazyPath partitionsStorePath(LazyPath partitionsBaseDir) { Review Comment: I would expect java docs for all *Path methods, not only for `partitionsStorePath` ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { + return new LazyPath(() -> pathOrDefault(pathSupplier.get(), defaultPath)); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier) { + return create(pathSupplier, defaultPathSupplier, false); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. If {code + * ensureCreated} is {@code true}, then create the path if it doesn't exist. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + * @param ensureCreated If {@code true}, then create the path if it doesn't exist. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier, boolean ensureCreated) { + return new LazyPath(() -> { + Path path = pathOrDefault(pathSupplier.get(), defaultPathSupplier); + + return ensureCreated ? ensureCreated(path) : path; + }); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(Path other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(String other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(Path other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(String other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + @Override + public Path get() { + return super.get(); + } + + private static Path ensureCreated(Path dir) { Review Comment: Why do we have two the same methods here and in `org.apache.ignite.internal.configuration.IgnitePaths#ensureCreated` ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { + return new LazyPath(() -> pathOrDefault(pathSupplier.get(), defaultPath)); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier) { + return create(pathSupplier, defaultPathSupplier, false); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. If {code + * ensureCreated} is {@code true}, then create the path if it doesn't exist. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + * @param ensureCreated If {@code true}, then create the path if it doesn't exist. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier, boolean ensureCreated) { + return new LazyPath(() -> { + Path path = pathOrDefault(pathSupplier.get(), defaultPathSupplier); + + return ensureCreated ? ensureCreated(path) : path; + }); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(Path other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(String other) { Review Comment: these two methods are just the same ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { + return new LazyPath(() -> pathOrDefault(pathSupplier.get(), defaultPath)); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier) { + return create(pathSupplier, defaultPathSupplier, false); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. If {code + * ensureCreated} is {@code true}, then create the path if it doesn't exist. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + * @param ensureCreated If {@code true}, then create the path if it doesn't exist. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier, boolean ensureCreated) { + return new LazyPath(() -> { + Path path = pathOrDefault(pathSupplier.get(), defaultPathSupplier); + + return ensureCreated ? ensureCreated(path) : path; + }); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(Path other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(String other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(Path other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(String other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + @Override + public Path get() { + return super.get(); + } + + private static Path ensureCreated(Path dir) { + try { + Files.createDirectories(dir); + } catch (IOException e) { + throw new IgniteInternalException("Failed to create directory: " + dir + ": " + e.getMessage(), e); Review Comment: deprecated constructor usage ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { + return new LazyPath(() -> pathOrDefault(pathSupplier.get(), defaultPath)); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier) { + return create(pathSupplier, defaultPathSupplier, false); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. If {code + * ensureCreated} is {@code true}, then create the path if it doesn't exist. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + * @param ensureCreated If {@code true}, then create the path if it doesn't exist. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier, boolean ensureCreated) { + return new LazyPath(() -> { + Path path = pathOrDefault(pathSupplier.get(), defaultPathSupplier); + + return ensureCreated ? ensureCreated(path) : path; + }); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(Path other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. + */ + public LazyPath resolveLazy(String other) { + return resolveLazy(other, false); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(Path other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + /** + * Resolve the other path against this one. If {code ensureCreated} is {@code true}, then create the path if it doesn't exist. + */ + public LazyPath resolveLazy(String other, boolean ensureCreated) { + return new LazyPath(() -> { + Path resolved = get().resolve(other); + + return ensureCreated ? ensureCreated(resolved) : resolved; + }); + } + + @Override + public Path get() { + return super.get(); + } + + private static Path ensureCreated(Path dir) { Review Comment: I don't understand scenarios when we nedd ensured or not ensured paths ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { Review Comment: this method is not used ########## modules/system-configuration/src/main/java/org/apache/ignite/internal/configuration/SystemConfigurationSchema.java: ########## @@ -0,0 +1,42 @@ +/* + * 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.configuration; + +import org.apache.ignite.configuration.annotation.ConfigurationRoot; +import org.apache.ignite.configuration.annotation.ConfigurationType; +import org.apache.ignite.configuration.annotation.Value; + +/** + * System Configuration schema. + */ +@ConfigurationRoot(rootName = "system", type = ConfigurationType.LOCAL) +public class SystemConfigurationSchema { Review Comment: I'm not sure that this is a good naming. I would name it like 'PathsConfigurationSchema`. As I understood, this class will have other paths, not only `partitionsBasePath`. The same for root, I would name it `paths` ########## modules/system-configuration/src/main/java/org/apache/ignite/internal/configuration/IgnitePaths.java: ########## @@ -0,0 +1,126 @@ +/* + * 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.configuration; + + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.Supplier; +import org.apache.ignite.configuration.ConfigurationValue; +import org.apache.ignite.internal.lang.IgniteInternalException; +import org.apache.ignite.internal.util.LazyPath; + +/** + * Manages storage paths for Ignite. + */ +public class IgnitePaths { + + /** + * Path to the base directory of the partitions data. + */ + private static final Path PARTITIONS_BASE_PATH = Paths.get("partitions"); + + /** + * Path to the persistent storage used by the VaultService component. + */ + private static final Path VAULT_DB_PATH = Paths.get("vault"); + + /** + * Path to the persistent storage used by the MetaStorageManager component. + */ + private static final Path METASTORAGE_DB_PATH = Paths.get("metastorage"); + + /** + * Path to the persistent storage used by the ClusterManagementGroupManager component. + */ + private static final Path CMG_DB_PATH = Paths.get("cmg"); + + /** + * Path for the persistent storage. + */ + private static final Path STORAGE_PATH = Paths.get("db"); + + /** + * Path for the raft log. + */ + private static final Path RAFT_LOG_PATH = Paths.get("log"); + + /** + * Path for the metadata. Review Comment: It is not obvious what metadata we are talking about ########## modules/core/src/main/java/org/apache/ignite/internal/util/LazyPath.java: ########## @@ -0,0 +1,145 @@ +/* + * 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.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.function.Supplier; +import org.apache.ignite.internal.lang.IgniteInternalException; + +/** + * A {@link Lazy} for {@link Path}. + * + * <p>Use this class to defer initialization of {@link Path} until it is needed. + */ +public class LazyPath extends Lazy<Path> { + + private LazyPath(Supplier<Path> supplier) { + super(supplier); + } + + /** + * Create a new instance for a path. + * + * @param defaultPath Path. + */ + public static LazyPath create(Path defaultPath) { + return new LazyPath(() -> defaultPath); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPath}. + * + * @param pathSupplier Path supplier. + * @param defaultPath Default path. + */ + public static LazyPath create(Supplier<String> pathSupplier, Path defaultPath) { + return new LazyPath(() -> pathOrDefault(pathSupplier.get(), defaultPath)); + } + + /** + * Create a new instance from {@code pathSupplier} if it returns a nonempty value, otherwise use {@code defaultPathSupplier}. + * + * @param pathSupplier Path supplier. + * @param defaultPathSupplier Default path supplier. + */ + public static LazyPath create(Supplier<String> pathSupplier, Supplier<Path> defaultPathSupplier) { Review Comment: this method is not used -- 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]
