ibessonov commented on code in PR #2165: URL: https://github.com/apache/ignite-3/pull/2165#discussion_r1222555363
########## modules/metastorage/src/testFixtures/java/org/apache/ignite/internal/metastorage/server/TestRocksDbKeyValueStorage.java: ########## @@ -0,0 +1,60 @@ +/* + * 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.server; + +import static org.apache.ignite.internal.util.ByteUtils.bytesToLong; +import static org.apache.ignite.lang.ErrorGroups.MetaStorage.STARTING_STORAGE_ERR; + +import java.nio.file.Path; +import org.apache.ignite.internal.metastorage.exceptions.MetaStorageException; +import org.apache.ignite.internal.metastorage.server.persistence.RocksDbKeyValueStorage; +import org.jetbrains.annotations.TestOnly; +import org.rocksdb.RocksDBException; + +/** + * Test version of {@link RocksDbKeyValueStorage}, but behavior on a start differs. In this version, storage is not destroyed on + * a restart, so it can be used in {@link org.apache.ignite.internal.metastorage.impl.StandaloneMetaStorageManager}, where raft + * layer is mocked and there are no raft's snapshot installing and log playback. + */ +@TestOnly +public class TestRocksDbKeyValueStorage extends RocksDbKeyValueStorage { + /** + * Constructor. + * + * @param nodeName Node name. + * @param dbPath RocksDB path. + */ + public TestRocksDbKeyValueStorage(String nodeName, Path dbPath) { + super(nodeName, dbPath); + } + + @Override + public void start() { + try { + createDb(); + + byte[] revision = getData().get(REVISION_KEY); + + if (revision != null) { + setRev(bytesToLong(revision)); + } Review Comment: You could move this to parent class and simply override "destroyRocksDb" with empty body. This way it would take less code and would be less confusing when it comes to abundance of "TestOnly" methods -- 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]
