rpuch commented on code in PR #4005:
URL: https://github.com/apache/ignite-3/pull/4005#discussion_r1713245025
##########
modules/cluster-management/build.gradle:
##########
@@ -75,6 +75,7 @@ dependencies {
integrationTestImplementation project(':ignite-raft')
integrationTestImplementation project(':ignite-raft-api')
integrationTestImplementation project(':ignite-catalog')
+ integrationTestImplementation project(':ignite-runner')
Review Comment:
Should the following TODO be here?
>// TODO https://issues.apache.org/jira/browse/IGNITE-22564 runner should
not be in test fixtures
##########
modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItIdempotentCommandCacheTest.java:
##########
@@ -179,11 +195,22 @@ private static class Node implements AutoCloseable {
cmgManager = mock(ClusterManagementGroupManager.class);
- Path metaStorageDir = workDir.resolve("metastorage" + index);
+ ComponentWorkingDir metastorageWorkDir = new
ComponentWorkingDir(workDir.resolve("metastorage" + index));
+
+ msLogStorageFactory =
+
SharedLogStorageFactoryUtils.create(clusterService.nodeName(),
metastorageWorkDir.raftLogPath());
+
+ RaftOptionsConfigurator msRaftConfigurator = options -> {
+ RaftGroupOptions raftOptions = (RaftGroupOptions) options;
+
+ // TODO: use interface, see
https://issues.apache.org/jira/browse/IGNITE-18273
+ raftOptions.setLogStorageFactory(msLogStorageFactory);
+ raftOptions.serverDataPath(metastorageWorkDir.metaPath());
+ };
Review Comment:
This spell seems to be repeated a lot. How about extracting a method with 2
parameters and using it instead?
##########
modules/metastorage/src/integrationTest/java/org/apache/ignite/internal/metastorage/impl/ItMetaStorageMultipleNodesAbstractTest.java:
##########
@@ -130,6 +135,12 @@ private class Node {
private final Loza raftManager;
+ private final LogStorageFactory defaultLogStorageFactory;
+
+ private final LogStorageFactory msLogStorageFactory;
+
+ private final LogStorageFactory cmgLogStorageFactory;
Review Comment:
Why are these different? Should they both be the same factory?
##########
modules/runner/src/main/java/org/apache/ignite/internal/app/IgniteImpl.java:
##########
@@ -406,6 +408,12 @@ public class IgniteImpl implements Ignite {
/** Default log storage factory for raft. */
private final LogStorageFactory logStorageFactory;
+ private final LogStorageFactory msLogStorageFactory;
+
+ private final LogStorageFactory cmgLogStorageFactory;
Review Comment:
Why are these different?
##########
modules/runner/src/main/java/org/apache/ignite/internal/configuration/IgnitePaths.java:
##########
@@ -68,21 +67,29 @@ public Path raftLogPath() {
}
/**
- * Path to Metastorage store.
+ * Get paths where metastorage data is stored.
*
- * @param workDir Ignite working dir.
+ * @param systemConfiguration System configuration.
+ * @param workDir Node's working dir.
+ * @return Working dir subtree structure representation for metastorage.
*/
- public static Path metastorageDbPath(Path workDir) {
- return workDir.resolve(METASTORAGE_DB_PATH);
+ public static ComponentWorkingDir metastoragePath(SystemLocalConfiguration
systemConfiguration, Path workDir) {
+ Path basePath = pathOrDefault(systemConfiguration.metastoragePath(),
() -> workDir.resolve(METASTORAGE_PATH));
+
+ return new ComponentWorkingDir(basePath);
}
/**
- * Path to CMG store.
+ * Get paths where CMG data is stored.
Review Comment:
```suggestion
* Gets paths where CMG data is stored.
```
##########
modules/raft-api/src/main/java/org/apache/ignite/internal/raft/RaftManager.java:
##########
@@ -118,7 +124,8 @@ <T extends RaftGroupService> CompletableFuture<T>
startRaftGroupNodeAndWaitNodeR
RaftGroupListener lsnr,
RaftGroupEventsListener eventsLsnr,
RaftNodeDisruptorConfiguration disruptorConfiguration,
- RaftServiceFactory<T> factory
+ RaftServiceFactory<T> factory,
+ RaftOptionsConfigurator storageConfigurator
Review Comment:
The configurer accepts an `Object`, but the argument is always a
`RaftGroupOptions`. How about at least adding a utility method that would allow
to hide the cast? Like
```
interface TypedConfigurator {
void configure(RaftGroupOptions options);
}
```
```
RaftOptionsConfigurator typeSafe(TypedConfigurator configurator) {
return options -> configurator.configure((RaftGroupOptions) options);
}
```
and use
`typeSafe(options -> blabla without cast)`
instead of `options -> blabla with cast` (all names are provisional)
##########
modules/table/src/integrationTest/java/org/apache/ignite/distributed/ReplicasSafeTimePropagationTest.java:
##########
@@ -293,6 +306,8 @@ CompletableFuture<Void> start() throws Exception {
),
RaftGroupEventsListener.noopLsnr,
RaftGroupOptions.defaults()
+ .serverDataPath(workingDir.metaPath())
+
.setLogStorageFactory(defaultLogStorageFactory)
Review Comment:
Do we even have 'default' log storages now? It seems that everything
(partitions, cmg, metastorage) has their paths explicitly configured via this
configurator.
An alternative would be to leave a default factory in `Loza` and keep
methods without configurator in the parameters, they would use the default
factory. But you seem to avoid this path. So does it make sense to keep the
'default' term?
##########
modules/placement-driver/build.gradle:
##########
@@ -57,6 +57,7 @@ dependencies {
integrationTestImplementation project(':ignite-transactions')
integrationTestImplementation project(':ignite-catalog')
integrationTestImplementation project(':ignite-metrics')
+ integrationTestImplementation project(':ignite-runner')
Review Comment:
Why is this needed here?
##########
modules/raft-api/src/main/java/org/apache/ignite/internal/raft/RaftOptionsConfigurator.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.raft;
+
+/**
+ * This interface allows to inject RAFT options configuration.
+ *
+ * <p>This is the example of using it:
+ * <pre>
+ * RaftOptionsConfigurator raftOptionsConfigurator = options -> {
+ * RaftGroupOptions raftOptions = (RaftGroupOptions) options;
+ *
+ * raftOptions.setLogStorageFactory(logStorageFactory);
+ * raftOptions.serverDataPath(dataPath);
+ * };
+ * </pre>
+ * TODO: https://issues.apache.org/jira/browse/IGNITE-18273
+ */
+@FunctionalInterface
+public interface RaftOptionsConfigurator {
Review Comment:
It seems to always configure `RaftGroupOptions`, not `RaftOptions`, so
should it be called `RaftGroupOptionsConfigurator` (or
`GroupOptionsConfigurator`)?
##########
modules/runner/src/main/java/org/apache/ignite/internal/configuration/IgnitePaths.java:
##########
@@ -68,21 +67,29 @@ public Path raftLogPath() {
}
/**
- * Path to Metastorage store.
+ * Get paths where metastorage data is stored.
Review Comment:
```suggestion
* Gets paths where metastorage data is stored.
```
##########
modules/raft-api/src/main/java/org/apache/ignite/internal/raft/RaftOptionsConfigurator.java:
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.raft;
+
+/**
+ * This interface allows to inject RAFT options configuration.
+ *
+ * <p>This is the example of using it:
+ * <pre>
+ * RaftOptionsConfigurator raftOptionsConfigurator = options -> {
+ * RaftGroupOptions raftOptions = (RaftGroupOptions) options;
+ *
+ * raftOptions.setLogStorageFactory(logStorageFactory);
+ * raftOptions.serverDataPath(dataPath);
+ * };
+ * </pre>
+ * TODO: https://issues.apache.org/jira/browse/IGNITE-18273
+ */
+@FunctionalInterface
+public interface RaftOptionsConfigurator {
Review Comment:
Also, isn't `configurer` more idiomatic than `configurator`?
##########
modules/raft/src/integrationTest/java/org/apache/ignite/raft/server/ItJraftServerLogPathTest.java:
##########
@@ -78,18 +81,6 @@ void testDefaultFactory() {
assertTrue(Files.exists(partitionsPath));
}
- @Test
- @WithSystemProperty(key =
SharedLogStorageFactoryUtils.LOGIT_STORAGE_ENABLED_PROPERTY, value = "true")
Review Comment:
Why is this test removed? Is it moved elsewhere?
##########
modules/runner/src/main/java/org/apache/ignite/internal/configuration/IgnitePaths.java:
##########
@@ -41,19 +41,18 @@ public class IgnitePaths {
/**
* Path to the persistent storage used by the MetaStorageManager component.
*/
- private static final Path METASTORAGE_DB_PATH = Paths.get("metastorage");
+ private static final Path METASTORAGE_PATH = Paths.get("metastorage");
/**
* Path to the persistent storage used by the
ClusterManagementGroupManager component.
*/
- private static final Path CMG_DB_PATH = Paths.get("cmg");
+ private static final Path CMG_PATH = Paths.get("cmg");
/**
- * Directory where partition data is stored. By default "partitions"
subfolder of data storage path is used.
+ * Get paths where partition data is stored.
Review Comment:
```suggestion
* Gets paths where partition data is stored.
```
--
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]