public void update( LabelTokenRecord before, LabelTokenRecord after ) { otherCommands.add( new Command.LabelTokenCommand( before, after ) ); }
@Test public void shouldApplyLabelTokenCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final LabelTokenRecord before = new LabelTokenRecord( 42 ); final LabelTokenRecord after = new LabelTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command.LabelTokenCommand command = new Command.LabelTokenCommand( before, after ); final NamedToken token = new NamedToken( "token", 21 ); when( labelTokenStore.getToken( (int) command.getKey() ) ).thenReturn( token ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( labelTokenStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( labelTokenStore, times( 1 ) ).updateRecord( after ); verify( cacheAccess, times( 1 ) ).addLabelToken( token ); }
public void label( int id, String name, int... dynamicIds ) { LabelTokenRecord before = new LabelTokenRecord( id ); LabelTokenRecord after = withName( new LabelTokenRecord( id ), dynamicIds, name ); otherCommands.add( new Command.LabelTokenCommand( before, after ) ); }
commands.add( new Command.LabelTokenCommand( record.getBefore(), record.forReadingLinkage() ) );
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { // id+in_use(byte)+type_blockId(int)+nr_type_records(int) int id = channel.getInt(); byte inUseFlag = channel.get(); boolean inUse = false; if ( (inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue() ) { inUse = true; } else if ( inUseFlag != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseFlag ); } LabelTokenRecord record = new LabelTokenRecord( id ); record.setInUse( inUse ); record.setNameId( channel.getInt() ); int nrTypeRecords = channel.getInt(); for ( int i = 0; i < nrTypeRecords; i++ ) { DynamicRecord dr = readDynamicRecord( channel ); if ( dr == null ) { return null; } record.addNameRecord( dr ); } return new Command.LabelTokenCommand( null, record ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { // id+in_use(byte)+type_blockId(int)+nr_type_records(int) int id = channel.getInt(); byte inUseFlag = channel.get(); boolean inUse = false; if ( (inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue() ) { inUse = true; } else if ( inUseFlag != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseFlag ); } LabelTokenRecord record = new LabelTokenRecord( id ); record.setInUse( inUse ); record.setNameId( channel.getInt() ); int nrTypeRecords = channel.getInt(); for ( int i = 0; i < nrTypeRecords; i++ ) { DynamicRecord dr = readDynamicRecord( channel ); if ( dr == null ) { return null; } record.addNameRecord( dr ); } return new Command.LabelTokenCommand( null, record ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); LabelTokenRecord before = readLabelTokenRecord( id, channel ); if ( before == null ) { return null; } LabelTokenRecord after = readLabelTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.LabelTokenCommand( before, after ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); LabelTokenRecord before = readLabelTokenRecord( id, channel ); if ( before == null ) { return null; } LabelTokenRecord after = readLabelTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.LabelTokenCommand( before, after ); }
public void label( int id, String name, int... dynamicIds ) { Command.LabelTokenCommand command = new Command.LabelTokenCommand(); command.init( withName( new LabelTokenRecord( id ), dynamicIds, name ) ); addCommand( command ); }
public void update( LabelTokenRecord labelToken ) { Command.LabelTokenCommand command = new Command.LabelTokenCommand(); command.init( labelToken ); addCommand( command ); }
commands.add( new Command.LabelTokenCommand( record.getBefore(), record.forReadingLinkage() ) );
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { // id+in_use(byte)+type_blockId(int)+nr_type_records(int) int id = channel.getInt(); byte inUseFlag = channel.get(); boolean inUse = false; if ( (inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue() ) { inUse = true; } else if ( inUseFlag != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseFlag ); } LabelTokenRecord record = new LabelTokenRecord( id ); record.setInUse( inUse ); record.setNameId( channel.getInt() ); int nrTypeRecords = channel.getInt(); for ( int i = 0; i < nrTypeRecords; i++ ) { DynamicRecord dr = readDynamicRecord( channel ); if ( dr == null ) { return null; } record.addNameRecord( dr ); } return new Command.LabelTokenCommand( null, record ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { // id+in_use(byte)+type_blockId(int)+nr_type_records(int) int id = channel.getInt(); byte inUseFlag = channel.get(); boolean inUse = false; if ( (inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue() ) { inUse = true; } else if ( inUseFlag != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseFlag ); } LabelTokenRecord record = new LabelTokenRecord( id ); record.setInUse( inUse ); record.setNameId( channel.getInt() ); int nrTypeRecords = channel.getInt(); for ( int i = 0; i < nrTypeRecords; i++ ) { DynamicRecord dr = readDynamicRecord( channel ); if ( dr == null ) { return null; } record.addNameRecord( dr ); } return new Command.LabelTokenCommand( null, record ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); LabelTokenRecord before = readLabelTokenRecord( id, channel ); if ( before == null ) { return null; } LabelTokenRecord after = readLabelTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.LabelTokenCommand( before, after ); }
@Test public void shouldApplyLabelTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final LabelTokenRecord before = new LabelTokenRecord( 42 ); final LabelTokenRecord after = new LabelTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new LabelTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( labelTokenStore, times( 1 ) ).updateRecord( after ); }
private Command visitLabelTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); LabelTokenRecord before = readLabelTokenRecord( id, channel ); if ( before == null ) { return null; } LabelTokenRecord after = readLabelTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.LabelTokenCommand( before, after ); }
public static LabelTokenCommand createLabelToken( int id, int nameId ) { LabelTokenRecord before = new LabelTokenRecord( id ); LabelTokenRecord after = new LabelTokenRecord( id ); populateTokenRecord( after, nameId ); return new LabelTokenCommand( before, after ); }