@Override public void setIdTo( PropertyRecord property ) { property.setNodeId( getId() ); }
private static PropertyRecord propertyRecord( PropertyBlock... propertyBlocks ) { PropertyRecord record = new PropertyRecord( 0 ); if ( propertyBlocks != null ) { record.setInUse( true ); for ( PropertyBlock propertyBlock : propertyBlocks ) { record.addPropertyBlock( propertyBlock ); } } record.setNodeId( 0 ); return record; }
@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 ); }
public void create( PropertyRecord property ) { property.setCreated(); PropertyRecord before = new PropertyRecord( property.getId() ); if ( property.isNodeSet() ) { before.setNodeId( property.getNodeId() ); } if ( property.isRelSet() ) { before.setRelId( property.getRelId() ); } update( before, property ); }
if ( primitiveId != -1 && nodeProperty ) record.setNodeId( primitiveId );
if ( primitiveId != -1 && nodeProperty ) record.setNodeId( primitiveId );
if ( primitiveId != -1 && nodeProperty ) record.setNodeId( primitiveId );
if ( primitiveId != -1 && nodeProperty ) record.setNodeId( primitiveId );
@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() ); }
nodePropertyBlocks.setNodeId( nodeId ); Command.PropertyCommand nodePropertyCommand = new Command.PropertyCommand( recordAccess.getIfLoaded( nodePropertyId ).forReadingData(), nodePropertyBlocks );
@Override public void setIdTo( PropertyRecord property ) { property.setNodeId( getId() ); }
@Test public void shouldReportPropertyChangedForWrongNode() throws Exception { // given PropertyRecord oldProperty = inUse( new PropertyRecord( 42 ) ); PropertyRecord newProperty = notInUse( new PropertyRecord( 42 ) ); newProperty.setNodeId( 10 ); add( inUse( new NodeRecord( 10, false, NONE, NONE ) ) ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verify( report ).changedForWrongOwner(); verifyNoMoreInteractions( report ); }
@Test public void shouldReportPropertyNotReferencedFromNode() throws Exception { // given PropertyRecord oldProperty = notInUse( new PropertyRecord( 42 ) ); PropertyRecord newProperty = inUse( new PropertyRecord( 42 ) ); newProperty.setNodeId( add( inUse( new NodeRecord( 1, false, NONE, NONE ) ) ).getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verify( report ).ownerDoesNotReferenceBack(); verifyNoMoreInteractions( report ); }
@Test public void shouldNotReportMissingPropertyForDeletedNodeWithProperty() { // given PropertyRecord oldProperty = add( inUse( new PropertyRecord( 10 ) ) ); NodeRecord oldNode = add( inUse( new NodeRecord( 20, false, 0, 0 ) ) ); oldProperty.setNodeId( oldNode.getId() ); oldNode.setNextProp( oldProperty.getId() ); PropertyRecord newProperty = add( notInUse( new PropertyRecord( 10 ) ) ); NodeRecord newNode = add( notInUse( new NodeRecord( 20, false, 0, 0 ) ) ); newProperty.setNodeId( newNode.getId() ); newNode.setNextProp( newProperty.getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verifyNoMoreInteractions( report ); }
public void create( PropertyRecord property ) { property.setCreated(); PropertyRecord before = new PropertyRecord( property.getLongId() ); if ( property.isNodeSet() ) { before.setNodeId( property.getNodeId() ); } if ( property.isRelSet() ) { before.setRelId( property.getRelId() ); } update( before, property ); }
@Test public void shouldReportNextReplacedButNotUpdated() throws Exception { PropertyRecord oldProperty = inUse( new PropertyRecord( 42 ) ); oldProperty.setNextProp( 1 ); PropertyRecord newProperty = inUse( new PropertyRecord( 42 ) ); newProperty.setNextProp( 2 ); addChange( notInUse( new PropertyRecord( 2 ) ), inUse( new PropertyRecord( 2 ) ) ).setPrevProp( 42 ); newProperty.setNodeId( add( inUse( new NodeRecord( 100, false, NONE, newProperty.getId() ) ) ).getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verify( report ).nextNotUpdated(); verifyNoMoreInteractions( report ); }
@Test public void shouldReportArrayValueUnreferencedButStillInUse() throws Exception { // given PropertyRecord oldProperty = inUse( new PropertyRecord( 42 ) ); PropertyBlock block = propertyBlock( add( inUse( new PropertyKeyTokenRecord( 1 ) ) ), add( array( inUse( new DynamicRecord( 100 ) ) ) ) ); oldProperty.addPropertyBlock( block ); PropertyRecord newProperty = inUse( new PropertyRecord( 42 ) ); newProperty.setNodeId( add( inUse( new NodeRecord( 100, false, NONE, newProperty.getId() ) ) ).getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verify( report ).arrayUnreferencedButNotDeleted( block ); verifyNoMoreInteractions( report ); }
@Test public void shouldReportStringValueUnreferencedButStillInUse() throws Exception { // given PropertyRecord oldProperty = inUse( new PropertyRecord( 42 ) ); PropertyBlock block = propertyBlock( add( inUse( new PropertyKeyTokenRecord( 1 ) ) ), add( string( inUse( new DynamicRecord( 100 ) ) ) ) ); oldProperty.addPropertyBlock( block ); PropertyRecord newProperty = inUse( new PropertyRecord( 42 ) ); newProperty.setNodeId( add( inUse( new NodeRecord( 100, false, NONE, newProperty.getId() ) ) ).getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verify( report ).stringUnreferencedButNotDeleted( block ); verifyNoMoreInteractions( report ); }
@Test public void shouldNotReportAnythingWhenAddingAnInitialNextProperty() throws Exception { // given PropertyRecord oldProperty = inUse( new PropertyRecord( 42 ) ); PropertyRecord newProperty = inUse( new PropertyRecord( 42 ) ); PropertyRecord nextProperty = addChange( notInUse( new PropertyRecord( 1 ) ), inUse( new PropertyRecord( 1 ) ) ); nextProperty.setPrevProp( 42 ); newProperty.setNextProp( nextProperty.getId() ); newProperty.setNodeId( add( inUse( new NodeRecord( 100, false, NONE, newProperty.getId() ) ) ).getId() ); // when ConsistencyReport.PropertyConsistencyReport report = checkChange( oldProperty, newProperty ); // then verifyNoMoreInteractions( report ); }