Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private long doCheckPoint(TriggerInfo triggerInfo) throws java.io.IOException
        private long DoCheckPoint(TriggerInfo triggerInfo)
        {
            try
            {
                using (LogCheckPointEvent @event = _tracer.beginCheckPoint())
                {
                    long[]      lastClosedTransaction   = _transactionIdStore.LastClosedTransaction;
                    long        lastClosedTransactionId = lastClosedTransaction[0];
                    LogPosition logPosition             = new LogPosition(lastClosedTransaction[1], lastClosedTransaction[2]);
                    string      prefix = triggerInfo.Describe(lastClosedTransactionId);

                    /*
                     * Check kernel health before going into waiting for transactions to be closed, to avoid
                     * getting into a scenario where we would await a condition that would potentially never
                     * happen.
                     */
                    _databaseHealth.assertHealthy(typeof(IOException));

                    /*
                     * First we flush the store. If we fail now or during the flush, on recovery we'll find the
                     * earlier check point and replay from there all the log entries. Everything will be ok.
                     */
                    _msgLog.info(prefix + " checkpoint started...");
                    long startTime = currentTimeMillis();
                    _storageEngine.flushAndForce(_ioLimiter);

                    /*
                     * Check kernel health before going to write the next check point.  In case of a panic this check point
                     * will be aborted, which is the safest alternative so that the next recovery will have a chance to
                     * repair the damages.
                     */
                    _databaseHealth.assertHealthy(typeof(IOException));
                    _appender.checkPoint(logPosition, @event);
                    _threshold.checkPointHappened(lastClosedTransactionId);
                    _msgLog.info(prefix + " checkpoint completed in " + duration(currentTimeMillis() - startTime));

                    /*
                     * Prune up to the version pointed from the latest check point,
                     * since it might be an earlier version than the current log version.
                     */
                    _logPruning.pruneLogs(logPosition.LogVersion);
                    _lastCheckPointedTx = lastClosedTransactionId;
                    return(lastClosedTransactionId);
                }
            }
            catch (Exception t)
            {
                // Why only log failure here? It's because check point can potentially be made from various
                // points of execution e.g. background thread triggering check point if needed and during
                // shutdown where it's better to have more control over failure handling.
                _msgLog.error("Checkpoint failed", t);
                throw t;
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void checkPoint(LogPosition logPosition, org.neo4j.kernel.impl.transaction.tracing.LogCheckPointEvent logCheckPointEvent) throws java.io.IOException
        public override void CheckPoint(LogPosition logPosition, LogCheckPointEvent logCheckPointEvent)
        {
            // Synchronized with logFile to get absolute control over concurrent rotations happening
            lock ( _logFile )
            {
                try
                {
                    _transactionLogWriter.checkPoint(logPosition);
                }
                catch (Exception cause)
                {
                    _databaseHealth.panic(cause);
                    throw cause;
                }
            }
            ForceAfterAppend(logCheckPointEvent);
        }