AMashenkov commented on code in PR #1832: URL: https://github.com/apache/ignite-3/pull/1832#discussion_r1145889328
########## modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/impl/StandaloneMetaStorageManager.java: ########## @@ -0,0 +1,135 @@ +/* + * 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.metastorage.impl; + +import static java.util.Collections.singleton; +import static java.util.concurrent.CompletableFuture.completedFuture; +import static java.util.concurrent.CompletableFuture.failedFuture; + +import java.io.Serializable; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicReference; +import org.apache.ignite.internal.cluster.management.ClusterManagementGroupManager; +import org.apache.ignite.internal.cluster.management.topology.api.LogicalTopologyService; +import org.apache.ignite.internal.metastorage.server.KeyValueStorage; +import org.apache.ignite.internal.metastorage.server.SimpleInMemoryKeyValueStorage; +import org.apache.ignite.internal.metastorage.server.raft.MetaStorageListener; +import org.apache.ignite.internal.raft.Command; +import org.apache.ignite.internal.raft.RaftManager; +import org.apache.ignite.internal.raft.ReadCommand; +import org.apache.ignite.internal.raft.WriteCommand; +import org.apache.ignite.internal.raft.service.CommandClosure; +import org.apache.ignite.internal.raft.service.RaftGroupService; +import org.apache.ignite.internal.util.IgniteSpinBusyLock; +import org.apache.ignite.internal.vault.VaultManager; +import org.apache.ignite.network.ClusterNode; +import org.apache.ignite.network.ClusterService; +import org.apache.ignite.network.NetworkAddress; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; +import org.mockito.ArgumentMatchers; +import org.mockito.Mockito; + +/** + * MetaStorageManager dummy implementation. + */ +@TestOnly +public class StandaloneMetaStorageManager extends MetaStorageManagerImpl { + private static final String TEST_NODE_NAME = "test"; + + /** + * Creates standalone MetaStorage manager for provided VaultManager. + */ + public static StandaloneMetaStorageManager create(VaultManager vaultMgr) { + return create(vaultMgr, new SimpleInMemoryKeyValueStorage(TEST_NODE_NAME)); + } + + /** + * Creates standalone MetaStorage manager for provided VaultManager. + */ + public static StandaloneMetaStorageManager create(VaultManager vaultMgr, KeyValueStorage storage) { + return new StandaloneMetaStorageManager( + vaultMgr, + Mockito.mock(ClusterService.class), + Mockito.mock(ClusterManagementGroupManager.class), + Mockito.mock(LogicalTopologyService.class), + Mockito.mock(RaftManager.class), + storage + ); + } + + private final KeyValueStorage keyValueStorage; + + /** + * The constructor. + * + * @param vaultMgr Vault manager. + * @param clusterService Cluster network service. + * @param cmgMgr Cluster management service Manager. + * @param logicalTopologyService Logical topology service. + * @param raftMgr Raft manager. + * @param storage Storage. This component owns this resource and will manage its lifecycle. + */ + public StandaloneMetaStorageManager(VaultManager vaultMgr, ClusterService clusterService, ClusterManagementGroupManager cmgMgr, + LogicalTopologyService logicalTopologyService, RaftManager raftMgr, KeyValueStorage storage) { + super(vaultMgr, clusterService, cmgMgr, logicalTopologyService, raftMgr, storage); + + keyValueStorage = storage; + } + + @Override + public void start() { + keyValueStorage.start(); Review Comment: Here, we avoid interaction with CMG and just complete this manager initialization with mocked MetastorageService. Surprisingly, MetaStorageImpl is responsible for keyValueStorage start/stop. So, actualy, keyValueStorage.stop() will be called in super method. -- 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]
