Пример #1
0
        public TransactionInfo GetTransactionInfo(long writerCheckpoint, long transactionId)
        {
            TransactionInfo transactionInfo;

            if (!_transactionInfoCache.TryGet(transactionId, out transactionInfo))
            {
                if (GetTransactionInfoUncached(writerCheckpoint, transactionId, out transactionInfo))
                {
                    _transactionInfoCache.Put(transactionId, transactionInfo, 0);
                }
                else
                {
                    transactionInfo = new TransactionInfo(int.MinValue, null);
                }
                Interlocked.Increment(ref _notCachedTransInfo);
            }
            else
            {
                Interlocked.Increment(ref _cachedTransInfo);
            }
            return(transactionInfo);
        }
Пример #2
0
 public void UpdateTransactionInfo(long transactionId, long logPosition, TransactionInfo transactionInfo)
 {
     _notProcessedTrans.Enqueue(new TransInfo(transactionId, logPosition));
     _transactionInfoCache.Put(transactionId, transactionInfo, +1);
 }
Пример #3
0
 private bool GetTransactionInfoUncached(long writerCheckpoint, long transactionId, out TransactionInfo transactionInfo)
 {
     using (var reader = _indexBackend.BorrowReader())
     {
         reader.Reposition(writerCheckpoint);
         SeqReadResult result;
         while ((result = reader.TryReadPrev()).Success)
         {
             if (result.LogRecord.LogPosition < transactionId)
                 break;
             if (result.LogRecord.RecordType != LogRecordType.Prepare)
                 continue;
             var prepare = (PrepareLogRecord)result.LogRecord;
             if (prepare.TransactionPosition == transactionId)
             {
                 transactionInfo = new TransactionInfo(prepare.TransactionOffset, prepare.EventStreamId);
                 return true;
             }
         }
     }
     transactionInfo = new TransactionInfo(int.MinValue, null);
     return false;
 }
Пример #4
0
 public TransactionInfo GetTransactionInfo(long writerCheckpoint, long transactionId)
 {
     TransactionInfo transactionInfo;
     if (!_transactionInfoCache.TryGet(transactionId, out transactionInfo))
     {
         if (GetTransactionInfoUncached(writerCheckpoint, transactionId, out transactionInfo))
             _transactionInfoCache.Put(transactionId, transactionInfo, 0);
         else
             transactionInfo = new TransactionInfo(int.MinValue, null);
         Interlocked.Increment(ref _notCachedTransInfo);
     }
     else
     {
         Interlocked.Increment(ref _cachedTransInfo);
     }
     return transactionInfo;
 }
Пример #5
0
 public void UpdateTransactionInfo(long transactionId, long logPosition, TransactionInfo transactionInfo)
 {
     _notProcessedTrans.Enqueue(new TransInfo(transactionId, logPosition));
     _transactionInfoCache.Put(transactionId, transactionInfo, +1);
 }
Пример #6
0
 private bool GetTransactionInfoUncached(long writerCheckpoint, long transactionId, out TransactionInfo transactionInfo)
 {
     var seqReader = GetSeqReader();
     try
     {
         seqReader.Reposition(writerCheckpoint);
         SeqReadResult result;
         while ((result = seqReader.TryReadPrev()).Success)
         {
             if (result.LogRecord.Position < transactionId)
                 break;
             if (result.LogRecord.RecordType != LogRecordType.Prepare)
                 continue;
             var prepare = (PrepareLogRecord)result.LogRecord;
             if (prepare.TransactionPosition == transactionId)
             {
                 transactionInfo = new TransactionInfo(prepare.TransactionOffset, prepare.EventStreamId);
                 return true;
             }
         }
     }
     finally
     {
         ReturnSeqReader(seqReader);
     }
     transactionInfo = new TransactionInfo(int.MinValue, null);
     return false;
 }
Пример #7
0
 TransactionInfo IReadIndex.GetTransactionInfo(long writerCheckpoint, long transactionId)
 {
     TransactionInfo transactionInfo;
     if (!_transactionInfoCache.TryGet(transactionId, out transactionInfo))
     {
         if (GetTransactionInfoUncached(writerCheckpoint, transactionId, out transactionInfo))
             _transactionInfoCache.Put(transactionId, transactionInfo);
         else
             transactionInfo = new TransactionInfo(int.MinValue, null);
     }
     return transactionInfo;
 }
Пример #8
0
 void IReadIndex.UpdateTransactionInfo(long transactionId, TransactionInfo transactionInfo)
 {
     _transactionInfoCache.Put(transactionId, transactionInfo);
 }
Пример #9
0
 private bool GetTransactionInfoUncached(long writerCheckpoint, long transactionId, out TransactionInfo transactionInfo)
 {
     using (var reader = _indexBackend.BorrowReader())
     {
         reader.Reposition(writerCheckpoint);
         SeqReadResult result;
         while ((result = reader.TryReadPrev()).Success)
         {
             if (result.LogRecord.LogPosition < transactionId)
             {
                 break;
             }
             if (result.LogRecord.RecordType != LogRecordType.Prepare)
             {
                 continue;
             }
             var prepare = (PrepareLogRecord)result.LogRecord;
             if (prepare.TransactionPosition == transactionId)
             {
                 transactionInfo = new TransactionInfo(prepare.TransactionOffset, prepare.EventStreamId);
                 return(true);
             }
         }
     }
     transactionInfo = new TransactionInfo(int.MinValue, null);
     return(false);
 }
 public void UpdateTransactionInfo(long transactionId, TransactionInfo transactionInfo)
 {
     throw new NotImplementedException();
 }