summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/transaction_coordinator_structures.cpp
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-03-27 10:21:08 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2019-04-01 07:26:26 -0400
commit9dd07662bbe80415d90131fca2be6312166d6f39 (patch)
tree2c3225830737ac56796901d6e928830be62ede31 /src/mongo/db/s/transaction_coordinator_structures.cpp
parentd7f0bffc93993bcc7e794344d5a1ae25ff95571b (diff)
downloadmongo-9dd07662bbe80415d90131fca2be6312166d6f39.tar.gz
SERVER-40297 Move the TransactionCoordinator data structures to a separate file
Diffstat (limited to 'src/mongo/db/s/transaction_coordinator_structures.cpp')
-rw-r--r--src/mongo/db/s/transaction_coordinator_structures.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/mongo/db/s/transaction_coordinator_structures.cpp b/src/mongo/db/s/transaction_coordinator_structures.cpp
new file mode 100644
index 00000000000..08be1a0b7aa
--- /dev/null
+++ b/src/mongo/db/s/transaction_coordinator_structures.cpp
@@ -0,0 +1,81 @@
+/**
+ * Copyright (C) 2018-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.
+ */
+
+#define MONGO_LOG_DEFAULT_COMPONENT ::mongo::logger::LogComponent::kTransaction
+
+#include "mongo/platform/basic.h"
+
+#include "mongo/db/s/transaction_coordinator_structures.h"
+
+#include "mongo/util/assert_util.h"
+
+namespace mongo {
+namespace txn {
+namespace {
+
+constexpr auto kCommitDecision = "commit"_sd;
+constexpr auto kAbortDecision = "abort"_sd;
+
+} // namespace
+
+CommitDecision readCommitDecisionEnumProperty(StringData decision) {
+ // clang-format off
+ if (decision == kCommitDecision) return CommitDecision::kCommit;
+ if (decision == kAbortDecision) return CommitDecision::kAbort;
+ // clang-format on
+
+ uasserted(ErrorCodes::BadValue,
+ str::stream() << "'" << decision << "' is not a valid decision");
+}
+
+StringData writeCommitDecisionEnumProperty(CommitDecision decision) {
+ // clang-format off
+ switch (decision) {
+ case CommitDecision::kCommit: return kCommitDecision;
+ case CommitDecision::kAbort: return kAbortDecision;
+ case CommitDecision::kCanceled: break;
+ };
+ // clang-format on
+ MONGO_UNREACHABLE;
+}
+
+logger::LogstreamBuilder& operator<<(logger::LogstreamBuilder& stream,
+ const CommitDecision& decision) {
+ // clang-format off
+ switch (decision) {
+ case txn::CommitDecision::kCommit: return stream << "kCommit";
+ case txn::CommitDecision::kAbort: return stream << "kAbort";
+ case txn::CommitDecision::kCanceled: return stream << "kCanceled";
+ };
+ // clang-format on
+ MONGO_UNREACHABLE;
+}
+
+} // namespace txn
+} // namespace mongo