void CollectionCloner::_finishCallback(const Status& status) {
    LOG(1) << "CollectionCloner ns:" << _destNss << " finished with status: " << redact(status);
    // Copy the status so we can change it below if needed.
    auto finalStatus = status;
    bool callCollectionLoader = false;
    UniqueLock lk(_mutex);
    callCollectionLoader = _collLoader.operator bool();
    lk.unlock();
    if (callCollectionLoader) {
        if (finalStatus.isOK()) {
            const auto loaderStatus = _collLoader->commit();
            if (!loaderStatus.isOK()) {
                warning() << "Failed to commit changes to collection " << _destNss.ns() << ": "
                          << redact(loaderStatus);
                finalStatus = loaderStatus;
            }
        }

        // This will release the resources held by the loader.
        _collLoader.reset();
    }
    _onCompletion(finalStatus);
    lk.lock();
    _stats.end = _executor->now();
    _progressMeter.finished();
    _active = false;
    _condition.notify_all();
    LOG(1) << "    collection: " << _destNss << ", stats: " << _stats.toString();
}
Beispiel #2
0
 void Applier::_finishCallback(const StatusWith<Timestamp>& result,
                               const Operations& operations) {
     _onCompletion(result, operations);
     boost::lock_guard<boost::mutex> lk(_mutex);
     _active = false;
     _condition.notify_all();
 }
Beispiel #3
0
void DatabaseCloner::_finishCallback(const Status& status) {
    _onCompletion(status);
    LockGuard lk(_mutex);
    _active = false;
    _condition.notify_all();
    _stats.end = _executor->now();
    LOG(1) << "    database: " << _dbname << ", stats: " << _stats.toString();
}
void CollectionCloner::_finishCallback(OperationContext* txn, const Status& status) {
    if (status.isOK()) {
        auto commitStatus = _storageInterface->commitCollection(txn, _destNss);
        if (!commitStatus.isOK()) {
            warning() << "Failed to commit changes to collection " << _destNss.ns() << ": "
                      << commitStatus;
        }
    }
    _onCompletion(status);
    stdx::lock_guard<stdx::mutex> lk(_mutex);
    _active = false;
    _condition.notify_all();
}
Beispiel #5
0
Status SyncSourceResolver::_finishCallback(const SyncSourceResolverResponse& response) {
    try {
        _onCompletion(response);
    } catch (...) {
        warning() << "sync source resolver finish callback threw exception: "
                  << exceptionToStatus();
    }

    stdx::lock_guard<stdx::mutex> lock(_mutex);
    invariant(_state != State::kComplete);
    _state = State::kComplete;
    _condition.notify_all();
    return response.syncSourceStatus.getStatus();
}
 void ScatterGatherRunner::_signalSufficientResponsesReceived(ReplicationExecutor* executor) {
     if (_sufficientResponsesReceived.isValid()) {
         std::for_each(_callbacks.begin(),
                       _callbacks.end(),
                       stdx::bind(&ReplicationExecutor::cancel,
                                  executor,
                                  stdx::placeholders::_1));
         const ReplicationExecutor::EventHandle h = _sufficientResponsesReceived;
         _sufficientResponsesReceived = ReplicationExecutor::EventHandle();
         if (_onCompletion) {
             _onCompletion();
         }
         executor->signalEvent(h);
     }
 }
void DatabaseCloner::_finishCallback(const Status& status) {
    _onCompletion(status);
    stdx::lock_guard<stdx::mutex> lk(_mutex);
    _active = false;
    _condition.notify_all();
}