Пример #1
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()));
        }
Пример #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long commit(final org.neo4j.kernel.impl.api.TransactionToApply tx, final org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are ignored unless the option to convert to C# 7.2 'in' parameters is selected:
        public override long Commit(TransactionToApply tx, CommitEvent commitEvent, TransactionApplicationMode mode)
        {
            TransactionRepresentationReplicatedTransaction transaction = ReplicatedTransaction.from(tx.TransactionRepresentation());
            Future <object> futureTxId;

            try
            {
                futureTxId = _replicator.replicate(transaction, true);
            }
            catch (ReplicationFailureException e)
            {
                throw new TransactionFailureException(ReplicationFailure, e);
            }

            try
            {
                return(( long )futureTxId.get());
            }
            catch (ExecutionException e)
            {
                if (e.InnerException is TransactionFailureException)
                {
                    throw ( TransactionFailureException )e.InnerException;
                }
                // TODO: Panic?
                throw new Exception(e);
            }
            catch (InterruptedException e)
            {
                // TODO Wait for the transaction to possibly finish within a user configurable time, before aborting.
                throw new TransactionFailureException("Interrupted while waiting for txId", e);
            }
        }
Пример #3
0
 public ExplicitIndexTransactionApplier(ExplicitIndexApplierLookup applierLookup, IndexConfigStore indexConfigStore, TransactionApplicationMode mode, IdOrderingQueue transactionOrdering)
 {
     this._applierLookup       = applierLookup;
     this._indexConfigStore    = indexConfigStore;
     this._mode                = mode;
     this._transactionOrdering = transactionOrdering;
 }
Пример #4
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;
            }
        }
Пример #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.recovery.RecoveryApplier getRecoveryApplier(org.neo4j.storageengine.api.TransactionApplicationMode mode) throws Exception
            public override RecoveryApplier getRecoveryApplier(TransactionApplicationMode mode)
            {
                RecoveryApplier actual = base.getRecoveryApplier(mode);

                if (mode == TransactionApplicationMode.REVERSE_RECOVERY)
                {
                    return(actual);
                }

                return(new RecoveryApplierAnonymousInnerClass(this, actual));
            }
 public CountsStoreBatchTransactionApplier(CountsTracker countsTracker, TransactionApplicationMode mode)
 {
     this._countsTracker = countsTracker;
     this._mode          = mode;
 }
Пример #7
0
 public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode)
 {
     Debug.Assert(Transaction == null, "Designed to only allow one transaction");
     Debug.Assert(batch.Next() == null, "Designed to only allow one transaction");
     Transaction = batch.TransactionRepresentation();
     return(++TxId);
 }
Пример #8
0
            public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode)
            {
                int batchSize = Count(batch);

                BatchSizes.AddLast(batchSize);
                return(42);
            }
Пример #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected void applyToStore(TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        protected internal virtual void ApplyToStore(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode)
        {
            try
            {
                using (StoreApplyEvent storeApplyEvent = commitEvent.BeginStoreApply())
                {
                    _storageEngine.apply(batch, mode);
                }
            }
            catch (Exception cause)
            {
                throw new TransactionFailureException(TransactionCommitFailed, cause, "Could not apply the transaction to the store after written to log");
            }
        }
Пример #10
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long commit(TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.internal.kernel.api.exceptions.TransactionFailureException
        public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode)
        {
            long lastTxId = AppendToLog(batch, commitEvent);

            try
            {
                ApplyToStore(batch, commitEvent, mode);
                return(lastTxId);
            }
            finally
            {
                Close(batch);
            }
        }
Пример #11
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long commit(org.neo4j.kernel.impl.api.TransactionToApply batch, org.neo4j.kernel.impl.transaction.tracing.CommitEvent commitEvent, org.neo4j.storageengine.api.TransactionApplicationMode mode) throws org.neo4j.graphdb.TransactionFailureException
            public override long Commit(TransactionToApply batch, CommitEvent commitEvent, TransactionApplicationMode mode)
            {
                TransactionsToApply.Add(batch.TransactionRepresentation());
                return(-1);
            }
Пример #12
0
 public RecoveryApplier getRecoveryApplier(TransactionApplicationMode mode)
 {
     return(mode == TransactionApplicationMode.REVERSE_RECOVERY ? mock(typeof(RecoveryApplier)) : _visitor);
 }
Пример #13
0
 private LockService LockService(TransactionApplicationMode mode)
 {
     return(mode == RECOVERY || mode == REVERSE_RECOVERY ? NO_LOCK_SERVICE : _lockService);
 }
 public CountsStoreTransactionApplier(TransactionApplicationMode mode, CountsAccessor_Updater countsUpdater)
 {
     this._mode          = mode;
     this._countsUpdater = countsUpdater;
 }