recordChangeSet.getRelationshipTypeTokenChanges().changes() ) commands.add( new Command.RelationshipTypeTokenCommand( record.getBefore(), record.forReadingLinkage() ) );
@Test public void shouldApplyRelationshipTypeTokenCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( 42 ); final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand( before, after ); final NamedToken token = new NamedToken( "token", 21 ); when( relationshipTypeTokenStore.getToken( (int) command.getKey() ) ).thenReturn( token ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipTypeTokenStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( relationshipTypeTokenStore, times( 1 ) ).updateRecord( after ); verify( cacheAccess, times( 1 ) ).addRelationshipTypeToken( token ); }
@Test public void testVisitRelationshipTypeTokenCommand() throws Exception { Command.RelationshipTypeTokenCommand cmd = mock( Command.RelationshipTypeTokenCommand.class ); when( cmd.handle( any( CommandVisitor.class ) ) ).thenCallRealMethod(); // WHEN boolean result = facade.visitRelationshipTypeTokenCommand( cmd ); // THEN InOrder inOrder = inOrder( txApplier1, txApplier2, txApplier3 ); inOrder.verify( txApplier1 ).visitRelationshipTypeTokenCommand( cmd ); inOrder.verify( txApplier2 ).visitRelationshipTypeTokenCommand( cmd ); inOrder.verify( txApplier3 ).visitRelationshipTypeTokenCommand( cmd ); inOrder.verifyNoMoreInteractions(); assertFalse( result ); }
recordChangeSet.getRelationshipTypeTokenChanges().changes() ) commands.add( new Command.RelationshipTypeTokenCommand( record.getBefore(), record.forReadingLinkage() ) );
private Command visitRelationshipTypeTokenCommand( 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 ); } RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord( 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.RelationshipTypeTokenCommand( null, record ); }
private Command visitRelationshipTypeTokenCommand( 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 ); } RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord( 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.RelationshipTypeTokenCommand( null, record ); }
private void writeRelationshipTypeTokenRecord( WritableChannel channel, RelationshipTypeTokenRecord record ) throws IOException { // id+in_use(byte)+count(int)+key_blockId(int)+nr_key_records(int) byte inUse = record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue(); channel.put( inUse ); channel.putInt( record.getNameId() ); if ( record.isLight() ) { channel.putInt( 0 ); } else { writeDynamicRecords( channel, record.getNameRecords() ); } } }
private Command visitRelationshipTypeTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); RelationshipTypeTokenRecord before = readRelationshipTypeTokenRecord( id, channel ); if ( before == null ) { return null; } RelationshipTypeTokenRecord after = readRelationshipTypeTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.RelationshipTypeTokenCommand( before, after ); }
private Command visitRelationshipTypeTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); RelationshipTypeTokenRecord before = readRelationshipTypeTokenRecord( id, channel ); if ( before == null ) { return null; } RelationshipTypeTokenRecord after = readRelationshipTypeTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.RelationshipTypeTokenCommand( before, after ); }
public void add( RelationshipTypeTokenRecord record ) { Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); command.init( record ); addCommand( command ); }
@Override public boolean visitRelationshipTypeTokenCommand( RelationshipTypeTokenCommand command ) { NamedToken type = relationshipTypeTokenStore.getToken( (int) command.getKey() ); cacheAccess.addRelationshipTypeToken( type ); return false; }
public void relationshipType( int id, String label, int... dynamicIds ) { Command.RelationshipTypeTokenCommand command = new Command.RelationshipTypeTokenCommand(); command.init( withName( new RelationshipTypeTokenRecord( id ), dynamicIds, label ) ); addCommand( command ); }
@Override public void serialize( WritableChannel channel ) throws IOException { channel.put( NeoCommandType.REL_TYPE_COMMAND ); channel.putInt( after.getIntId() ); writeRelationshipTypeTokenRecord( channel, before ); writeRelationshipTypeTokenRecord( channel, after ); }
private Command visitRelationshipTypeTokenCommand( 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 ); } RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord( 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.RelationshipTypeTokenCommand( null, record ); }
private Command visitRelationshipTypeTokenCommand( 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 ); } RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord( 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.RelationshipTypeTokenCommand( null, record ); }
@Test public void shouldReadSomeCommands() throws Exception { // GIVEN InMemoryClosableChannel channel = new InMemoryClosableChannel(); Commands.createNode( 0 ).serialize( channel ); Commands.createNode( 1 ).serialize( channel ); Commands.createRelationshipTypeToken( 0, 0 ).serialize( channel ); Commands.createRelationship( 0, 0, 1, 0 ).serialize( channel ); Commands.createPropertyKeyToken( 0, 0 ).serialize( channel ); Commands.createProperty( 0, PropertyType.SHORT_STRING, 0 ).serialize( channel ); CommandReader reader = new PhysicalLogCommandReaderV3_0(); // THEN assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.NodeCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipTypeTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.RelationshipCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyKeyTokenCommand ); assertTrue( reader.read( channel ) instanceof Command.PropertyCommand ); }
private void writeRelationshipTypeTokenRecord( WritableChannel channel, RelationshipTypeTokenRecord record ) throws IOException { // id+in_use(byte)+count(int)+key_blockId(int)+nr_key_records(int) byte inUse = record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue(); channel.put( inUse ); channel.putInt( record.getNameId() ); if ( record.isLight() ) { channel.putInt( 0 ); } else { writeDynamicRecords( channel, record.getNameRecords() ); } } }
@Test public void shouldApplyRelationshipTypeTokenCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final RelationshipTypeTokenRecord before = new RelationshipTypeTokenRecord( 42 ); final RelationshipTypeTokenRecord after = new RelationshipTypeTokenRecord( 42 ); after.setInUse( true ); after.setNameId( 323 ); final Command command = new RelationshipTypeTokenCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipTypeTokenStore, times( 1 ) ).updateRecord( after ); }
private Command visitRelationshipTypeTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); RelationshipTypeTokenRecord before = readRelationshipTypeTokenRecord( id, channel ); if ( before == null ) { return null; } RelationshipTypeTokenRecord after = readRelationshipTypeTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.RelationshipTypeTokenCommand( before, after ); }
private Command visitRelationshipTypeTokenCommand( ReadableChannel channel ) throws IOException { int id = channel.getInt(); RelationshipTypeTokenRecord before = readRelationshipTypeTokenRecord( id, channel ); if ( before == null ) { return null; } RelationshipTypeTokenRecord after = readRelationshipTypeTokenRecord( id, channel ); if ( after == null ) { return null; } return new Command.RelationshipTypeTokenCommand( before, after ); }