diff options
author | Adam Rayner <adam.rayner@gmail.com> | 2022-02-11 21:52:27 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-02-11 22:49:56 +0000 |
commit | 16e6bdd1ac2f93f7ba35666783bb9bbc60af19b1 (patch) | |
tree | ee0e04606039fa1fa00a611471e6e255748b3372 | |
parent | be1a53bfed2438e50ceb02ee84cb897660da8cdc (diff) | |
download | mongo-16e6bdd1ac2f93f7ba35666783bb9bbc60af19b1.tar.gz |
SERVER-63173 Add WriteBlockBypass decorator to OperationContext
-rw-r--r-- | src/mongo/db/SConscript | 10 | ||||
-rw-r--r-- | src/mongo/db/write_block_bypass.cpp | 51 | ||||
-rw-r--r-- | src/mongo/db/write_block_bypass.h | 45 |
3 files changed, 106 insertions, 0 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 219b665762c..7949473c257 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -495,6 +495,16 @@ env.Library( ) env.Library( + target='write_block_bypass', + source=[ + 'write_block_bypass.cpp', + ], + LIBDEPS_PRIVATE=[ + 'service_context' + ], +) + +env.Library( target="read_write_concern_defaults_mock", source=[ "read_write_concern_defaults_cache_lookup_mock.cpp", diff --git a/src/mongo/db/write_block_bypass.cpp b/src/mongo/db/write_block_bypass.cpp new file mode 100644 index 00000000000..86a445df1b3 --- /dev/null +++ b/src/mongo/db/write_block_bypass.cpp @@ -0,0 +1,51 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#include "mongo/platform/basic.h" + +#include "mongo/db/write_block_bypass.h" + +namespace mongo { + +namespace { +static const auto getWriteBlockBypass = OperationContext::declareDecoration<WriteBlockBypass>(); +} + +bool WriteBlockBypass::isWriteBlockBypassEnabled() const { + return _writeBlockBypassEnabled; +} + +void WriteBlockBypass::enableWriteBlockBypass() { + _writeBlockBypassEnabled = true; +} + +WriteBlockBypass& WriteBlockBypass::get(OperationContext* opCtx) { + return getWriteBlockBypass(opCtx); +} +} // namespace mongo diff --git a/src/mongo/db/write_block_bypass.h b/src/mongo/db/write_block_bypass.h new file mode 100644 index 00000000000..a9d214fb408 --- /dev/null +++ b/src/mongo/db/write_block_bypass.h @@ -0,0 +1,45 @@ +/** + * Copyright (C) 2022-present MongoDB, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * <http://www.mongodb.com/licensing/server-side-public-license>. + * + * As a special exception, the copyright holders give permission to link the + * code of portions of this program with the OpenSSL library under certain + * conditions as described in each individual source file and distribute + * linked combinations including the program with the OpenSSL library. You + * must comply with the Server Side Public License in all respects for + * all of the code used other than as permitted herein. If you modify file(s) + * with this exception, you may extend this exception to your version of the + * file(s), but you are not obligated to do so. If you do not wish to do so, + * delete this exception statement from your version. If you delete this + * exception statement from all source files in the program, then also delete + * it in the license file. + */ + +#pragma once + +#include "mongo/db/operation_context.h" + +namespace mongo { +class WriteBlockBypass { +public: + static WriteBlockBypass& get(OperationContext* opCtx); + + bool isWriteBlockBypassEnabled() const; + void enableWriteBlockBypass(); + +private: + bool _writeBlockBypassEnabled = false; +}; +} // namespace mongo |