Skip to content

Commit

Permalink
Rename StubReplicator to DirectReplicator.
Browse files Browse the repository at this point in the history
Since that is what it does, replicates directly.
  • Loading branch information
martinfurmanski committed Jan 18, 2016
1 parent 4f3d49c commit 0224f99
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Expand Up @@ -23,7 +23,7 @@

import org.neo4j.coreedge.raft.log.InMemoryRaftLog;
import org.neo4j.coreedge.raft.log.RaftLogEntry;
import org.neo4j.coreedge.raft.replication.StubReplicator;
import org.neo4j.coreedge.raft.replication.DirectReplicator;
import org.neo4j.coreedge.raft.state.membership.InMemoryRaftMembershipState;
import org.neo4j.coreedge.server.RaftTestMember;
import org.neo4j.coreedge.server.RaftTestMemberSetBuilder;
Expand All @@ -49,7 +49,7 @@ public void membershipManagerShouldUseLatestAppendedMembershipSetEntries()
// given
final InMemoryRaftLog log = new InMemoryRaftLog();

RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new StubReplicator(),
RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new DirectReplicator(),
RaftTestMemberSetBuilder.INSTANCE, log, NullLogProvider.getInstance(), 3, 1000, new FakeClock(),
1000, new InMemoryRaftMembershipState<>() );

Expand All @@ -72,7 +72,7 @@ public void membershipManagerShouldRevertToOldMembershipSetAfterTruncationCauses
final InMemoryRaftLog log = new InMemoryRaftLog();


RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new StubReplicator(),
RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new DirectReplicator(),
RaftTestMemberSetBuilder.INSTANCE, log, NullLogProvider.getInstance(), 3, 1000, new FakeClock(),
1000, new InMemoryRaftMembershipState<>() );

Expand All @@ -97,7 +97,7 @@ public void membershipManagerShouldRevertToEarlierAppendedMembershipSetAfterTrun
// given
final InMemoryRaftLog log = new InMemoryRaftLog();

RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new StubReplicator(),
RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new DirectReplicator(),
RaftTestMemberSetBuilder.INSTANCE, log, NullLogProvider.getInstance(), 3, 1000, new FakeClock(),
1000, new InMemoryRaftMembershipState<>() );

Expand Down Expand Up @@ -126,7 +126,7 @@ public void shouldNotOverwriteCurrentStateWithPreviousState() throws Exception
final long logIndex = 42l;
when( state.logIndex() ).thenReturn( logIndex );

RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new StubReplicator(),
RaftMembershipManager<RaftTestMember> membershipManager = new RaftMembershipManager<>( new DirectReplicator(),
RaftTestMemberSetBuilder.INSTANCE, log, NullLogProvider.getInstance(), 3, 1000, new FakeClock(),
1000, state );

Expand All @@ -139,4 +139,4 @@ public void shouldNotOverwriteCurrentStateWithPreviousState() throws Exception
verify( state, times( 0 ) ).logIndex( anyLong() );
verify( state, times( 0 ) ).setVotingMembers( anySet() );
}
}
}
Expand Up @@ -22,7 +22,7 @@
import java.util.HashSet;
import java.util.Set;

public class StubReplicator implements Replicator
public class DirectReplicator implements Replicator
{
private final Set<ReplicatedContentListener> listeners = new HashSet<>();
private long logIndex = 0;
Expand Down
Expand Up @@ -24,7 +24,7 @@

import org.junit.Test;

import org.neo4j.coreedge.raft.replication.StubReplicator;
import org.neo4j.coreedge.raft.replication.DirectReplicator;
import org.neo4j.coreedge.raft.state.id_allocation.InMemoryIdAllocationState;
import org.neo4j.coreedge.server.AdvertisedSocketAddress;
import org.neo4j.coreedge.server.CoreMember;
Expand All @@ -39,7 +39,7 @@ public class ReplicatedIdRangeAcquirerTest
new AdvertisedSocketAddress( "a:2" ) );
private final CoreMember two = new CoreMember( new AdvertisedSocketAddress( "b:1" ),
new AdvertisedSocketAddress( "b:2" ) );
private final StubReplicator replicator = new StubReplicator();
private final DirectReplicator replicator = new DirectReplicator();

