Search in sources :

Example 1 with BatchTransactionApplierFacade

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

the class RecordStorageEngine method applier.

/**
     * Creates a {@link BatchTransactionApplierFacade} that is to be used for all transactions
     * in a batch. Each transaction is handled by a {@link TransactionApplierFacade} which wraps the
     * individual {@link TransactionApplier}s returned by the wrapped {@link BatchTransactionApplier}s.
     *
     * After all transactions have been applied the appliers are closed.
     */
protected BatchTransactionApplierFacade applier(TransactionApplicationMode mode) {
    ArrayList<BatchTransactionApplier> appliers = new ArrayList<>();
    // Graph store application. The order of the decorated store appliers is irrelevant
    appliers.add(new NeoStoreBatchTransactionApplier(neoStores, cacheAccess, lockService));
    if (mode.needsHighIdTracking()) {
        appliers.add(new HighIdBatchTransactionApplier(neoStores));
    }
    if (mode.needsCacheInvalidationOnUpdates()) {
        appliers.add(new CacheInvalidationBatchTransactionApplier(neoStores, cacheAccess));
    }
    // Schema index application
    appliers.add(new IndexBatchTransactionApplier(indexingService, labelScanStoreSync, indexUpdatesSync, neoStores.getNodeStore(), new PropertyLoader(neoStores), indexUpdatesConverter, mode));
    // Legacy index application
    appliers.add(new LegacyBatchIndexApplier(indexConfigStore, legacyIndexApplierLookup, legacyIndexTransactionOrdering, mode));
    // Counts store application
    appliers.add(new CountsStoreBatchTransactionApplier(neoStores.getCounts(), mode));
    // Perform the application
    return new BatchTransactionApplierFacade(appliers.toArray(new BatchTransactionApplier[appliers.size()]));
}
Also used : HighIdBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.HighIdBatchTransactionApplier) ArrayList(java.util.ArrayList) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) BatchTransactionApplierFacade(org.neo4j.kernel.impl.api.BatchTransactionApplierFacade) PropertyLoader(org.neo4j.kernel.impl.transaction.state.PropertyLoader) CountsStoreBatchTransactionApplier(org.neo4j.kernel.impl.api.CountsStoreBatchTransactionApplier) HighIdBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.HighIdBatchTransactionApplier) BatchTransactionApplier(org.neo4j.kernel.impl.api.BatchTransactionApplier) IndexBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier) CacheInvalidationBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.CacheInvalidationBatchTransactionApplier) NeoStoreBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier) IndexBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier) LegacyBatchIndexApplier(org.neo4j.kernel.impl.api.LegacyBatchIndexApplier) CacheInvalidationBatchTransactionApplier(org.neo4j.kernel.impl.transaction.command.CacheInvalidationBatchTransactionApplier) CountsStoreBatchTransactionApplier(org.neo4j.kernel.impl.api.CountsStoreBatchTransactionApplier)

Example 2 with BatchTransactionApplierFacade

use of org.neo4j.kernel.impl.api.BatchTransactionApplierFacade 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)

Aggregations

BatchTransactionApplier (org.neo4j.kernel.impl.api.BatchTransactionApplier)2 BatchTransactionApplierFacade (org.neo4j.kernel.impl.api.BatchTransactionApplierFacade)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)1 CountsStoreBatchTransactionApplier (org.neo4j.kernel.impl.api.CountsStoreBatchTransactionApplier)1 LegacyBatchIndexApplier (org.neo4j.kernel.impl.api.LegacyBatchIndexApplier)1 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)1 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)1 CacheInvalidationBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.CacheInvalidationBatchTransactionApplier)1 LabelTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.LabelTokenCommand)1 PropertyKeyTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.PropertyKeyTokenCommand)1 RelationshipTypeTokenCommand (org.neo4j.kernel.impl.transaction.command.Command.RelationshipTypeTokenCommand)1 HighIdBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.HighIdBatchTransactionApplier)1 IndexBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier)1 NeoStoreBatchTransactionApplier (org.neo4j.kernel.impl.transaction.command.NeoStoreBatchTransactionApplier)1 PropertyLoader (org.neo4j.kernel.impl.transaction.state.PropertyLoader)1