public void add( PropertyRecord before, PropertyRecord property ) { otherCommands.add( new Command.PropertyCommand( before, property ) ); }
@Test public void shouldApplyNodePropertyCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setNodeId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( lockService, times( 1 ) ).acquireNodeLock( 42, LockService.LockType.WRITE_LOCK ); verify( propertyStore, times( 1 ) ).setHighestPossibleIdInUse( after.getId() ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyNodePropertyCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setNodeId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( lockService, times( 1 ) ).acquireNodeLock( 42, LockService.LockType.WRITE_LOCK ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
recordChangeSet.getPropertyRecords().changes() ) propCommands[i++] = new Command.PropertyCommand( change.getBefore(), prepared( change, propertyStore ) );
nodePropertyBlocks.setNodeId( nodeId ); Command.PropertyCommand nodePropertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( nodePropertyId ).forReadingData(), nodePropertyBlocks ); relationshipPropertyBlocks.setRelId( relId ); Command.PropertyCommand relationshipPropertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), relationshipPropertyBlocks );
PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); Command.PropertyCommand propertyCommand2 = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId2 ).forReadingData(), propertyBlocks2 );
@Test public void shouldContainFedRelationshipUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); long relId = 0; RelationshipRecord inUse = getRelationship( relId, true, ENTITY_TOKEN ); Value propertyValue = Values.of( "hej" ); long propertyId = createRelationshipProperty( inUse, propertyValue, 1 ); RelationshipRecord notInUse = getRelationship( relId, false, ENTITY_TOKEN ); relationshipStore.updateRecord( inUse ); Command.RelationshipCommand relationshipCommand = new Command.RelationshipCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setRelId( relId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, RELATIONSHIP, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( relId, relationshipCommand ) ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( relId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
@Test public void shouldContainFedNodeUpdate() throws Exception { OnlineIndexUpdates onlineIndexUpdates = new OnlineIndexUpdates( nodeStore, relationshipStore, indexingService, propertyPhysicalToLogicalConverter ); int nodeId = 0; NodeRecord inUse = getNode( nodeId, true ); Value propertyValue = Values.of( "hej" ); long propertyId = createNodeProperty( inUse, propertyValue, 1 ); NodeRecord notInUse = getNode( nodeId, false ); nodeStore.updateRecord( inUse ); Command.NodeCommand nodeCommand = new Command.NodeCommand( inUse, notInUse ); PropertyRecord propertyBlocks = new PropertyRecord( propertyId ); propertyBlocks.setNodeId( nodeId ); Command.PropertyCommand propertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( propertyId ).forReadingData(), propertyBlocks ); StoreIndexDescriptor indexDescriptor = forSchema( multiToken( ENTITY_TOKENS, NODE, 1, 4, 6 ), EMPTY.getProviderDescriptor() ).withId( 0 ); indexingService.createIndexes( indexDescriptor ); indexingService.getIndexProxy( indexDescriptor.schema() ).awaitStoreScanCompleted(); onlineIndexUpdates.feed( LongObjectMaps.immutable.of( nodeId, singletonList( propertyCommand ) ), LongObjectMaps.immutable.empty(), LongObjectMaps.immutable.of( nodeId, nodeCommand ), LongObjectMaps.immutable.empty() ); assertTrue( onlineIndexUpdates.hasUpdates() ); Iterator<IndexEntryUpdate<SchemaDescriptor>> iterator = onlineIndexUpdates.iterator(); assertEquals( iterator.next(), IndexEntryUpdate.remove( nodeId, indexDescriptor, propertyValue, null, null ) ); assertFalse( iterator.hasNext() ); }
@Test public void readPropertyCommandWithFixedReferenceFormat302() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0_2 reader = new PhysicalLogCommandReaderV3_0_2(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
@Test public void readPropertyCommandWithFixedReferenceFormat300() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); before.setUseFixedReferences( true ); after.setUseFixedReferences( true ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); assertTrue( neoStoreCommand.getBefore().isUseFixedReferences() ); assertTrue( neoStoreCommand.getAfter().isUseFixedReferences() ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
private void addCorruptedCommandsToLastLogFile() throws IOException { PositiveLogFilesBasedLogVersionRepository versionRepository = new PositiveLogFilesBasedLogVersionRepository( logFiles ); LogFiles internalLogFiles = LogFilesBuilder.builder( directory.databaseLayout(), fileSystemRule ) .withLogVersionRepository( versionRepository ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); try ( Lifespan lifespan = new Lifespan( internalLogFiles ) ) { LogFile transactionLogFile = internalLogFiles.getLogFile(); FlushablePositionAwareChannel channel = transactionLogFile.getWriter(); TransactionLogWriter writer = new TransactionLogWriter( new CorruptedLogEntryWriter( channel ) ); Collection<StorageCommand> commands = new ArrayList<>(); commands.add( new Command.PropertyCommand( new PropertyRecord( 1 ), new PropertyRecord( 2 ) ) ); commands.add( new Command.NodeCommand( new NodeRecord( 2 ), new NodeRecord( 3 ) ) ); PhysicalTransactionRepresentation transaction = new PhysicalTransactionRepresentation( commands ); writer.append( transaction, 1000 ); } }
@Test public void readPropertyCommandWithNonRequiredSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); after.setRequiresSecondaryUnit( false ); after.setSecondaryUnitId( 78 ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); verifySecondaryUnit( after, neoStoreCommand.getAfter() ); }
@Test public void readPropertyCommandWithSecondaryUnit() throws IOException { InMemoryClosableChannel channel = new InMemoryClosableChannel(); PropertyRecord before = new PropertyRecord( 1 ); PropertyRecord after = new PropertyRecord( 2 ); after.setRequiresSecondaryUnit( true ); after.setSecondaryUnitId( 78 ); new Command.PropertyCommand( before, after ).serialize( channel ); PhysicalLogCommandReaderV3_0 reader = new PhysicalLogCommandReaderV3_0(); Command command = reader.read( channel ); assertTrue( command instanceof Command.PropertyCommand); Command.PropertyCommand neoStoreCommand = (Command.PropertyCommand) command; // Then assertEquals( before.getNextProp(), neoStoreCommand.getBefore().getNextProp() ); assertEquals( after.getNextProp(), neoStoreCommand.getAfter().getNextProp() ); verifySecondaryUnit( after, neoStoreCommand.getAfter() ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
private Command visitPropertyCommand( ReadableChannel channel ) throws IOException { // ID long id = channel.getLong(); // 8 // BEFORE PropertyRecord before = readPropertyRecord( id, channel ); if ( before == null ) { return null; } // AFTER PropertyRecord after = readPropertyRecord( id, channel ); if ( after == null ) { return null; } return new Command.PropertyCommand( before, after ); }
public static PropertyCommand createProperty( long id, PropertyType type, int key, long... valueRecordIds ) { PropertyRecord record = new PropertyRecord( id ); record.setInUse( true ); record.setCreated(); PropertyBlock block = new PropertyBlock(); if ( valueRecordIds.length == 0 ) { PropertyStore.encodeValue( block, key, Values.of( 123 ), null, null, true ); } else { PropertyStore.setSingleBlockValue( block, key, type, valueRecordIds[0] ); block.setValueRecords( dynamicRecords( valueRecordIds ) ); } record.addPropertyBlock( block ); return new PropertyCommand( new PropertyRecord( id ), record ); }
@Test public void shouldApplyRelPropertyCommandToTheStoreInRecovery() throws Exception { // given final BatchTransactionApplier applier = newApplier( true ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setRelId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyStore, times( 1 ) ).setHighestPossibleIdInUse( 12 ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }
@Test public void shouldApplyRelPropertyCommandToTheStore() throws Exception { // given final BatchTransactionApplier applier = newApplier( false ); final PropertyRecord before = new PropertyRecord( 11 ); final PropertyRecord after = new PropertyRecord( 12 ); after.setRelId( 42 ); final Command command = new Command.PropertyCommand( before, after ); // when boolean result = apply( applier, command::handle, transactionToApply ); // then assertFalse( result ); verify( propertyStore, times( 1 ) ).updateRecord( after ); }