Add a Builder for RaftServer.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ratis/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ratis/commit/0fed3078 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ratis/tree/0fed3078 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ratis/diff/0fed3078 Branch: refs/heads/master Commit: 0fed3078dd04c799067e856fb191fb0244a0f544 Parents: 336874f Author: Tsz-Wo Nicholas Sze <[email protected]> Authored: Fri Jan 13 15:47:28 2017 +0800 Committer: Tsz-Wo Nicholas Sze <[email protected]> Committed: Fri Jan 13 15:47:28 2017 +0800 ---------------------------------------------------------------------- .../ratis/client/impl/ClientImplUtils.java | 2 +- .../ratis/examples/RaftExamplesTestUtil.java | 9 ++ .../org/apache/ratis/server/RaftServer.java | 54 ++++++++++ .../ratis/server/impl/ConfigurationManager.java | 2 +- .../ratis/server/impl/RaftServerImpl.java | 10 +- .../ratis/server/impl/ServerImplUtils.java | 101 +++++++++++++++++++ .../apache/ratis/server/impl/ServerUtils.java | 81 --------------- .../apache/ratis/server/protocol/TermIndex.java | 4 +- .../java/org/apache/ratis/MiniRaftCluster.java | 19 ++-- .../ratis/server/impl/RaftServerTestUtil.java | 5 +- .../server/storage/TestSegmentedRaftLog.java | 5 +- .../SimpleStateMachine4Testing.java | 2 +- .../ratis/statemachine/TestStateMachine.java | 2 +- 13 files changed, 192 insertions(+), 104 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientImplUtils.java ---------------------------------------------------------------------- diff --git a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientImplUtils.java b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientImplUtils.java index 472c8b4..542f600 100644 --- a/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientImplUtils.java +++ b/ratis-client/src/main/java/org/apache/ratis/client/impl/ClientImplUtils.java @@ -23,7 +23,7 @@ import org.apache.ratis.protocol.RaftPeer; import java.util.Collection; -/** Utilities for the client implementation. */ +/** Client utilities for internal use. */ public class ClientImplUtils { public static RaftClient newRaftClient( String clientId, Collection< RaftPeer > peers, String leaderId, http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-examples/src/test/java/org/apache/ratis/examples/RaftExamplesTestUtil.java ---------------------------------------------------------------------- diff --git a/ratis-examples/src/test/java/org/apache/ratis/examples/RaftExamplesTestUtil.java b/ratis-examples/src/test/java/org/apache/ratis/examples/RaftExamplesTestUtil.java index ff936bd..873c0da 100644 --- a/ratis-examples/src/test/java/org/apache/ratis/examples/RaftExamplesTestUtil.java +++ b/ratis-examples/src/test/java/org/apache/ratis/examples/RaftExamplesTestUtil.java @@ -24,11 +24,16 @@ import org.apache.ratis.hadooprpc.MiniRaftClusterWithHadoopRpc; import org.apache.ratis.netty.MiniRaftClusterWithNetty; import org.apache.ratis.server.simulation.MiniRaftClusterWithSimulatedRpc; import org.apache.ratis.statemachine.StateMachine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.*; +import java.util.stream.Collectors; public class RaftExamplesTestUtil { + public static final Logger LOG = LoggerFactory.getLogger(RaftExamplesTestUtil.class); + private static void add( Collection<Object[]> clusters, MiniRaftCluster.Factory factory, String[] ids, RaftProperties properties) @@ -68,6 +73,10 @@ public class RaftExamplesTestUtil { if (isAll || classes.contains(MiniRaftClusterWithGRpc.class)) { add(clusters, MiniRaftClusterWithGRpc.FACTORY, ids.next(), prop); } + for(int i = 0; i < clusters.size(); i++) { + LOG.info(i + ": " + clusters.get(i)[0].getClass().getSimpleName()); + } + LOG.info("#clusters = " + clusters.size()); return clusters; } http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/RaftServer.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/RaftServer.java b/ratis-server/src/main/java/org/apache/ratis/server/RaftServer.java index 06967ce..f3f63ae 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/RaftServer.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/RaftServer.java @@ -17,12 +17,18 @@ */ package org.apache.ratis.server; +import com.google.common.base.Preconditions; +import org.apache.ratis.conf.RaftProperties; import org.apache.ratis.protocol.RaftClientAsynchronousProtocol; import org.apache.ratis.protocol.RaftClientProtocol; +import org.apache.ratis.protocol.RaftPeer; +import org.apache.ratis.server.impl.ServerImplUtils; import org.apache.ratis.server.protocol.RaftServerProtocol; import org.apache.ratis.statemachine.StateMachine; import java.io.Closeable; +import java.io.IOException; +import java.util.concurrent.atomic.AtomicInteger; /** Raft server interface */ public interface RaftServer extends Closeable, RaftServerProtocol, @@ -41,4 +47,52 @@ public interface RaftServer extends Closeable, RaftServerProtocol, * @return the StateMachine instance. */ StateMachine getStateMachine(); + + /** @return a {@link Builder}. */ + static Builder newBuilder() { + return new Builder(); + } + + /** To build {@link RaftServer} objects. */ + class Builder { + private static final AtomicInteger COUNT = new AtomicInteger(); + + private String serverId = RaftServer.class.getSimpleName() + COUNT.incrementAndGet(); + private StateMachine stateMachine; + private Iterable<RaftPeer> peers; + private RaftProperties properties; + + /** @return a {@link RaftServer} object. */ + public RaftServer build() throws IOException { + Preconditions.checkNotNull(stateMachine); + Preconditions.checkNotNull(peers); + Preconditions.checkNotNull(properties); + + return ServerImplUtils.newRaftServer(serverId, stateMachine, peers, properties); + } + + /** Set the server ID. */ + public Builder setServerId(String serverId) { + this.serverId = serverId; + return this; + } + + /** Set the {@link StateMachine} of the server. */ + public Builder setStateMachine(StateMachine stateMachine) { + this.stateMachine = stateMachine; + return this; + } + + /** Set all the peers (including the server being built) in the Raft cluster. */ + public Builder setPeers(Iterable<RaftPeer> peers) { + this.peers = peers; + return this; + } + + /** Set {@link RaftProperties}. */ + public Builder setProperties(RaftProperties properties) { + this.properties = properties; + return this; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java index f495c28..7769de1 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ConfigurationManager.java @@ -38,7 +38,7 @@ public class ConfigurationManager { */ private RaftConfiguration currentConf; - public ConfigurationManager(RaftConfiguration initialConf) { + ConfigurationManager(RaftConfiguration initialConf) { setInitialConf(initialConf); } http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java index d079abf..135ae68 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/RaftServerImpl.java @@ -25,10 +25,7 @@ import static org.apache.ratis.util.LifeCycle.State.STARTING; import static org.apache.ratis.shaded.proto.RaftProtos.AppendEntriesReplyProto.AppendResult.*; import java.io.IOException; import java.io.InterruptedIOException; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.OptionalLong; +import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; @@ -104,8 +101,9 @@ public class RaftServerImpl implements RaftServer { private final LogAppenderFactory appenderFactory; - public RaftServerImpl(String id, RaftConfiguration raftConf, - RaftProperties properties, StateMachine stateMachine) throws IOException { + RaftServerImpl(String id, StateMachine stateMachine, + RaftConfiguration raftConf, RaftProperties properties) + throws IOException { this.lifeCycle = new LifeCycle(id); minTimeoutMs = properties.getInt( RaftServerConfigKeys.RAFT_SERVER_RPC_TIMEOUT_MIN_MS_KEY, http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerImplUtils.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerImplUtils.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerImplUtils.java new file mode 100644 index 0000000..c6d650f --- /dev/null +++ b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerImplUtils.java @@ -0,0 +1,101 @@ +/** + * 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.ratis.server.impl; + +import org.apache.commons.lang.builder.HashCodeBuilder; +import org.apache.ratis.conf.RaftProperties; +import org.apache.ratis.protocol.RaftPeer; +import org.apache.ratis.server.RaftServer; +import org.apache.ratis.server.protocol.TermIndex; +import org.apache.ratis.statemachine.StateMachine; + +import java.io.IOException; + +/** Server utilities for internal use. */ +public class ServerImplUtils { + public static RaftServer newRaftServer( + String id, StateMachine stateMachine, + Iterable<RaftPeer> peers, RaftProperties properties) throws IOException { + return newRaftServer(id, stateMachine, + RaftConfiguration.newBuilder().setConf(peers).build(), + properties); + } + + public static RaftServerImpl newRaftServer( + String id, StateMachine stateMachine, + RaftConfiguration conf, RaftProperties properties) throws IOException { + return new RaftServerImpl(id, stateMachine, conf, properties); + } + + public static TermIndex newTermIndex(long term, long index) { + return new TermIndexImpl(term, index); + } + + private static class TermIndexImpl implements TermIndex { + private final long term; + private final long index; //log index; first index is 1. + + TermIndexImpl(long term, long logIndex) { + this.term = term; + this.index = logIndex; + } + + @Override + public long getTerm() { + return term; + } + + @Override + public long getIndex() { + return index; + } + + @Override + public int compareTo(TermIndex that) { + final int d = Long.compare(this.getTerm(), that.getTerm()); + return d != 0 ? d : Long.compare(this.getIndex(), that.getIndex()); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj == null || !(obj instanceof TermIndexImpl)) { + return false; + } + + final TermIndexImpl that = (TermIndexImpl) obj; + return this.getTerm() == that.getTerm() + && this.getIndex() == that.getIndex(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(term).append(index).hashCode(); + } + + private static String toString(long n) { + return n < 0 ? "~" : "" + n; + } + + @Override + public String toString() { + return "(t:" + toString(term) + ", i:" + toString(index) + ")"; + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerUtils.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerUtils.java b/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerUtils.java deleted file mode 100644 index 3dc9ab4..0000000 --- a/ratis-server/src/main/java/org/apache/ratis/server/impl/ServerUtils.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * 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.ratis.server.impl; - -import org.apache.commons.lang.builder.HashCodeBuilder; -import org.apache.ratis.server.protocol.TermIndex; - -/** Server utilities for internal use. */ -public class ServerUtils { - public static TermIndex newTermIndex(long term, long index) { - return new TermIndexImpl(term, index); - } - - private static class TermIndexImpl implements TermIndex { - private final long term; - private final long index; //log index; first index is 1. - - TermIndexImpl(long term, long logIndex) { - this.term = term; - this.index = logIndex; - } - - @Override - public long getTerm() { - return term; - } - - @Override - public long getIndex() { - return index; - } - - @Override - public int compareTo(TermIndex that) { - final int d = Long.compare(this.getTerm(), that.getTerm()); - return d != 0 ? d : Long.compare(this.getIndex(), that.getIndex()); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } else if (obj == null || !(obj instanceof TermIndexImpl)) { - return false; - } - - final TermIndexImpl that = (TermIndexImpl) obj; - return this.getTerm() == that.getTerm() - && this.getIndex() == that.getIndex(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder().append(term).append(index).hashCode(); - } - - private static String toString(long n) { - return n < 0 ? "~" : "" + n; - } - - @Override - public String toString() { - return "(t:" + toString(term) + ", i:" + toString(index) + ")"; - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/main/java/org/apache/ratis/server/protocol/TermIndex.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/main/java/org/apache/ratis/server/protocol/TermIndex.java b/ratis-server/src/main/java/org/apache/ratis/server/protocol/TermIndex.java index 665f5d5..477b70c 100644 --- a/ratis-server/src/main/java/org/apache/ratis/server/protocol/TermIndex.java +++ b/ratis-server/src/main/java/org/apache/ratis/server/protocol/TermIndex.java @@ -17,7 +17,7 @@ */ package org.apache.ratis.server.protocol; -import org.apache.ratis.server.impl.ServerUtils; +import org.apache.ratis.server.impl.ServerImplUtils; /** The term and the log index defined in the Raft consensus algorithm. */ public interface TermIndex extends Comparable<TermIndex> { @@ -29,7 +29,7 @@ public interface TermIndex extends Comparable<TermIndex> { /** Create a new {@link TermIndex} instance. */ static TermIndex newTermIndex(long term, long index) { - return ServerUtils.newTermIndex(term, index); + return ServerImplUtils.newTermIndex(term, index); } } http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java index 7eb6ddb..d824014 100644 --- a/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java +++ b/ratis-server/src/test/java/org/apache/ratis/MiniRaftCluster.java @@ -27,6 +27,7 @@ import org.apache.ratis.server.RaftServerRpc; import org.apache.ratis.server.impl.DelayLocalExecutionInjection; import org.apache.ratis.server.impl.RaftConfiguration; import org.apache.ratis.server.impl.RaftServerImpl; +import org.apache.ratis.server.impl.ServerImplUtils; import org.apache.ratis.server.storage.MemoryRaftLog; import org.apache.ratis.server.storage.RaftLog; import org.apache.ratis.statemachine.BaseStateMachine; @@ -104,6 +105,10 @@ public abstract class MiniRaftCluster { } } + public static RaftConfiguration initConfiguration(int numServers) { + return initConfiguration(generateIds(numServers, 0)); + } + public static RaftConfiguration initConfiguration(String[] ids) { return RaftConfiguration.newBuilder() .setConf(Arrays.stream(ids).map(RaftPeer::new).collect(Collectors.toList())) @@ -142,7 +147,7 @@ public abstract class MiniRaftCluster { this.testBaseDir = getBaseDirectory(); conf.getPeers().forEach( - p -> servers.put(p.getId(), newRaftServer(p.getId(), conf, formatted))); + p -> servers.put(p.getId(), newRaftServer(p.getId(), formatted))); ExitUtils.disableSystemExit(); } @@ -168,7 +173,7 @@ public abstract class MiniRaftCluster { public void restartServer(String id, boolean format) throws IOException { killServer(id); servers.remove(id); - servers.put(id, newRaftServer(id, conf, format)); + servers.put(id, newRaftServer(id, format)); } public final void restart(boolean format) throws IOException { @@ -177,7 +182,7 @@ public abstract class MiniRaftCluster { List<String> idList = new ArrayList<>(servers.keySet()); for (String id : idList) { servers.remove(id); - servers.put(id, newRaftServer(id, conf, format)); + servers.put(id, newRaftServer(id, format)); } setPeerRpc(); @@ -196,8 +201,7 @@ public abstract class MiniRaftCluster { return conf; } - private RaftServerImpl newRaftServer(String id, RaftConfiguration conf, - boolean format) { + private RaftServerImpl newRaftServer(String id, boolean format) { final RaftServerImpl s; try { final String dirStr = testBaseDir + id; @@ -205,7 +209,8 @@ public abstract class MiniRaftCluster { formatDir(dirStr); } properties.set(RaftServerConfigKeys.RAFT_SERVER_STORAGE_DIR_KEY, dirStr); - s = new RaftServerImpl(id, conf, properties, getStateMachine4Test(properties)); + final StateMachine stateMachine = getStateMachine4Test(properties); + s = ServerImplUtils.newRaftServer(id, stateMachine, conf, properties); } catch (IOException e) { throw new RuntimeException(e); } @@ -255,7 +260,7 @@ public abstract class MiniRaftCluster { // create and add new RaftServers final List<RaftServerImpl> newServers = new ArrayList<>(ids.length); for (RaftPeer p : newPeers) { - RaftServerImpl newServer = newRaftServer(p.getId(), conf, true); + RaftServerImpl newServer = newRaftServer(p.getId(), true); Preconditions.checkArgument(!servers.containsKey(p.getId())); servers.put(p.getId(), newServer); newServers.add(newServer); http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java index dc10bd3..3cf2ef6 100644 --- a/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java +++ b/ratis-server/src/test/java/org/apache/ratis/server/impl/RaftServerTestUtil.java @@ -69,7 +69,8 @@ public class RaftServerTestUtil { Assert.assertEquals(peers.length, numIncluded + deadIncluded); } - public static StateMachine getStateMachine(RaftServerImpl s) { - return s.getStateMachine(); + public static ConfigurationManager newConfigurationManager( + RaftConfiguration initialConf) { + return new ConfigurationManager(initialConf); } } http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/test/java/org/apache/ratis/server/storage/TestSegmentedRaftLog.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/test/java/org/apache/ratis/server/storage/TestSegmentedRaftLog.java b/ratis-server/src/test/java/org/apache/ratis/server/storage/TestSegmentedRaftLog.java index 405a1a5..ce595c5 100644 --- a/ratis-server/src/test/java/org/apache/ratis/server/storage/TestSegmentedRaftLog.java +++ b/ratis-server/src/test/java/org/apache/ratis/server/storage/TestSegmentedRaftLog.java @@ -36,6 +36,7 @@ import org.apache.ratis.conf.RaftProperties; import org.apache.ratis.server.RaftServerConfigKeys; import org.apache.ratis.server.impl.ConfigurationManager; import org.apache.ratis.server.impl.RaftServerConstants; +import org.apache.ratis.server.impl.RaftServerTestUtil; import org.apache.ratis.shaded.proto.RaftProtos.LogEntryProto; import org.apache.ratis.util.FileUtils; import org.apache.ratis.util.ProtoUtils; @@ -69,8 +70,8 @@ public class TestSegmentedRaftLog { private File storageDir; private RaftProperties properties; private RaftStorage storage; - private final ConfigurationManager cm = new ConfigurationManager( - MiniRaftCluster.initConfiguration(MiniRaftCluster.generateIds(3, 0))); + private final ConfigurationManager cm = RaftServerTestUtil.newConfigurationManager( + MiniRaftCluster.initConfiguration(3)); @Before public void setup() throws Exception { http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java b/ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java index cc82371..952c40b 100644 --- a/ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java +++ b/ratis-server/src/test/java/org/apache/ratis/statemachine/SimpleStateMachine4Testing.java @@ -63,7 +63,7 @@ public class SimpleStateMachine4Testing extends BaseStateMachine { public static final boolean RAFT_TEST_SIMPLE_STATE_MACHINE_TAKE_SNAPSHOT_DEFAULT = false; public static SimpleStateMachine4Testing get(RaftServerImpl s) { - return (SimpleStateMachine4Testing)RaftServerTestUtil.getStateMachine(s); + return (SimpleStateMachine4Testing)s.getStateMachine(); } private final List<LogEntryProto> list = http://git-wip-us.apache.org/repos/asf/incubator-ratis/blob/0fed3078/ratis-server/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java ---------------------------------------------------------------------- diff --git a/ratis-server/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java b/ratis-server/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java index cdce568..bac2c38 100644 --- a/ratis-server/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java +++ b/ratis-server/src/test/java/org/apache/ratis/statemachine/TestStateMachine.java @@ -102,7 +102,7 @@ public class TestStateMachine { static class SMTransactionContext extends SimpleStateMachine4Testing { public static SMTransactionContext get(RaftServerImpl s) { - return (SMTransactionContext)RaftServerTestUtil.getStateMachine(s); + return (SMTransactionContext)s.getStateMachine(); } AtomicReference<Throwable> throwable = new AtomicReference<>(null);