@Test
public void consecutiveAllocationsFromSeparateIdGeneratorsForSameIdTypeShouldNotDuplicateWhenInitialIdIsZero()
Expand Down
Expand Up @@ -22,7 +22,7 @@
import org.junit.Test;

import org.neo4j.coreedge.raft.LeaderLocator;
import org.neo4j.coreedge.raft.replication.StubReplicator;
import org.neo4j.coreedge.raft.replication.DirectReplicator;
import org.neo4j.coreedge.server.RaftTestMember;
import org.neo4j.kernel.impl.locking.Locks;
import org.neo4j.kernel.impl.locking.ResourceTypes;
Expand All @@ -43,7 +43,7 @@ public void shouldIssueLocksOnLeader() throws Exception
{
// given
RaftTestMember me = member( 0 );
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
ReplicatedLockTokenStateMachine<RaftTestMember> replicatedLockStateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
LeaderLocator<RaftTestMember> leaderLocator = mock( LeaderLocator.class );
when(leaderLocator.getLeader()).thenReturn( me );
Expand All @@ -65,7 +65,7 @@ public void shouldNotIssueLocksOnNonLeader() throws Exception
// given
RaftTestMember me = member( 0 );
RaftTestMember leader = member( 1 );
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
ReplicatedLockTokenStateMachine<RaftTestMember> replicatedLockStateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
LeaderLocator<RaftTestMember> leaderLocator = mock( LeaderLocator.class );
when(leaderLocator.getLeader()).thenReturn( leader );
Expand Down
Expand Up @@ -21,7 +21,7 @@

import org.junit.Test;

import org.neo4j.coreedge.raft.replication.StubReplicator;
import org.neo4j.coreedge.raft.replication.DirectReplicator;

import static org.junit.Assert.assertEquals;

Expand All @@ -33,8 +33,8 @@ public class ReplicatedLockTokenStateMachineTest
public void shouldStartWithInvalidTokenId() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
DirectReplicator replicator = new DirectReplicator();
LockTokenManager stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );

// when
int initialTokenId = stateMachine.currentToken().id();
Expand All @@ -47,7 +47,7 @@ public void shouldStartWithInvalidTokenId() throws Exception
public void shouldIssueNextLockTokenCandidateId() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
ReplicatedLockTokenStateMachine stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
int firstCandidateId = stateMachine.nextCandidateId();

Expand All @@ -62,7 +62,7 @@ public void shouldIssueNextLockTokenCandidateId() throws Exception
public void shouldKeepTrackOfCurrentLockTokenId() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
LockTokenManager stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
int firstCandidateId = stateMachine.nextCandidateId();

Expand All @@ -83,7 +83,7 @@ public void shouldKeepTrackOfCurrentLockTokenId() throws Exception
public void shouldKeepTrackOfLockTokenOwner() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
LockTokenManager stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
int firstCandidateId = stateMachine.nextCandidateId();

Expand All @@ -104,7 +104,7 @@ public void shouldKeepTrackOfLockTokenOwner() throws Exception
public void shouldAcceptOnlyFirstRequestWithSameId() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
LockTokenManager stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
int firstCandidateId = stateMachine.nextCandidateId();

Expand All @@ -129,7 +129,7 @@ public void shouldAcceptOnlyFirstRequestWithSameId() throws Exception
public void shouldOnlyAcceptNextImmediateId() throws Exception
{
// given
StubReplicator replicator = new StubReplicator();
DirectReplicator replicator = new DirectReplicator();
LockTokenManager stateMachine = new ReplicatedLockTokenStateMachine<>( replicator );
int firstCandidateId = stateMachine.nextCandidateId();

Expand Down

0 comments on commit 0224f99

Please sign in to comment.