rpuch commented on code in PR #908: URL: https://github.com/apache/ignite-3/pull/908#discussion_r910691147
########## modules/raft/src/main/java/org/apache/ignite/raft/jraft/core/VolatileJRaftServiceFactory.java: ########## @@ -0,0 +1,63 @@ +/* + * 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.raft.jraft.core; + +import org.apache.ignite.raft.jraft.JRaftServiceFactory; +import org.apache.ignite.raft.jraft.entity.codec.LogEntryCodecFactory; +import org.apache.ignite.raft.jraft.entity.codec.v1.LogEntryV1CodecFactory; +import org.apache.ignite.raft.jraft.option.RaftOptions; +import org.apache.ignite.raft.jraft.storage.LogStorage; +import org.apache.ignite.raft.jraft.storage.RaftMetaStorage; +import org.apache.ignite.raft.jraft.storage.SnapshotStorage; +import org.apache.ignite.raft.jraft.storage.impl.LocalLogStorage; +import org.apache.ignite.raft.jraft.storage.impl.VolatileRaftMetaStorage; +import org.apache.ignite.raft.jraft.storage.snapshot.local.LocalSnapshotStorage; +import org.apache.ignite.raft.jraft.util.Requires; +import org.apache.ignite.raft.jraft.util.StringUtils; +import org.apache.ignite.raft.jraft.util.timer.DefaultRaftTimerFactory; +import org.apache.ignite.raft.jraft.util.timer.RaftTimerFactory; + +/** + * The factory for JRaft services producing volatile stores. Useful for Raft groups hosting partitions of in-memory tables. + */ +public class VolatileJRaftServiceFactory implements JRaftServiceFactory { + @Override public LogStorage createLogStorage(final String groupId, final RaftOptions raftOptions) { + Requires.requireTrue(StringUtils.isNotBlank(groupId), "Blank group id."); + + return new LocalLogStorage(raftOptions); + } + + @Override public SnapshotStorage createSnapshotStorage(final String uri, final RaftOptions raftOptions) { + Requires.requireTrue(!StringUtils.isBlank(uri), "Blank snapshot storage uri."); + + // TODO: IGNITE-17083 - return an in-memory store here (or get rid of SnapshotStorage) + + return new LocalSnapshotStorage(uri, raftOptions); + } + + @Override public RaftMetaStorage createRaftMetaStorage(final String uri, final RaftOptions raftOptions) { + return new VolatileRaftMetaStorage(); + } + + @Override public LogEntryCodecFactory createLogEntryCodecFactory() { + return LogEntryV1CodecFactory.getInstance(); Review Comment: Moved the methods' implementations to `default` 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]
