Esempio n. 1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public synchronized void close() throws java.io.IOException
        public override void Close()
        {
            lock (this)
            {
                if (_asPartOfStoreCopy)
                {
                    /* A checkpoint which points to the beginning of all the log files, meaning that
                     * all the streamed transactions will be applied as part of recovery. */
                    long        logVersion         = _logFiles.LowestLogVersion;
                    LogPosition checkPointPosition = new LogPosition(logVersion, LOG_HEADER_SIZE);

                    _log.info("Writing checkpoint as part of store copy: " + checkPointPosition);
                    _writer.checkPoint(checkPointPosition);

                    // * comment copied from old StoreCopyClient *
                    // since we just create new log and put checkpoint into it with offset equals to
                    // LOG_HEADER_SIZE we need to update last transaction offset to be equal to this newly defined max
                    // offset otherwise next checkpoint that use last transaction offset will be created for non
                    // existing offset that is in most of the cases bigger than new log size.
                    // Recovery will treat that as last checkpoint and will not try to recover store till new
                    // last closed transaction offset will not overcome old one. Till that happens it will be
                    // impossible for recovery process to restore the store
                    File neoStore = _databaseLayout.metadataStore();
                    MetaDataStore.setRecord(_pageCache, neoStore, LAST_CLOSED_TRANSACTION_LOG_BYTE_OFFSET, checkPointPosition.ByteOffset);
                }

                _lifespan.close();

                if (_lastTxId != -1)
                {
                    File neoStoreFile = _databaseLayout.metadataStore();
                    MetaDataStore.setRecord(_pageCache, neoStoreFile, LAST_TRANSACTION_ID, _lastTxId);
                }
                _stores.close();
            }
        }