コード例 #1
0
ファイル: batch_executor.cpp プロジェクト: AndrewCEmil/mongo
    static WriteErrorDetail* toWriteError( const Status& status ) {

        WriteErrorDetail* error = new WriteErrorDetail;

        // TODO: Complex transform here?
        error->setErrCode( status.code() );
        error->setErrMessage( status.reason() );

        return error;
    }
コード例 #2
0
 static bool checkIsMasterForCollection(const std::string& ns, WriteOpResult* result) {
     if (!isMasterNs(ns.c_str())) {
         WriteErrorDetail* errorDetail = new WriteErrorDetail;
         result->setError(errorDetail);
         errorDetail->setErrCode(ErrorCodes::NotMaster);
         errorDetail->setErrMessage("Not primary while writing to " + ns);
         return false;
     }
     return true;
 }
コード例 #3
0
static bool checkIsMasterForCollection(const NamespaceString& ns, WriteErrorDetail** error) {
    if (!isMasterNs(ns.ns().c_str())) {
        WriteErrorDetail* errorDetail = *error = new WriteErrorDetail;
        errorDetail->setErrCode(ErrorCodes::NotMaster);
        errorDetail->setErrMessage(std::string(mongoutils::str::stream() <<
                                               "Not primary while writing to " << ns.ns()));
        return false;
    }
    return true;
}
コード例 #4
0
ファイル: batch_executor.cpp プロジェクト: AndrewCEmil/mongo
 static bool checkIsMasterForDatabase(const std::string& ns, WriteOpResult* result) {
     if (!repl::getGlobalReplicationCoordinator()->canAcceptWritesForDatabase(
             NamespaceString(ns).db())) {
         WriteErrorDetail* errorDetail = new WriteErrorDetail;
         result->setError(errorDetail);
         errorDetail->setErrCode(ErrorCodes::NotMaster);
         errorDetail->setErrMessage("Not primary while writing to " + ns);
         return false;
     }
     return true;
 }
コード例 #5
0
WriteErrorDetail* BatchSafeWriter::lastErrorToBatchError( const LastError& lastError ) {

    bool isFailedOp = lastError.msg != "";
    bool isStaleOp = lastError.writebackId.isSet();
    dassert( !( isFailedOp && isStaleOp ) );

    if ( isFailedOp ) {
        WriteErrorDetail* batchError = new WriteErrorDetail;
        if ( lastError.code != 0 ) batchError->setErrCode( lastError.code );
        else batchError->setErrCode( ErrorCodes::UnknownError );
        batchError->setErrMessage( lastError.msg );
        return batchError;
    }
    else if ( isStaleOp ) {
        WriteErrorDetail* batchError = new WriteErrorDetail;
        batchError->setErrCode( ErrorCodes::StaleShardVersion );
        batchError->setErrInfo( BSON( "downconvert" << true ) ); // For debugging
        batchError->setErrMessage( "shard version was stale" );
        return batchError;
    }

    return NULL;
}