Search in sources :

Example 26 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem.

@Test
public void shouldApplyUpdateIndexRuleSchemaRuleCommandToTheStoreThrowingIndexProblem() throws IOException, IndexNotFoundKernelException, IndexPopulationFailedKernelException, IndexActivationFailedKernelException {
    // given
    final BatchTransactionApplier applier = newIndexApplier();
    doThrow(new IndexNotFoundKernelException("")).when(indexingService).activateIndex(anyLong());
    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
    try {
        apply(applier, command::handle, transactionToApply);
        fail("should have thrown");
    } catch (Exception e) {
        // then
        assertTrue(e.getCause() instanceof IndexNotFoundKernelException);
    }
}
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) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) IndexPopulationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexPopulationFailedKernelException) IOException(java.io.IOException) IndexActivationFailedKernelException(org.neo4j.kernel.api.exceptions.index.IndexActivationFailedKernelException) Test(org.junit.Test)

Example 27 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore.

@Test
public void shouldApplyDeleteIndexRuleSchemaRuleCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier base = newApplier(false);
    final BatchTransactionApplier indexApplier = newIndexApplier();
    final BatchTransactionApplierFacade applier = new BatchTransactionApplierFacade(base, indexApplier);
    final DynamicRecord record = DynamicRecord.dynamicRecord(21, true);
    record.setInUse(false);
    final Collection<DynamicRecord> recordsAfter = Arrays.asList(record);
    final IndexRule rule = indexRule(0, 1, 2, new SchemaIndexProvider.Descriptor("K", "X.Y"));
    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(indexingService, times(1)).dropIndex(rule);
    verify(cacheAccess, times(1)).removeSchemaRuleFromCache(command.getKey());
}
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) BatchTransactionApplierFacade(org.neo4j.kernel.impl.api.BatchTransactionApplierFacade) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) Test(org.junit.Test)

Example 28 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery.

@Test
public void shouldApplyUpdateUniquenessConstraintRuleSchemaRuleCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    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)).setHighestPossibleIdInUse(record.getId());
    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)

Example 29 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyLabelTokenCommandToTheStoreInRecovery.

@Test
public void shouldApplyLabelTokenCommandToTheStoreInRecovery() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(true);
    final LabelTokenRecord before = new LabelTokenRecord(42);
    final LabelTokenRecord after = new LabelTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command.LabelTokenCommand command = new Command.LabelTokenCommand(before, after);
    final Token token = new Token("token", 21);
    when(labelTokenStore.getToken((int) command.getKey())).thenReturn(token);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(labelTokenStore, times(1)).setHighestPossibleIdInUse(after.getId());
    verify(labelTokenStore, times(1)).updateRecord(after);
    verify(cacheAccess, times(1)).addLabelToken(token);
}
Also used : LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) 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) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) RelationshipTypeToken(org.neo4j.kernel.impl.core.RelationshipTypeToken) Token(org.neo4j.storageengine.api.Token) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) Test(org.junit.Test)

Example 30 with BatchTransactionApplier

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

the class NeoStoreTransactionApplierTest method shouldApplyLabelTokenCommandToTheStore.

// LABEL TOKEN COMMAND
@Test
public void shouldApplyLabelTokenCommandToTheStore() throws Exception {
    // given
    final BatchTransactionApplier applier = newApplier(false);
    final LabelTokenRecord before = new LabelTokenRecord(42);
    final LabelTokenRecord after = new LabelTokenRecord(42);
    after.setInUse(true);
    after.setNameId(323);
    final Command command = new LabelTokenCommand(before, after);
    // when
    boolean result = apply(applier, command::handle, transactionToApply);
    // then
    assertFalse(result);
    verify(labelTokenStore, 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) LabelTokenCommand(org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord) 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