Search in sources :

Example 41 with BatchTransactionApplier

use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyPropertyKeyTokenCommandToTheStore.

// PROPERTY KEY TOKEN COMMAND
@Test
public void shouldApplyPropertyKeyTokenCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final PropertyKeyTokenRecord before = new PropertyKeyTokenRecord(42);
    final PropertyKeyTokenRecord after = new PropertyKeyTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command command = new PropertyKeyTokenCommand(before, after);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(propertyKeyTokenStore, times(1)).updateRecord(after);
}
Also used : RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) PropertyKeyTokenRecord(org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) Test(org.junit.Test)

Example 42 with BatchTransactionApplier

use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.

the class NeoStoreTransactionApplierTest method shouldApplyRelPropertyCommandToTheStoreInRecovery.

@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);
}
Also used : PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) PropertyKeyTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 43 with BatchTransactionApplier

use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.

the class TransactionRecordStateTest method shouldDeleteDynamicLabelsForDeletedNodeForRecoveredTransaction.

@Test
public void shouldDeleteDynamicLabelsForDeletedNodeForRecoveredTransaction() throws Throwable {
    // GIVEN a store that has got a node with a dynamic label record
    NeoStores store = neoStoresRule.open();
    BatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(store, mock(CacheAccessBackDoor.class), LockService.NO_LOCK_SERVICE);
    AtomicLong nodeId = new AtomicLong();
    AtomicLong dynamicLabelRecordId = new AtomicLong();
    apply(applier, transaction(nodeWithDynamicLabelRecord(store, nodeId, dynamicLabelRecordId)));
    assertDynamicLabelRecordInUse(store, dynamicLabelRecordId.get(), true);
    // WHEN applying a transaction, which has first round-tripped through a log (written then read)
    TransactionRepresentation transaction = transaction(deleteNode(store, nodeId.get()));
    InMemoryVersionableReadableClosablePositionAwareChannel channel = new InMemoryVersionableReadableClosablePositionAwareChannel();
    writeToChannel(transaction, channel);
    CommittedTransactionRepresentation recoveredTransaction = readFromChannel(channel);
    // and applying that recovered transaction
    apply(applier, recoveredTransaction.getTransactionRepresentation());
    // THEN should have the dynamic label record should be deleted as well
    assertDynamicLabelRecordInUse(store, dynamicLabelRecordId.get(), false);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) NeoStores(org.neo4j.kernel.impl.store.NeoStores) CommittedTransactionRepresentation(org.neo4j.kernel.impl.transaction.CommittedTransactionRepresentation) PhysicalTransactionRepresentation(org.neo4j.kernel.impl.transaction.log.PhysicalTransactionRepresentation) TransactionRepresentation(org.neo4j.kernel.impl.transaction.TransactionRepresentation) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) InMemoryVersionableReadableClosablePositionAwareChannel(org.neo4j.kernel.impl.transaction.log.InMemoryVersionableReadableClosablePositionAwareChannel) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) CacheAccessBackDoor(org.neo4j.kernel.impl.core.CacheAccessBackDoor) Test(org.junit.Test)

Example 44 with BatchTransactionApplier

use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.

the class TransactionRecordStateTest method apply.

private void apply(NeoStores neoStores, TransactionRecordState state) throws Exception {
    BatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(neoStores, mock(CacheAccessBackDoor.class), LockService.NO_LOCK_SERVICE);
    apply(applier, transactionRepresentationOf(state));
}
Also used : NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) CacheAccessBackDoor(org.neo4j.kernel.impl.core.CacheAccessBackDoor)

Example 45 with BatchTransactionApplier

use of org.neo4j.kernel.impl.api.BatchTransactionApplier in project neo4j by neo4j.

the class TransactionRecordStateTest method apply.

private void apply(NeoStores neoStores, TransactionRepresentation transaction) throws Exception {
    BatchTransactionApplier applier = new NeoStoreBatchTransactionApplier(neoStores, mock(CacheAccessBackDoor.class), LockService.NO_LOCK_SERVICE);
    apply(applier, transaction);
}
Also used : NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) CacheAccessBackDoor(org.neo4j.kernel.impl.core.CacheAccessBackDoor)

Aggregations

BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)45 Test (org.junit.Test)41 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)34 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)34 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)34 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)13 NeoStoreBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier)10 CacheAccessBackDoor (org.neo4j.kernel.impl.core.CacheAccessBackDoor)8 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)7 NeoStores (org.neo4j.kernel.impl.store.NeoStores)7 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)7 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)6 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)4 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)4 ArrayList (java.util.ArrayList)3 RelationshipTypeToken (org.neo4j.kernel.impl.core.RelationshipTypeToken)3 RelationshipRecord (org.neo4j.kernel.impl.store.record.RelationshipRecord)3 RelationshipGroupCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipGroupCommand)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 BatchTransactionApplierFacade (org.neo4j.kernel.impl.api.BatchTransactionApplierFacade)2