本文整理汇总了C++中boost::optional::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ optional::isNull方法的具体用法?C++ optional::isNull怎么用?C++ optional::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::optional
的用法示例。
在下文中一共展示了optional::isNull方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setTimestampReadSource
void WiredTigerRecoveryUnit::setTimestampReadSource(ReadSource readSource,
boost::optional<Timestamp> provided) {
LOG(3) << "setting timestamp read source: " << static_cast<int>(readSource)
<< ", provided timestamp: " << ((provided) ? provided->toString() : "none");
invariant(!_isActive() || _timestampReadSource == readSource,
str::stream() << "Current state: " << toString(_state)
<< ". Invalid internal state while setting timestamp read source: "
<< static_cast<int>(readSource)
<< ", provided timestamp: "
<< (provided ? provided->toString() : "none"));
invariant(!provided == (readSource != ReadSource::kProvided));
invariant(!(provided && provided->isNull()));
_timestampReadSource = readSource;
_readAtTimestamp = (provided) ? *provided : Timestamp();
}
示例2: recoverFromOplog
void ReplicationRecoveryImpl::recoverFromOplog(OperationContext* opCtx,
boost::optional<Timestamp> stableTimestamp) try {
if (_consistencyMarkers->getInitialSyncFlag(opCtx)) {
log() << "No recovery needed. Initial sync flag set.";
return; // Initial Sync will take over so no cleanup is needed.
}
const auto serviceCtx = getGlobalServiceContext();
inReplicationRecovery(serviceCtx) = true;
ON_BLOCK_EXIT([serviceCtx] {
invariant(
inReplicationRecovery(serviceCtx),
"replication recovery flag is unexpectedly unset when exiting recoverFromOplog()");
inReplicationRecovery(serviceCtx) = false;
});
const auto truncateAfterPoint = _consistencyMarkers->getOplogTruncateAfterPoint(opCtx);
if (!truncateAfterPoint.isNull()) {
log() << "Removing unapplied entries starting at: " << truncateAfterPoint.toBSON();
_truncateOplogTo(opCtx, truncateAfterPoint);
// Clear the truncateAfterPoint so that we don't truncate the next batch of oplog entries
// erroneously.
_consistencyMarkers->setOplogTruncateAfterPoint(opCtx, {});
opCtx->recoveryUnit()->waitUntilDurable();
}
auto topOfOplogSW = _getTopOfOplog(opCtx);
if (topOfOplogSW.getStatus() == ErrorCodes::CollectionIsEmpty ||
topOfOplogSW.getStatus() == ErrorCodes::NamespaceNotFound) {
// Oplog is empty. There are no oplog entries to apply, so we exit recovery and go into
// initial sync.
log() << "No oplog entries to apply for recovery. Oplog is empty.";
return;
}
fassert(40290, topOfOplogSW);
const auto topOfOplog = topOfOplogSW.getValue();
// If we were passed in a stable timestamp, we are in rollback recovery and should recover from
// that stable timestamp. Otherwise, we're recovering at startup. If this storage engine
// supports recover to stable timestamp or enableMajorityReadConcern=false, we ask it for the
// recovery timestamp. If the storage engine returns a timestamp, we recover from that point.
// However, if the storage engine returns "none", the storage engine does not have a stable
// checkpoint and we must recover from an unstable checkpoint instead.
const bool supportsRecoveryTimestamp =
_storageInterface->supportsRecoveryTimestamp(opCtx->getServiceContext());
if (!stableTimestamp && supportsRecoveryTimestamp) {
stableTimestamp = _storageInterface->getRecoveryTimestamp(opCtx->getServiceContext());
}
const auto appliedThrough = _consistencyMarkers->getAppliedThrough(opCtx);
invariant(!stableTimestamp || stableTimestamp->isNull() || appliedThrough.isNull() ||
*stableTimestamp == appliedThrough.getTimestamp(),
str::stream() << "Stable timestamp " << stableTimestamp->toString()
<< " does not equal appliedThrough timestamp "
<< appliedThrough.toString());
if (stableTimestamp) {
invariant(supportsRecoveryTimestamp);
_recoverFromStableTimestamp(opCtx, *stableTimestamp, appliedThrough, topOfOplog);
} else {
_recoverFromUnstableCheckpoint(opCtx, appliedThrough, topOfOplog);
}
_reconstructPreparedTransactions(opCtx);
} catch (...) {
severe() << "Caught exception during replication recovery: " << exceptionToStatus();
std::terminate();
}