Skip to content

Commit

Permalink
Remove unnecessary type parameter.
Browse files Browse the repository at this point in the history
  • Loading branch information
apcj committed Jul 14, 2016
1 parent 6a64f6a commit 4c48c71
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Expand Up @@ -35,7 +35,7 @@
/** /**
* A replicator implementation suitable in a RAFT context. Will handle resending due to timeouts and leader switches. * A replicator implementation suitable in a RAFT context. Will handle resending due to timeouts and leader switches.
*/ */
public class RaftReplicator implements Replicator<ReplicatedContent>, Listener<CoreMember> public class RaftReplicator implements Replicator, Listener<CoreMember>
{ {
private final CoreMember me; private final CoreMember me;
private final Outbound<CoreMember,RaftMessages.RaftMessage> outbound; private final Outbound<CoreMember,RaftMessages.RaftMessage> outbound;
Expand Down Expand Up @@ -90,9 +90,7 @@ public Future<Object> replicate( ReplicatedContent command, boolean trackResult
} }
} while( !progress.isReplicated() ); } while( !progress.isReplicated() );


BiConsumer<Object,Throwable> cleanup = ( ignored1, ignored2 ) -> { BiConsumer<Object,Throwable> cleanup = ( ignored1, ignored2 ) -> sessionPool.releaseSession( session );
sessionPool.releaseSession( session );
};


if( trackResult ) if( trackResult )
{ {
Expand Down
Expand Up @@ -24,7 +24,7 @@
/** /**
* Replicate content across a cluster of servers. * Replicate content across a cluster of servers.
*/ */
public interface Replicator<CONTENT extends ReplicatedContent> public interface Replicator
{ {
/** /**
* Submit content for replication. This method does not guarantee that the content * Submit content for replication. This method does not guarantee that the content
Expand All @@ -36,5 +36,5 @@ public interface Replicator<CONTENT extends ReplicatedContent>
* *
* @return A future that will receive the result when available. Only valid if trackResult is set. * @return A future that will receive the result when available. Only valid if trackResult is set.
*/ */
Future<Object> replicate( CONTENT content, boolean trackResult ) throws InterruptedException; Future<Object> replicate( ReplicatedContent content, boolean trackResult ) throws InterruptedException;
} }
Expand Up @@ -25,7 +25,7 @@


import org.neo4j.coreedge.raft.state.StateMachine; import org.neo4j.coreedge.raft.state.StateMachine;


public class DirectReplicator<Command extends ReplicatedContent> implements Replicator<Command> public class DirectReplicator<Command extends ReplicatedContent> implements Replicator
{ {
private final StateMachine<Command> stateMachine; private final StateMachine<Command> stateMachine;
private long commandIndex = 0; private long commandIndex = 0;
Expand All @@ -36,10 +36,10 @@ public DirectReplicator( StateMachine<Command> stateMachine )
} }


@Override @Override
public synchronized Future<Object> replicate( Command content, boolean trackResult ) public synchronized Future<Object> replicate( ReplicatedContent content, boolean trackResult )
{ {
AtomicReference<CompletableFuture<Object>> futureResult = new AtomicReference<>( new CompletableFuture<>() ); AtomicReference<CompletableFuture<Object>> futureResult = new AtomicReference<>( new CompletableFuture<>() );
stateMachine.applyCommand( content, commandIndex++, result -> { stateMachine.applyCommand( (Command) content, commandIndex++, result -> {
if ( trackResult ) if ( trackResult )
{ {
futureResult.getAndUpdate( result::apply ); futureResult.getAndUpdate( result::apply );
Expand Down
Expand Up @@ -59,8 +59,8 @@


public class ReplicatedTokenHolderTest public class ReplicatedTokenHolderTest
{ {
Dependencies dependencies = mock( Dependencies.class ); private Dependencies dependencies = mock( Dependencies.class );
long TIMEOUT_MILLIS = 10; private long TIMEOUT_MILLIS = 10;


@Test @Test
public void shouldStoreInitialTokens() throws Exception public void shouldStoreInitialTokens() throws Exception
Expand Down Expand Up @@ -156,7 +156,7 @@ public void shouldTimeoutIfTokenDoesNotReplicateWithinTimeout() throws Exception
} }
} }


private static class DropAllTheThingsReplicator implements Replicator<ReplicatedContent> private static class DropAllTheThingsReplicator implements Replicator
{ {
@Override @Override
public Future<Object> replicate( final ReplicatedContent content, boolean trackResult ) public Future<Object> replicate( final ReplicatedContent content, boolean trackResult )
Expand Down

0 comments on commit 4c48c71

Please sign in to comment.