Fawkes API Fawkes Development Version
mongodb_instance_config.h
1
2/***************************************************************************
3 * mongodb_instance_config.h - MongoDB instance configuration
4 *
5 * Created: Wed Jul 12 14:31:10 2017
6 * Copyright 2006-2017 Tim Niemueller [www.niemueller.de]
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef _PLUGINS_MONGODB_MONGODB_INSTANCE_CONFIG_H_
23#define _PLUGINS_MONGODB_MONGODB_INSTANCE_CONFIG_H_
24
25#include <aspect/clock.h>
26#include <aspect/logging.h>
27#include <core/threading/thread.h>
28
29#include <memory>
30#include <string>
31#include <vector>
32
33namespace fawkes {
34class Configuration;
35class Logger;
36class SubProcess;
37class TimeWait;
38} // namespace fawkes
39
40/** Client configuration. */
44{
45public:
46 MongoDBInstanceConfig(fawkes::Configuration *config, std::string cfgname, std::string prefix);
47
48 /** Check if configuration is enabled.
49 * @return true if configuration is enabled, false otherwise
50 */
51 bool
52 is_enabled() const
53 {
54 return enabled_;
55 }
56
57 virtual void init();
58 virtual void loop();
59 virtual void finalize();
60
61 void start_mongod();
62 void kill_mongod(bool clear_data);
63
64 std::string command_line() const;
65 unsigned int termination_grace_period() const;
66
67private:
68 bool check_alive();
69
70private:
71 bool enabled_;
72
73 std::string config_name_;
74 unsigned int startup_grace_period_;
75 unsigned int termination_grace_period_;
76 float loop_interval_;
77 bool clear_data_on_termination_;
78 bool use_tmp_directory_;
79 std::string bind_ip_;
80 unsigned int port_;
81 std::string data_path_;
82 std::string log_path_;
83 bool log_append_;
84 std::string replica_set_;
85 unsigned int oplog_size_;
86
87 bool running_;
88 std::vector<std::string> argv_;
89 std::shared_ptr<fawkes::SubProcess> proc_;
90 std::string command_line_;
91
92 fawkes::TimeWait *timewait_;
93};
94
95#endif
Client configuration.
bool is_enabled() const
Check if configuration is enabled.
unsigned int termination_grace_period() const
Get termination grace period.
virtual void loop()
Code to execute in the thread.
virtual void finalize()
Finalize the thread.
void start_mongod()
Start mongod.
void kill_mongod(bool clear_data)
Stop mongod.
MongoDBInstanceConfig(fawkes::Configuration *config, std::string cfgname, std::string prefix)
Constructor.
virtual void init()
Initialize the thread.
std::string command_line() const
Get command line used to execute program.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Interface for configuration handling.
Definition: config.h:68
Thread aspect to log output.
Definition: logging.h:33
Thread class encapsulation of pthreads.
Definition: thread.h:46
Time wait utility.
Definition: wait.h:33
Fawkes library namespace.