Beispiel #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void apply(org.neo4j.storageengine.api.CommandsToApply batch, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws Exception
        public override void Apply(CommandsToApply batch, TransactionApplicationMode mode)
        {
            // Have these command appliers as separate try-with-resource to have better control over
            // point between closing this and the locks above
            try
            {
                using (IndexActivator indexActivator = new IndexActivator(_indexingService), LockGroup locks = new LockGroup(), BatchTransactionApplier batchApplier = Applier(mode, indexActivator))
                {
                    while (batch != null)
                    {
                        using (TransactionApplier txApplier = batchApplier.StartTx(batch, locks))
                        {
                            batch.Accept(txApplier);
                        }
                        batch = batch.Next();
                    }
                }
            }
            catch (Exception cause)
            {
                TransactionApplyKernelException kernelException = new TransactionApplyKernelException(cause, "Failed to apply transaction: %s", batch);
                _databaseHealth.panic(kernelException);
                throw kernelException;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates a <seealso cref="BatchTransactionApplierFacade"/> that is to be used for all transactions
        /// in a batch. Each transaction is handled by a <seealso cref="TransactionApplierFacade"/> which wraps the
        /// individual <seealso cref="TransactionApplier"/>s returned by the wrapped <seealso cref="BatchTransactionApplier"/>s.
        ///
        /// After all transactions have been applied the appliers are closed.
        /// </summary>
        protected internal virtual BatchTransactionApplierFacade Applier(TransactionApplicationMode mode, IndexActivator indexActivator)
        {
            List <BatchTransactionApplier> appliers = new List <BatchTransactionApplier>();

            // Graph store application. The order of the decorated store appliers is irrelevant
            appliers.Add(new NeoStoreBatchTransactionApplier(mode.version(), _neoStores, _cacheAccess, LockService(mode)));
            if (mode.needsHighIdTracking())
            {
                appliers.Add(new HighIdBatchTransactionApplier(_neoStores));
            }
            if (mode.needsCacheInvalidationOnUpdates())
            {
                appliers.Add(new CacheInvalidationBatchTransactionApplier(_neoStores, _cacheAccess));
            }
            if (mode.needsAuxiliaryStores())
            {
                // Counts store application
                appliers.Add(new CountsStoreBatchTransactionApplier(_neoStores.Counts, mode));

                // Schema index application
                appliers.Add(new IndexBatchTransactionApplier(_indexingService, _labelScanStoreSync, _indexUpdatesSync, _neoStores.NodeStore, _neoStores.RelationshipStore, _neoStores.PropertyStore, indexActivator));

                // Explicit index application
                appliers.Add(new ExplicitBatchIndexApplier(_indexConfigStore, _explicitIndexApplierLookup, _explicitIndexTransactionOrdering, mode));
            }

            // Perform the application
            return(new BatchTransactionApplierFacade(appliers.ToArray()));
        }