Exemple #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void accept(LogFile_LogFileVisitor visitor, org.neo4j.kernel.impl.transaction.log.LogPosition startingFromPosition) throws java.io.IOException
        public override void Accept(LogFile_LogFileVisitor visitor, LogPosition startingFromPosition)
        {
            using (ReadableLogChannel reader = GetReader(startingFromPosition))
            {
                visitor.Visit(reader);
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void removeLastCheckpointRecordFromLastLogFile() throws java.io.IOException
        private void RemoveLastCheckpointRecordFromLastLogFile()
        {
            LogPosition checkpointPosition = null;

            LogFile transactionLogFile = _logFiles.LogFile;
            VersionAwareLogEntryReader <ReadableLogChannel> entryReader = new VersionAwareLogEntryReader <ReadableLogChannel>();
            LogPosition startPosition = LogPosition.start(_logFiles.HighestLogVersion);

            using (ReadableLogChannel reader = transactionLogFile.GetReader(startPosition))
            {
                LogEntry logEntry;
                do
                {
                    logEntry = entryReader.ReadLogEntry(reader);
                    if (logEntry is CheckPoint)
                    {
                        checkpointPosition = (( CheckPoint )logEntry).LogPosition;
                    }
                } while (logEntry != null);
            }
            if (checkpointPosition != null)
            {
                using (StoreChannel storeChannel = _fileSystemRule.open(_logFiles.HighestLogFile, OpenMode.READ_WRITE))
                {
                    storeChannel.Truncate(checkpointPosition.ByteOffset);
                }
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> log(int... transactionCounts) throws java.io.IOException
        private ThrowingFunction <LogPosition, TransactionCursor, IOException> Log(params int[] transactionCounts)
        {
            long baseOffset = LogPosition.start(0).ByteOffset;

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") org.neo4j.function.ThrowingFunction<org.neo4j.kernel.impl.transaction.log.LogPosition,org.neo4j.kernel.impl.transaction.log.TransactionCursor,java.io.IOException> result = mock(org.neo4j.function.ThrowingFunction.class);
            ThrowingFunction <LogPosition, TransactionCursor, IOException> result = mock(typeof(ThrowingFunction));
            AtomicLong txId = new AtomicLong(0);

            CommittedTransactionRepresentation[][] logs = new CommittedTransactionRepresentation[transactionCounts.Length][];
            for (int logVersion = 0; logVersion < transactionCounts.Length; logVersion++)
            {
                logs[logVersion] = Transactions(transactionCounts[logVersion], txId);
            }

            when(result.Apply(any(typeof(LogPosition)))).thenAnswer(invocation =>
            {
                LogPosition position = invocation.getArgument(0);
                if (position == null)
                {
                    // A mockito issue when calling the "when" methods, I believe
                    return(null);
                }

                // For simplicity the offset means, in this test, the array offset
                CommittedTransactionRepresentation[] transactions = logs[toIntExact(position.LogVersion)];
                CommittedTransactionRepresentation[] subset       = copyOfRange(transactions, toIntExact(position.ByteOffset - baseOffset), transactions.Length);
                ArrayUtil.reverse(subset);
                return(given(subset));
            });
            return(result);
        }
Exemple #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public org.neo4j.kernel.impl.transaction.log.ReadableLogChannel getReader(org.neo4j.kernel.impl.transaction.log.LogPosition position, org.neo4j.kernel.impl.transaction.log.LogVersionBridge logVersionBridge) throws java.io.IOException
        public override ReadableLogChannel GetReader(LogPosition position, LogVersionBridge logVersionBridge)
        {
            PhysicalLogVersionedStoreChannel logChannel = _logFiles.openForVersion(position.LogVersion);

            logChannel.Position(position.ByteOffset);
            return(new ReadAheadLogChannel(logChannel, logVersionBridge));
        }
Exemple #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void pruneAndArchiveLastLog() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PruneAndArchiveLastLog()
        {
            Life.start();
            GenerateTransactionLogFiles(_logFiles);

            long        highestLogVersion   = _logFiles.HighestLogVersion;
            File        highestLogFile      = _logFiles.HighestLogFile;
            long        fileSizeBeforePrune = highestLogFile.length();
            int         bytesToPrune        = 5;
            long        byteOffset          = fileSizeBeforePrune - bytesToPrune;
            LogPosition prunePosition       = new LogPosition(highestLogVersion, byteOffset);

            _logPruner.truncate(prunePosition);

            assertEquals(TOTAL_NUMBER_OF_LOG_FILES, _logFiles.logFiles().Length);
            assertEquals(byteOffset, highestLogFile.length());

            File corruptedLogsDirectory = new File(_databaseDirectory, CorruptedLogsTruncator.CorruptedTxLogsBaseName);

            assertTrue(corruptedLogsDirectory.exists());
            File[] files = corruptedLogsDirectory.listFiles();
            assertEquals(1, Files.Length);

            File corruptedLogsArchive = files[0];

            CheckArchiveName(highestLogVersion, byteOffset, corruptedLogsArchive);
            using (ZipFile zipFile = new ZipFile(corruptedLogsArchive))
            {
                assertEquals(1, zipFile.size());
                CheckEntryNameAndSize(zipFile, highestLogFile.Name, bytesToPrune);
            }
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void accept(LogHeaderVisitor visitor) throws java.io.IOException
        public override void Accept(LogHeaderVisitor visitor)
        {
            // Start from the where we're currently at and go backwards in time (versions)
            long logVersion        = HighestLogVersion;
            long highTransactionId = _logFilesContext.LastCommittedTransactionId;

            while (VersionExists(logVersion))
            {
                long?previousLogLastTxId = _logHeaderCache.getLogHeader(logVersion);
                if (previousLogLastTxId == null)
                {
                    LogHeader header = readLogHeader(_fileSystem, GetLogFileForVersion(logVersion), false);
                    if (header != null)
                    {
                        Debug.Assert(logVersion == header.LogVersion);
                        _logHeaderCache.putHeader(header.LogVersion, header.LastCommittedTxId);
                        previousLogLastTxId = header.LastCommittedTxId;
                    }
                }

                if (previousLogLastTxId != null)
                {
                    long        lowTransactionId = previousLogLastTxId + 1;
                    LogPosition position         = LogPosition.start(logVersion);
                    if (!visitor.Visit(position, lowTransactionId, highTransactionId))
                    {
                        break;
                    }
                    highTransactionId = previousLogLastTxId.Value;
                }
                logVersion--;
            }
        }
Exemple #7
0
        /// <summary>
        /// Channels must be closed when no longer used, so that they are released back to the pool of readers.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: org.neo4j.cursor.IOCursor<org.neo4j.causalclustering.core.consensus.log.EntryRecord> getCursor(long logIndex) throws java.io.IOException, DisposedException
        internal virtual IOCursor <EntryRecord> GetCursor(long logIndex)
        {
            Debug.Assert(logIndex > _header.prevIndex());

            if (!_refCount.increase())
            {
                throw new DisposedException();
            }

            /* This is the relative index within the file, starting from zero. */
            long offsetIndex = logIndex - (_header.prevIndex() + 1);

            LogPosition position = _positionCache.lookup(offsetIndex);
            Reader      reader   = _readerPool.acquire(_version, position.ByteOffset);

            try
            {
                long currentIndex = position.LogIndex;
                return(new EntryRecordCursor(reader, _contentMarshal, currentIndex, offsetIndex, this));
            }
            catch (EndOfStreamException)
            {
                _readerPool.release(reader);
                _refCount.decrease();
                return(IOCursor.Empty);
            }
            catch (IOException e)
            {
                reader.Dispose();
                _refCount.decrease();
                throw e;
            }
        }
Exemple #8
0
 public override bool HandleInvalidEntry(Exception e, LogPosition position)
 {
     this.E        = e;
     this.Position = position;
     InvalidEntryCalls++;
     return(true);
 }
Exemple #9
0
        /// <summary>
        /// Find the log position to start recovery from
        /// </summary>
        /// <returns> <seealso cref="LogPosition.UNSPECIFIED"/> if there is no need to recover otherwise the <seealso cref="LogPosition"/> to
        /// start recovery from </returns>
        /// <exception cref="IOException"> if log files cannot be read </exception>
        public override RecoveryStartInformation Get()
        {
            LogTailScanner.LogTailInformation logTailInformation = _logTailScanner.TailInformation;
            CheckPoint lastCheckPoint          = logTailInformation.LastCheckPoint;
            long       txIdAfterLastCheckPoint = logTailInformation.FirstTxIdAfterLastCheckPoint;

            if (!logTailInformation.CommitsAfterLastCheckpoint())
            {
                _monitor.noCommitsAfterLastCheckPoint(lastCheckPoint != null ? lastCheckPoint.LogPosition : null);
                return(CreateRecoveryInformation(LogPosition.UNSPECIFIED, txIdAfterLastCheckPoint));
            }

            if (lastCheckPoint != null)
            {
                _monitor.commitsAfterLastCheckPoint(lastCheckPoint.LogPosition, txIdAfterLastCheckPoint);
                return(CreateRecoveryInformation(lastCheckPoint.LogPosition, txIdAfterLastCheckPoint));
            }
            else
            {
                if (logTailInformation.OldestLogVersionFound != INITIAL_LOG_VERSION)
                {
                    long fromLogVersion = Math.Max(INITIAL_LOG_VERSION, logTailInformation.OldestLogVersionFound);
                    throw new UnderlyingStorageException("No check point found in any log file from version " + fromLogVersion + " to " + logTailInformation.CurrentLogVersion);
                }
                _monitor.noCheckPointFound();
                return(CreateRecoveryInformation(LogPosition.start(0), txIdAfterLastCheckPoint));
            }
        }
Exemple #10
0
 public void checkpoint(CheckPoint checkpoint, LogPosition checkpointEntryPosition)
 {
     if (_filter == null || _filter(new LogEntry[] { checkpoint }))
     {
         @out.println(_serializer(checkpoint));
     }
 }
Exemple #11
0
        public IHttpActionResult PutLogPosition(int id, LogPosition logPosition)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != logPosition.id)
            {
                return(BadRequest());
            }

            db.Entry(logPosition).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LogPositionExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #12
0
        public async Task PostLogPosition(LogPosition position)
        {
            try
            {
                var request = JsonConvert.SerializeObject(position);
                var content = new StringContent(request, Encoding.UTF8, "application/json");
                var client  = new HttpClient();
                client.BaseAddress = new Uri(URL_ws);
                var url      = "simed/api/LogPositions";
                var response = await client.PostAsync(url, content);

                if (!response.IsSuccessStatusCode)
                {
                    return;
                }
                var result = await response.Content.ReadAsStringAsync();

                return;
                //  var log = JsonConvert.DeserializeObject<LogPosition>(result);
            }
            catch (Exception ex)
            {
                return;
            }
        }
Exemple #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldThrowWhenCachingATxWithNegativeOffsetPosition()
        public virtual void ShouldThrowWhenCachingATxWithNegativeOffsetPosition()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache cache = new org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache();
            TransactionMetadataCache cache = new TransactionMetadataCache();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition position = new org.neo4j.kernel.impl.transaction.log.LogPosition(3, -1);
            LogPosition position = new LogPosition(3, -1);
            const int   txId     = 42;
            const int   masterId = 0;
            const int   authorId = 1;
            const int   checksum = 2;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long timestamp = System.currentTimeMillis();
            long timestamp = DateTimeHelper.CurrentUnixTimeMillis();

            // when
            try
            {
                cache.CacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp);
                fail();
            }
            catch (Exception ex)
            {
                assertEquals("StartEntry.position is " + position, ex.Message);
            }
        }
Exemple #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnTheTxValueTIfInTheCached()
        public virtual void ShouldReturnTheTxValueTIfInTheCached()
        {
            // given
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache cache = new org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache();
            TransactionMetadataCache cache = new TransactionMetadataCache();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition position = new org.neo4j.kernel.impl.transaction.log.LogPosition(3, 4);
            LogPosition position = new LogPosition(3, 4);
            const int   txId     = 42;
            const int   masterId = 0;
            const int   authorId = 1;
            const int   checksum = 2;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final long timestamp = System.currentTimeMillis();
            long timestamp = DateTimeHelper.CurrentUnixTimeMillis();

            // when
            cache.CacheTransactionMetadata(txId, position, masterId, authorId, checksum, timestamp);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.TransactionMetadataCache.TransactionMetadata metadata = cache.getTransactionMetadata(txId);
            TransactionMetadataCache.TransactionMetadata metadata = cache.GetTransactionMetadata(txId);

            // then
            assertEquals(new TransactionMetadataCache.TransactionMetadata(masterId, authorId, position, checksum, timestamp), metadata);
        }
Exemple #15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReadACheckPointLogEntry() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldReadACheckPointLogEntry()
        {
            // given
            LogEntryVersion version = LogEntryVersion.CURRENT;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.LogPosition logPosition = new org.neo4j.kernel.impl.transaction.log.LogPosition(42, 43);
            LogPosition logPosition = new LogPosition(42, 43);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final CheckPoint checkPoint = new CheckPoint(version, logPosition);
            CheckPoint checkPoint = new CheckPoint(version, logPosition);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel channel = new org.neo4j.kernel.impl.transaction.log.InMemoryClosableChannel();
            InMemoryClosableChannel channel = new InMemoryClosableChannel();

            channel.Put(version.byteCode());
            channel.Put(LogEntryByteCodes.CheckPoint);
            channel.PutLong(logPosition.LogVersion);
            channel.PutLong(logPosition.ByteOffset);

            // when
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LogEntry logEntry = logEntryReader.readLogEntry(channel);
            LogEntry logEntry = _logEntryReader.readLogEntry(channel);

            // then
            assertEquals(checkPoint, logEntry);
        }
Exemple #16
0
            public override void Checkpoint(CheckPoint checkpoint, LogPosition checkpointEntryPosition)
            {
                Checkpoints++;
                long?expected = ExpectedCheckpointsAt.dequeue();

                assertNotNull("Unexpected checkpoint", expected);
                assertEquals(expected.Value, NextExpectedTxId - 1);
            }
Exemple #17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReturnSaneDefaultPosition()
        public virtual void ShouldReturnSaneDefaultPosition()
        {
            // when
            LogPosition position = _cache.lookup(5);

            // then
            assertEquals(_beginning, position);
        }
Exemple #18
0
 /// <summary>
 /// Saves a known position in the cache.
 /// </summary>
 /// <param name="position"> The position which should interpreted as (offsetIndex, byteOffset). </param>
 public virtual void Put(LogPosition position)
 {
     lock (this)
     {
         _cache[_pos] = position;
         _pos         = (_pos + 1) % CACHE_SIZE;
     }
 }
Exemple #19
0
 public static void Welcome(int clientId, string message)
 {
     LogPosition.Log("Package sent");
     using Packet packet = new Packet((int)PacketId.Welcome);
     packet.Write(message);
     packet.Write(clientId);
     SendTcpData(clientId, packet);
 }
Exemple #20
0
        public ActionResult DeleteConfirmed(int id)
        {
            LogPosition logPosition = db.LogPosition.Find(id);

            db.LogPosition.Remove(logPosition);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #21
0
 public LogEntryStart(LogEntryVersion version, int masterId, int authorId, long timeWritten, long lastCommittedTxWhenTransactionStarted, sbyte[] additionalHeader, LogPosition startPosition) : base(version, TX_START)
 {
     this._masterId      = masterId;
     this._authorId      = authorId;
     this._startPosition = startPosition;
     this._timeWritten   = timeWritten;
     this._lastCommittedTxWhenTransactionStarted = lastCommittedTxWhenTransactionStarted;
     this._additionalHeader = additionalHeader;
 }
Exemple #22
0
 public static void PlayerRotation(Player player)
 {
     LogPosition.Log("Package sent");
     using (Packet packet = new Packet((int)PacketId.PlayerRotation)) {
         packet.Write(player.Id);
         packet.Write(player.Rotation);
         SendUdpDataToAllClients(player.Id, packet);
     }
 }
 internal TransactionCommitment(bool hasExplicitIndexChanges, long transactionId, long transactionChecksum, long transactionCommitTimestamp, LogPosition logPosition, TransactionIdStore transactionIdStore)
 {
     this._hasExplicitIndexChanges    = hasExplicitIndexChanges;
     this._transactionId              = transactionId;
     this._transactionChecksum        = transactionChecksum;
     this._transactionCommitTimestamp = transactionCommitTimestamp;
     this._logPosition        = logPosition;
     this._transactionIdStore = transactionIdStore;
 }
Exemple #24
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: protected LogTailInformation checkpointTailInformation(long highestLogVersion, org.neo4j.kernel.impl.transaction.log.entry.LogEntryStart latestStartEntry, long oldestVersionFound, org.neo4j.kernel.impl.transaction.log.entry.LogEntryVersion latestLogEntryVersion, org.neo4j.kernel.impl.transaction.log.entry.CheckPoint latestCheckPoint, boolean corruptedTransactionLogs) throws java.io.IOException
        protected internal virtual LogTailInformation CheckpointTailInformation(long highestLogVersion, LogEntryStart latestStartEntry, long oldestVersionFound, LogEntryVersion latestLogEntryVersion, CheckPoint latestCheckPoint, bool corruptedTransactionLogs)
        {
            LogPosition checkPointLogPosition            = latestCheckPoint.LogPosition;
            ExtractedTransactionRecord transactionRecord = ExtractFirstTxIdAfterPosition(checkPointLogPosition, highestLogVersion);
            long firstTxIdAfterPosition     = transactionRecord.Id;
            bool startRecordAfterCheckpoint = (firstTxIdAfterPosition != NoTransactionId) || ((latestStartEntry != null) && (latestStartEntry.StartPosition.CompareTo(latestCheckPoint.LogPosition) >= 0));
            bool corruptedLogs = transactionRecord.Failure || corruptedTransactionLogs;

            return(new LogTailInformation(latestCheckPoint, corruptedLogs || startRecordAfterCheckpoint, firstTxIdAfterPosition, oldestVersionFound, highestLogVersion, latestLogEntryVersion));
        }
Exemple #25
0
 public ActionResult Edit([Bind(Include = "id,idAgente,Lat,Lon,Fecha")] LogPosition logPosition)
 {
     if (ModelState.IsValid)
     {
         db.Entry(logPosition).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idAgente = new SelectList(db.Agente, "Id", "Nombre", logPosition.idAgente);
     return(View(logPosition));
 }
 public override int GetHashCode()
 {
     unchecked {
         int result = LogPosition.GetHashCode();
         result = (result * 397) ^ TimeStamp.GetHashCode();
         result = (result * 397) ^ SystemRecordType.GetHashCode();
         result = (result * 397) ^ SystemRecordSerialization.GetHashCode();
         result = (result * 397) ^ Reserved.GetHashCode();
         return(result);
     }
 }
Exemple #27
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;
            }
        }
Exemple #28
0
 private PhysicalLogVersionedStoreChannel TryOpenStoreChannel(LogPosition currentPosition)
 {
     try
     {
         return(_logFiles.openForVersion(currentPosition.LogVersion));
     }
     catch (IOException)
     {
         return(null);
     }
 }
Exemple #29
0
        public IHttpActionResult GetLogPosition(int id)
        {
            LogPosition logPosition = db.LogPosition.Find(id);

            if (logPosition == null)
            {
                return(NotFound());
            }

            return(Ok(logPosition));
        }
 public override int GetHashCode()
 {
     unchecked {
         int result = LogPosition.GetHashCode();
         result = (result * 397) ^ TransactionPosition.GetHashCode();
         result = (result * 397) ^ FirstEventNumber.GetHashCode();
         result = (result * 397) ^ SortKey.GetHashCode();
         result = (result * 397) ^ CorrelationId.GetHashCode();
         result = (result * 397) ^ TimeStamp.GetHashCode();
         return(result);
     }
 }
 public void Serialize(LogPosition lp)
 {
     Serialize(Magic.TypeLogPosition);
     Serialize(lp.CommitID);
 }
 static public StringBuilder Serialize(StringBuilder sb, LogPosition lp)
 {
     sb.Append(TypeLogPosition);
     Serialize(sb, lp.commit_id);
     sb.Append(' ');
     return sb;
 }
Exemple #33
0
 public static void Write(LogEntry logEntry, LogPosition logPosition, string path)
 {
     throw new NotImplementedException();
 }