public void ShouldPackResult() { const int termId = 7; const int termOffset = -1; long result = TermAppender.Pack(termId, termOffset); Assert.That(TermAppender.TermId(result), Is.EqualTo(termId)); Assert.That(TermAppender.TermOffset(result), Is.EqualTo(termOffset)); }
private long NewPosition(int index, int currentTail, long position, long result) { var newPosition = ADMIN_ACTION; var termOffset = TermAppender.TermOffset(result); if (termOffset > 0) { newPosition = (position - currentTail) + termOffset; } else if (termOffset == TermAppender.TRIPPED) { var nextIndex = LogBufferDescriptor.NextPartitionIndex(index); _termAppenders[nextIndex].TailTermId(TermAppender.TermId(result) + 1); LogBufferDescriptor.ActivePartitionIndexOrdered(_logMetaDataBuffer, nextIndex); } return(newPosition); }
private long NewPosition(int index, int currentTail, long position, long result) { long newPosition = TermAppender.TRIPPED; int termOffset = TermAppender.TermOffset(result); if (termOffset > 0) { newPosition = (position - currentTail) + termOffset; } else if (termOffset == TermAppender.TRIPPED) { //int nextIndex = NextPartitionIndex(index); //int nextNextIndex = NextPartitionIndex(nextIndex); //_termAppenders[nextIndex].TailTermId(TermAppender.TermId(result) + 1); //_termAppenders[nextNextIndex].StatusOrdered(LogBufferDescriptor.NEEDS_CLEANING); //ActivePartitionIndex(_logBuffers.LogMetaData, nextIndex); RotateLog(_logBuffers.Partitions, _logBuffers.LogMetaData, index, TermAppender.TermId(result) + 1); _cleanEvent.Set(); } return(newPosition); }