예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void init() throws Throwable
        public override void Init()
        {
            RecoveryStartInformation recoveryStartInformation = _recoveryService.RecoveryStartInformation;

            if (!recoveryStartInformation.RecoveryRequired)
            {
                // If there is nothing to recovery, then the schema is initialised immediately.
                _schemaLife.init();
                return;
            }

            LogPosition recoveryPosition = recoveryStartInformation.RecoveryPosition;

            _monitor.recoveryRequired(recoveryPosition);
            _recoveryService.startRecovery();

            LogPosition recoveryToPosition = recoveryPosition;
            CommittedTransactionRepresentation lastTransaction         = null;
            CommittedTransactionRepresentation lastReversedTransaction = null;

            try
            {
                long lowestRecoveredTxId = Org.Neo4j.Kernel.impl.transaction.log.TransactionIdStore_Fields.BASE_TX_ID;
                using (TransactionCursor transactionsToRecover = _recoveryService.getTransactionsInReverseOrder(recoveryPosition), RecoveryApplier recoveryVisitor = _recoveryService.getRecoveryApplier(REVERSE_RECOVERY))
                {
                    while (transactionsToRecover.next())
                    {
                        CommittedTransactionRepresentation transaction = transactionsToRecover.get();
                        if (lastReversedTransaction == null)
                        {
                            lastReversedTransaction = transaction;
                            InitProgressReporter(recoveryStartInformation, lastReversedTransaction);
                        }
                        recoveryVisitor.visit(transaction);
                        lowestRecoveredTxId = transaction.CommitEntry.TxId;
                        ReportProgress();
                    }
                }

                _monitor.reverseStoreRecoveryCompleted(lowestRecoveredTxId);

                // We cannot initialise the schema (tokens, schema cache, indexing service, etc.) until we have returned the store to a consistent state.
                // We need to be able to read the store before we can even figure out what indexes, tokens, etc. we have. Hence we defer the initialisation
                // of the schema life until after we've done the reverse recovery.
                _schemaLife.init();

                using (TransactionCursor transactionsToRecover = _recoveryService.getTransactions(recoveryPosition), RecoveryApplier recoveryVisitor = _recoveryService.getRecoveryApplier(RECOVERY))
                {
                    while (transactionsToRecover.next())
                    {
                        lastTransaction = transactionsToRecover.get();
                        long txId = lastTransaction.CommitEntry.TxId;
                        recoveryVisitor.visit(lastTransaction);
                        _monitor.transactionRecovered(txId);
                        _numberOfRecoveredTransactions++;
                        recoveryToPosition = transactionsToRecover.Position();
                        ReportProgress();
                    }
                    recoveryToPosition = transactionsToRecover.Position();
                }
            }
            catch (Exception e) when(e is Exception || e is ClosedByInterruptException)
            {
                // We do not want to truncate logs based on these exceptions. Since users can influence them with config changes
                // the users are able to workaround this if truncations is really needed.
                throw e;
            }
            catch (Exception t)
            {
                if (_failOnCorruptedLogFiles)
                {
                    ThrowUnableToCleanRecover(t);
                }
                if (lastTransaction != null)
                {
                    LogEntryCommit commitEntry = lastTransaction.CommitEntry;
                    _monitor.failToRecoverTransactionsAfterCommit(t, commitEntry, recoveryToPosition);
                }
                else
                {
                    _monitor.failToRecoverTransactionsAfterPosition(t, recoveryPosition);
                    recoveryToPosition = recoveryPosition;
                }
            }
            _progressReporter.completed();
            _logsTruncator.truncate(recoveryToPosition);

            _recoveryService.transactionsRecovered(lastTransaction, recoveryToPosition);
            _monitor.recoveryCompleted(_numberOfRecoveredTransactions);
        }
예제 #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void doNotPruneEmptyLogs() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DoNotPruneEmptyLogs()
        {
            _logPruner.truncate(LogPosition.start(0));
            assertTrue(FileUtils.isEmptyDirectory(_databaseDirectory));
        }