summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/SConscript10
-rw-r--r--src/mongo/db/write_block_bypass.cpp51
-rw-r--r--src/mongo/db/write_block_bypass.h45
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