本文整理汇总了C#中StorageEnvironmentOptions.InvokeRecoveryError方法的典型用法代码示例。如果您正苦于以下问题:C# StorageEnvironmentOptions.InvokeRecoveryError方法的具体用法?C# StorageEnvironmentOptions.InvokeRecoveryError怎么用?C# StorageEnvironmentOptions.InvokeRecoveryError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StorageEnvironmentOptions
的用法示例。
在下文中一共展示了StorageEnvironmentOptions.InvokeRecoveryError方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadOneTransaction
public bool ReadOneTransaction(StorageEnvironmentOptions options,bool checkCrc = true)
{
if (_readingPage >= _pager.NumberOfAllocatedPages)
return false;
TransactionHeader* current;
if (!TryReadAndValidateHeader(options, out current))
return false;
var compressedPages = (current->CompressedSize / AbstractPager.PageSize) + (current->CompressedSize % AbstractPager.PageSize == 0 ? 0 : 1);
if (current->TransactionId <= _lastSyncedTransactionId)
{
LastTransactionHeader = current;
_readingPage += compressedPages;
return true; // skipping
}
if (checkCrc && !ValidatePagesCrc(options, compressedPages, current))
return false;
_recoveryPager.EnsureContinuous(null, _recoveryPage, (current->PageCount + current->OverflowPageCount) + 1);
var dataPage = _recoveryPager.AcquirePagePointer(_recoveryPage);
NativeMethods.memset(dataPage, 0, (current->PageCount + current->OverflowPageCount) * AbstractPager.PageSize);
try
{
LZ4.Decode64(_pager.AcquirePagePointer(_readingPage), current->CompressedSize, dataPage, current->UncompressedSize, true);
}
catch (Exception e)
{
options.InvokeRecoveryError(this, "Could not de-compress, invalid data", e);
RequireHeaderUpdate = true;
return false;
}
var tempTransactionPageTranslaction = new Dictionary<long, JournalFile.PagePosition>();
for (var i = 0; i < current->PageCount; i++)
{
Debug.Assert(_pager.Disposed == false);
Debug.Assert(_recoveryPager.Disposed == false);
var page = _recoveryPager.Read(_recoveryPage);
tempTransactionPageTranslaction[page.PageNumber] = new JournalFile.PagePosition
{
JournalPos = _recoveryPage,
TransactionId = current->TransactionId
};
if (page.IsOverflow)
{
var numOfPages = _recoveryPager.GetNumberOfOverflowPages(page.OverflowSize);
_recoveryPage += numOfPages;
}
else
{
_recoveryPage++;
}
}
_readingPage += compressedPages;
LastTransactionHeader = current;
foreach (var pagePosition in tempTransactionPageTranslaction)
{
_transactionPageTranslation[pagePosition.Key] = pagePosition.Value;
}
return true;
}
示例2: TryReadAndValidateHeader
private bool TryReadAndValidateHeader(StorageEnvironmentOptions options,out TransactionHeader* current)
{
current = (TransactionHeader*)_pager.Read(_readingPage).Base;
if (current->HeaderMarker != Constants.TransactionHeaderMarker)
{
// not a transaction page,
// if the header marker is zero, we are probably in the area at the end of the log file, and have no additional log records
// to read from it. This can happen if the next transaction was too big to fit in the current log file. We stop reading
// this log file and move to the next one.
RequireHeaderUpdate = current->HeaderMarker != 0;
if (RequireHeaderUpdate)
{
options.InvokeRecoveryError(this,
"Transaction " + current->TransactionId +
" header marker was set to garbage value, file is probably corrupted", null);
}
return false;
}
ValidateHeader(current, LastTransactionHeader);
if (current->TxMarker.HasFlag(TransactionMarker.Commit) == false)
{
// uncommitted transaction, probably
RequireHeaderUpdate = true;
options.InvokeRecoveryError(this,
"Transaction " + current->TransactionId +
" was not committed", null);
return false;
}
_readingPage++;
return true;
}
示例3: ValidatePagesCrc
private bool ValidatePagesCrc(StorageEnvironmentOptions options, int compressedPages, TransactionHeader* current)
{
uint crc = Crc.Value(_pager.AcquirePagePointer(_readingPage), 0, compressedPages * AbstractPager.PageSize);
if (crc != current->Crc)
{
RequireHeaderUpdate = true;
options.InvokeRecoveryError(this, "Invalid CRC signature for transaction " + current->TransactionId, null);
return false;
}
return true;
}
示例4: TryDecompressTransactionPages
private unsafe bool TryDecompressTransactionPages(StorageEnvironmentOptions options, TransactionHeader* current, byte* dataPage)
{
try
{
LZ4.Decode64(_pager.AcquirePagePointer(_readingPage), current->CompressedSize, dataPage, current->UncompressedSize, true);
}
catch (Exception e)
{
options.InvokeRecoveryError(this, "Could not de-compress, invalid data", e);
RequireHeaderUpdate = true;
return false;
}
return true;
}