static Status getStatus(const BatchedCommandResponse& response) {
    if (response.getOk() != 1) {
        return Status(static_cast<ErrorCodes::Error>(response.getErrCode()),
                      response.getErrMessage());
    }

    if (response.isErrDetailsSet()) {
        const WriteErrorDetail* errDetail = response.getErrDetails().front();
        return Status(static_cast<ErrorCodes::Error>(errDetail->getErrCode()),
                      errDetail->getErrMessage());
    }

    if (response.isWriteConcernErrorSet()) {
        const WCErrorDetail* errDetail = response.getWriteConcernError();
        return Status(static_cast<ErrorCodes::Error>(errDetail->getErrCode()),
                      errDetail->getErrMessage());
    }

    return Status::OK();
}
Status SessionsCollectionSharded::removeRecords(OperationContext* opCtx,
                                                const LogicalSessionIdSet& sessions) {
    auto send = [&](BSONObj toSend) {
        auto opMsg = OpMsgRequest::fromDBAndBody(SessionsCollection::kSessionsDb, toSend);
        auto request = BatchedCommandRequest::parseDelete(opMsg);

        BatchedCommandResponse response;
        BatchWriteExecStats stats;

        ClusterWriter::write(opCtx, request, &stats, &response);

        if (response.getOk()) {
            return Status::OK();
        }

        auto error = response.isErrCodeSet() ? ErrorCodes::fromInt(response.getErrCode())
                                             : ErrorCodes::UnknownError;
        return Status(error, response.getErrMessage());
    };

    return doRemove(sessions, send);
}
Beispiel #3
0
static void cloneCommandErrorTo(const BatchedCommandResponse& batchResp,
                                WriteErrorDetail* details) {
    details->setErrCode(batchResp.getErrCode());
    details->setErrMessage(batchResp.getErrMessage());
}
Beispiel #4
0
 void buildErrorFromResponse( const BatchedCommandResponse& response, WriteErrorDetail* error ) {
     error->setErrCode( response.getErrCode() );
     error->setErrMessage( response.getErrMessage() );
 }
 void buildErrorFromResponse( const BatchedCommandResponse& response, BatchedErrorDetail* error ) {
     error->setErrCode( response.getErrCode() );
     if ( error->isErrInfoSet() ) error->setErrInfo( response.getErrInfo() );
     error->setErrMessage( response.getErrMessage() );
 }
Beispiel #6
0
 static void cloneBatchErrorTo( const BatchedCommandResponse& batchResp,
                                BatchedErrorDetail* details ) {
     details->setErrCode( batchResp.getErrCode() );
     if ( batchResp.isErrInfoSet() ) details->setErrInfo( batchResp.getErrInfo() );
     details->setErrMessage( batchResp.getErrMessage() );
 }