public void add( RelationshipGroupRecord before, RelationshipGroupRecord after ) { relationshipGroupCommands.add( new Command.RelationshipGroupCommand( before, after ) ); }
@Test public void shouldApplyRelationshipGroupCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); // when final RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 1 ); final RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 1, 2, 3, 4, 5, 6, true ); final Command command = new Command.RelationshipGroupCommand( before, after ); boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipGroupStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( relationshipGroupStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelationshipGroupCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); // when final RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 1 ); final RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 1, 2, 3, 4, 5, 6, true ); final Command command = new Command.RelationshipGroupCommand( before, after ); final boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( relationshipGroupStore, times( 1 ) ).updateRecord( after ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
public void add( RelationshipGroupRecord group ) { Command.RelationshipGroupCommand command = new Command.RelationshipGroupCommand(); command.init( group ); addCommand( command ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipGroupRecord before = readRelationshipGroupRecord( id, channel ); RelationshipGroupRecord after = readRelationshipGroupRecord( id, channel ); return new Command.RelationshipGroupCommand( before, after ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipGroupRecord before = readRelationshipGroupRecord( id, channel ); RelationshipGroupRecord after = readRelationshipGroupRecord( id, channel ); return new Command.RelationshipGroupCommand( before, after ); }
continue; relGroupCommands[i++] = new Command.RelationshipGroupCommand( change.getBefore(), prepared( change, relationshipGroupStore ) );
tracker.visitRelationshipCommand( new RelationshipCommand( new RelationshipRecord( relationship.getId() ), relationship ) ); tracker.visitRelationshipGroupCommand( new RelationshipGroupCommand( new RelationshipGroupRecord( relationshipGroup.getId() ), relationshipGroup ) ); tracker.close();
@Test public void readRelationshipGroupCommandWithFixedReferenceFormat302() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); before.setUseFixedReferences( true ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setUseFixedReferences( true ); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); assertTrue( relationshipGroupCommand.getBefore().isUseFixedReferences() ); assertTrue( relationshipGroupCommand.getAfter().isUseFixedReferences() ); }
@Test public void readRelationshipGroupCommandWithSecondaryUnit() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setRequiresSecondaryUnit( true ); after.setSecondaryUnitId( 17 ); after.setCreated(); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); verifySecondaryUnit( after, relationshipGroupCommand.getAfter() ); }
@Test public void readRelationshipGroupCommandWithFixedReferenceFormat300() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); before.setUseFixedReferences( true ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setUseFixedReferences( true ); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); assertTrue( relationshipGroupCommand.getBefore().isUseFixedReferences() ); assertTrue( relationshipGroupCommand.getAfter().isUseFixedReferences() ); }
@Test public void readRelationshipGroupCommandWithNonRequiredSecondaryUnit() throws IOException { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setRequiresSecondaryUnit( false ); after.setSecondaryUnitId( 17 ); after.setCreated(); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); verifySecondaryUnit( after, relationshipGroupCommand.getAfter() ); }
@Test public void shouldReadRelationshipGroupCommand() throws Throwable { // Given InMemoryClosableChannel channel = new InMemoryClosableChannel(); RelationshipGroupRecord before = new RelationshipGroupRecord( 42, 3 ); RelationshipGroupRecord after = new RelationshipGroupRecord( 42, 3, 4, 5, 6, 7, 8, true ); after.setCreated(); new Command.RelationshipGroupCommand( before, after ).serialize( channel ); // When PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.RelationshipGroupCommand); Command.RelationshipGroupCommand relationshipGroupCommand = (Command.RelationshipGroupCommand) command; // Then assertEquals( before, relationshipGroupCommand.getBefore() ); assertEquals( after, relationshipGroupCommand.getAfter() ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); byte inUseByte = channel.get(); boolean inUse = inUseByte == Record.IN_USE.byteValue(); if ( inUseByte != Record.IN_USE.byteValue() && inUseByte != Record.NOT_IN_USE.byteValue() ) { throw new IOException( "Illegal in use flag: " + inUseByte ); } int type = unsignedShortToInt( channel.getShort() ); RelationshipGroupRecord record = new RelationshipGroupRecord( id, type ); record.setInUse( inUse ); record.setNext( channel.getLong() ); record.setFirstOut( channel.getLong() ); record.setFirstIn( channel.getLong() ); record.setFirstLoop( channel.getLong() ); record.setOwningNode( channel.getLong() ); return new Command.RelationshipGroupCommand( null, record ); }
public static RelationshipGroupCommand createRelationshipGroup( long id, int type ) { RelationshipGroupRecord before = new RelationshipGroupRecord( id ); RelationshipGroupRecord after = new RelationshipGroupRecord( id, type ); after.setInUse( true ); after.setCreated(); return new RelationshipGroupCommand( before, after ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipGroupRecord before = readRelationshipGroupRecord( id, channel ); RelationshipGroupRecord after = readRelationshipGroupRecord( id, channel ); return new Command.RelationshipGroupCommand( before, after ); }
private Command visitRelationshipGroupCommand( ReadableChannel channel ) throws IOException { long id = channel.getLong(); RelationshipGroupRecord before = readRelationshipGroupRecord( id, channel ); RelationshipGroupRecord after = readRelationshipGroupRecord( id, channel ); return new Command.RelationshipGroupCommand( before, after ); }