Ejemplo n.º 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public long tryCheckPoint(TriggerInfo info, System.Func<boolean> timeout) throws java.io.IOException
        public override long TryCheckPoint(TriggerInfo info, System.Func <bool> timeout)
        {
            _ioLimiter.disableLimit();
            try
            {
                Resource lockAttempt = _mutex.tryCheckPoint();
                if (lockAttempt != null)
                {
                    using (Resource @lock = lockAttempt)
                    {
                        return(DoCheckPoint(info));
                    }
                }
                else
                {
                    using (Resource @lock = _mutex.tryCheckPoint(timeout))
                    {
                        if (@lock != null)
                        {
                            _msgLog.info(info.Describe(_lastCheckPointedTx) + " Check pointing was already running, completed now");
                            return(_lastCheckPointedTx);
                        }
                        else
                        {
                            return(-1);
                        }
                    }
                }
            }
            finally
            {
                _ioLimiter.enableLimit();
            }
        }
Ejemplo n.º 2
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;
            }
        }