Skip to content

Commit

Permalink
Merge pull request #7576 from apcj/non-generic-replicator
Browse files Browse the repository at this point in the history
Remove unnecessary type parameter.
  • Loading branch information
davidegrohmann committed Jul 14, 2016
2 parents c290879 + 4c48c71 commit 0d9be8d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/**
* 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 Outbound<CoreMember,RaftMessages.RaftMessage> outbound;
Expand Down Expand Up @@ -90,9 +90,7 @@ public Future<Object> replicate( ReplicatedContent command, boolean trackResult
}
} while( !progress.isReplicated() );

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

if( trackResult )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* 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
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.
*/
Future<Object> replicate( CONTENT content, boolean trackResult ) throws InterruptedException;
Future<Object> replicate( ReplicatedContent content, boolean trackResult ) throws InterruptedException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

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 long commandIndex = 0;
Expand All @@ -36,10 +36,10 @@ public DirectReplicator( StateMachine<Command> stateMachine )
}

@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<>() );
stateMachine.applyCommand( content, commandIndex++, result -> {
stateMachine.applyCommand( (Command) content, commandIndex++, result -> {
if ( trackResult )
{
futureResult.getAndUpdate( result::apply );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@

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

@Test
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
public Future<Object> replicate( final ReplicatedContent content, boolean trackResult )
Expand Down

0 comments on commit 0d9be8d

Please sign in to comment.