MongoDB  2.7.0
fail_point_registry.h
1 /*
2  * Copyright (C) 2012 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
21  * for all of the code used other than as permitted herein. If you modify
22  * file(s) with this exception, you may extend this exception to your
23  * version of the file(s), but you are not obligated to do so. If you do not
24  * wish to do so, delete this exception statement from your version. If you
25  * delete this exception statement from all source files in the program,
26  * then also delete it in the license file.
27  */
28 
33 #pragma once
34 
35 #include "mongo/base/status.h"
36 #include "mongo/platform/unordered_map.h"
37 #include "mongo/util/fail_point.h"
38 
39 namespace mongo {
44  public:
46 
55  Status addFailPoint(const std::string& name, FailPoint* failPoint);
56 
60  FailPoint* getFailPoint(const std::string& name) const;
61 
65  void freeze();
66 
67  private:
68  bool _frozen;
69  unordered_map<std::string, FailPoint*> _fpMap;
70  };
71 }
72 
A simple thread-safe fail point implementation that can be activated and deactivated, as well as embed temporary data into it.
Definition: fail_point.h:66
Class for storing FailPoint instances.
Definition: fail_point_registry.h:43
Status addFailPoint(const std::string &name, FailPoint *failPoint)
Adds a new fail point to this registry.
Definition: fail_point_registry.cpp:40
FailPoint * getFailPoint(const std::string &name) const
Definition: fail_point_registry.cpp:55
void freeze()
Freezes this registry from being modified.
Definition: fail_point_registry.cpp:59