Search in sources :

Example 11 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipTypeTokenCommandToTheStore.

// RELATIONSHIP TYPE TOKEN COMMAND
@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);
}
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) RelationshipTypeTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 12 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyNodePropertyCommandToTheStore.

// PROPERTY COMMAND
@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);
}
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 13 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache.

@Test
public void shouldApplyRelationshipCommandToTheStoreAndInvalidateTheCache() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final RelationshipRecord before = new RelationshipRecord(12);
    final RelationshipRecord record = new RelationshipRecord(12, 3, 4, 5);
    record.setInUse(false);
    final Command command = new Command.RelationshipCommand(before, record);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(relationshipStore, times(1)).updateRecord(record);
}
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) RelationshipRecord(org.neo4j.kernel.impl.store.record.RelationshipRecord) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 14 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreInRecovery.

@Test
public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplierFacade(newIndexApplier(), newApplier(true));
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final IndexRule rule = constraintIndexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"), 42L);
    final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(schemaStore, times(1)).setHighestPossibleIdInUse(record.getId());
    verify(schemaStore, times(1)).updateRecord(record);
    verify(indexingService, times(1)).activateIndex(rule.getId());
    verify(cacheAccess, times(1)).addSchemaRule(rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) 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 15 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStore.

@Test
public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final ConstraintRule rule = uniquenessConstraintRule(0L, 1, 2, 3L);
    final Command.SchemaRuleCommand command = new Command.SchemaRuleCommand(Collections.<DynamicRecord>emptyList(), recordsAfter, rule);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(schemaStore, times(1)).updateRecord(record);
    verify(metaDataStore, times(1)).setLatestConstraintIntroducingTx(transactionId);
    verify(cacheAccess, times(1)).addSchemaRule(rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ConstraintRule(org.neo4j.kernel.impl.store.record.ConstraintRule) 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)

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