Storage Engine API
storage_options.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 10gen Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License, version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * As a special exception, the copyright holders give permission to link the
17  * code of portions of this program with the OpenSSL library under certain
18  * conditions as described in each individual source file and distribute
19  * linked combinations including the program with the OpenSSL library. You
20  * must comply with the GNU Affero General Public License in all respects for
21  * all of the code used other than as permitted herein. If you modify file(s)
22  * with this exception, you may extend this exception to your version of the
23  * file(s), but you are not obligated to do so. If you do not wish to do so,
24  * delete this exception statement from your version. If you delete this
25  * exception statement from all source files in the program, then also delete
26  * it in the license file.
27  */
28 
29 #pragma once
30 
31 #include <atomic>
32 #include <string>
33 
34 #include "mongo/platform/atomic_proxy.h"
35 #include "mongo/platform/atomic_word.h"
36 
37 /*
38  * This file defines the storage for options that come from the command line related to data file
39  * persistence. Many executables that can access data files directly such as mongod and certain
40  * tools use these variables, but each executable may have a different set of command line flags
41  * that allow the user to change a different subset of these options.
42  */
43 
44 namespace mongo {
45 
47  // Default data directory for mongod when running in non-config server mode.
48  static const char* kDefaultDbPath;
49 
50  // Default data directory for mongod when running as the config database of
51  // a sharded cluster.
52  static const char* kDefaultConfigDbPath;
53 
54  // --storageEngine
55  // storage engine for this instance of mongod.
56  std::string engine = "wiredTiger";
57 
58  // True if --storageEngine was passed on the command line, and false otherwise.
59  bool engineSetByUser = false;
60 
61  // The directory where the mongod instance stores its data.
62  std::string dbpath = kDefaultDbPath;
63 
64  // --upgrade
65  // Upgrades the on-disk data format of the files specified by the --dbpath to the
66  // latest version, if needed.
67  bool upgrade = false;
68 
69  // --repair
70  // Runs a repair routine on all databases. This is equivalent to shutting down and
71  // running the repairDatabase database command on all databases.
72  bool repair = false;
73 
74  // --repairpath
75  // Specifies the root directory containing MongoDB data files to use for the --repair
76  // operation.
77  // Default: A _tmp directory within the path specified by the dbPath option.
78  std::string repairpath;
79 
80  // The intention here is to enable the journal by default if we are running on a 64 bit system.
81  bool dur = (sizeof(void*) == 8); // --dur durability (now --journal)
82 
83  // --journalCommitInterval
84  static const int kMaxJournalCommitIntervalMs;
86 
87  // --notablescan
88  // no table scans allowed
89  AtomicBool noTableScan{false};
90 
91  // --directoryperdb
92  // Stores each database’s files in its own folder in the data directory.
93  // When applied to an existing system, the directoryPerDB option alters
94  // the storage pattern of the data directory.
95  bool directoryperdb = false;
96 
97  // --syncdelay
98  // Controls how much time can pass before MongoDB flushes data to the data files
99  // via an fsync operation.
100  // Do not set this value on production systems.
101  // In almost every situation, you should use the default setting.
102  static const double kMaxSyncdelaySecs;
103  AtomicDouble syncdelay{60.0}; // seconds between fsyncs
104 
105  // --queryableBackupMode
106  // Puts MongoD into "read-only" mode. MongoD will not write any data to the underlying
107  // filesystem. Note that read operations may require writes. For example, a sort on a large
108  // dataset may fail if it requires spilling to disk.
109  bool readOnly = false;
110 
111  // --groupCollections
112  // Dictate to the storage engine that it should attempt to create new MongoDB collections from
113  // an existing underlying MongoDB database level resource if possible. This can improve
114  // workloads that rely heavily on creating many collections within a database.
115  bool groupCollections = false;
116 };
117 
119 
120 } // namespace mongo
AtomicDouble syncdelay
Definition: storage_options.h:103
static const char * kDefaultDbPath
The directory where the mongod instance stores its data.
Definition: storage_options.h:48
bool repair
Definition: storage_options.h:72
static const char * kDefaultConfigDbPath
Definition: storage_options.h:52
AtomicInt32 journalCommitIntervalMs
Definition: storage_options.h:85
Copyright (C) 2014 MongoDB Inc.
Definition: bson_collection_catalog_entry.cpp:38
bool upgrade
Definition: storage_options.h:67
bool groupCollections
Definition: storage_options.h:115
Definition: storage_options.h:46
std::string engine
Definition: storage_options.h:56
bool readOnly
Definition: storage_options.h:109
static const int kMaxJournalCommitIntervalMs
Definition: storage_options.h:84
bool dur
Definition: storage_options.h:81
std::string dbpath
Definition: storage_options.h:62
bool directoryperdb
Definition: storage_options.h:95
static const double kMaxSyncdelaySecs
Definition: storage_options.h:102
std::string repairpath
Definition: storage_options.h:78
StorageGlobalParams storageGlobalParams
Definition: storage_options.cpp:39
AtomicBool noTableScan
Definition: storage_options.h:89
bool engineSetByUser
Definition: storage_options.h:59