@Test public void shouldNotifyCacheAccessOnHowManyUpdatesOnCountsWeHadSoFar() throws Exception { // GIVEN final CountsTracker tracker = mock( CountsTracker.class ); final CountsAccessor.Updater updater = mock( CountsAccessor.Updater.class ); when( tracker.apply( anyLong() ) ).thenReturn( Optional.of( updater ) ); final CountsStoreBatchTransactionApplier applier = new CountsStoreBatchTransactionApplier( tracker, TransactionApplicationMode.INTERNAL ); // WHEN try ( TransactionApplier txApplier = applier.startTx( new TransactionToApply( null, 2L ) ) ) { txApplier.visitNodeCountsCommand( new Command.NodeCountsCommand( StatementConstants.ANY_LABEL, 1 ) ); } // THEN verify( updater, times( 1 ) ).incrementNodeCount( StatementConstants.ANY_LABEL, 1 ); } }
@Test public void testVisitNodeCountsCommand() throws Exception { Command.NodeCountsCommand cmd = mock( Command.NodeCountsCommand.class ); when( cmd.handle( any( CommandVisitor.class ) ) ).thenCallRealMethod(); // WHEN boolean result = facade.visitNodeCountsCommand( cmd ); // THEN InOrder inOrder = inOrder( txApplier1, txApplier2, txApplier3 ); inOrder.verify( txApplier1 ).visitNodeCountsCommand( cmd ); inOrder.verify( txApplier2 ).visitNodeCountsCommand( cmd ); inOrder.verify( txApplier3 ).visitNodeCountsCommand( cmd ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); }
public void incrementNodeCount( int labelId, long delta ) { addCommand( new Command.NodeCountsCommand().init( labelId, delta ) ); }
@Override public void visitNodeCount( int labelId, long count ) { if ( count != 0 ) { // Only add commands for counts that actually change commands.add( new Command.NodeCountsCommand( labelId, count ) ); } }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
public NodeCountsCommand( int labelId, long delta ) { setup( labelId, Mode.UPDATE ); assert delta != 0 : "Tried to create a NodeCountsCommand for something that didn't change any count"; this.labelId = labelId; this.delta = delta; }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
@Override public boolean visitNodeCountsCommand( Command.NodeCountsCommand command ) { assert countsUpdater != null || mode == TransactionApplicationMode.RECOVERY : "You must call begin first"; haveUpdates = true; if ( countsUpdater != null ) { // CountsUpdater is null if we're in recovery and the counts store already has had this transaction applied. countsUpdater.incrementNodeCount( command.labelId(), command.delta() ); } return false; }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
public void incrementNodeCount( int labelId, long delta ) { otherCommands.add( new Command.NodeCountsCommand( labelId, delta ) ); }
@Override public boolean visitNodeCountsCommand( Command.NodeCountsCommand command ) { assert countsUpdater != null || mode == TransactionApplicationMode.RECOVERY : "You must call begin first"; haveUpdates = true; if ( countsUpdater != null ) { // CountsUpdater is null if we're in recovery and the counts store already has had this transaction applied. countsUpdater.incrementNodeCount( command.labelId(), command.delta() ); } return false; }
private Command visitNodeCountsCommand( ReadableChannel channel ) throws IOException { int labelId = channel.getInt(); long delta = channel.getLong(); return new Command.NodeCountsCommand( labelId, delta ); }
public NodeCountsCommand( int labelId, long delta ) { setup( labelId, Mode.UPDATE ); assert delta != 0 : "Tried to create a NodeCountsCommand for something that didn't change any count"; this.labelId = labelId; this.delta = delta; }
@Override public void visitNodeCount( int labelId, long count ) { if ( count != 0 ) { // Only add commands for counts that actually change commands.add( new Command.NodeCountsCommand( labelId, count ) ); } }