2014-06-05 09:35:32 +00:00
|
|
|
/** Configuration file parser.
|
2014-07-14 11:49:44 +00:00
|
|
|
*
|
|
|
|
* The server program is configured by a single file.
|
|
|
|
* This config file is parsed with a third-party library:
|
|
|
|
* libconfig http://www.hyperrealm.com/libconfig/
|
2014-06-05 09:34:32 +00:00
|
|
|
*
|
2014-06-28 06:40:52 +00:00
|
|
|
* @file
|
2015-06-02 21:53:04 +02:00
|
|
|
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
2017-03-03 20:20:13 -04:00
|
|
|
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
2017-04-27 12:56:43 +02:00
|
|
|
* @license GNU General Public License (version 3)
|
|
|
|
*
|
|
|
|
* VILLASnode
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* any later version.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* 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
|
|
|
|
* GNU General Public License for more details.
|
2017-05-05 19:24:16 +00:00
|
|
|
*
|
2017-04-27 12:56:43 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-02 21:53:04 +02:00
|
|
|
*********************************************************************************/
|
2014-06-05 09:34:32 +00:00
|
|
|
|
2017-02-16 09:04:12 -03:00
|
|
|
#pragma once
|
2014-06-05 09:34:32 +00:00
|
|
|
|
|
|
|
#include <libconfig.h>
|
|
|
|
|
2017-02-18 10:31:42 -05:00
|
|
|
#include "list.h"
|
|
|
|
#include "api.h"
|
|
|
|
#include "web.h"
|
|
|
|
#include "log.h"
|
2017-03-11 23:50:30 -03:00
|
|
|
#include "common.h"
|
2017-02-18 10:31:42 -05:00
|
|
|
|
|
|
|
/** Global configuration */
|
2017-03-12 17:01:24 -03:00
|
|
|
struct super_node {
|
2017-02-18 10:31:42 -05:00
|
|
|
int priority; /**< Process priority (lower is better) */
|
|
|
|
int affinity; /**< Process affinity of the server and all created threads */
|
2017-03-11 23:39:00 -03:00
|
|
|
int hugepages; /**< Number of hugepages to reserve. */
|
2017-02-18 10:31:42 -05:00
|
|
|
double stats; /**< Interval for path statistics. Set to 0 to disable them. */
|
|
|
|
|
|
|
|
struct list nodes;
|
|
|
|
struct list paths;
|
|
|
|
struct list plugins;
|
|
|
|
|
|
|
|
struct log log;
|
|
|
|
struct api api;
|
|
|
|
struct web web;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-03-06 08:59:28 -04:00
|
|
|
struct {
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
} cli;
|
2017-05-05 19:24:16 +00:00
|
|
|
|
2017-03-11 23:50:30 -03:00
|
|
|
enum state state;
|
2017-02-18 10:31:42 -05:00
|
|
|
|
2017-03-05 10:06:32 -04:00
|
|
|
config_t cfg; /**< Pointer to configuration file */
|
2017-02-18 10:31:42 -05:00
|
|
|
json_t *json; /**< JSON representation of the same config. */
|
|
|
|
};
|
2014-06-05 09:34:52 +00:00
|
|
|
|
2016-02-04 16:27:14 +01:00
|
|
|
/* Compatibility with libconfig < 1.5 */
|
|
|
|
#if (LIBCONFIG_VER_MAJOR <= 1) && (LIBCONFIG_VER_MINOR < 5)
|
|
|
|
#define config_setting_lookup config_lookup_from
|
|
|
|
#endif
|
|
|
|
|
2017-02-18 10:31:42 -05:00
|
|
|
/** Inititalize configuration object before parsing the configuration. */
|
2017-03-12 17:01:24 -03:00
|
|
|
int super_node_init(struct super_node *sn);
|
2016-07-14 09:47:00 +02:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
/** Wrapper for super_node_parse() */
|
|
|
|
int super_node_parse_cli(struct super_node *sn, int argc, char *argv[]);
|
2017-02-18 10:31:42 -05:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
/** Wrapper for super_node_parse() */
|
|
|
|
int super_node_parse_uri(struct super_node *sn, const char *uri);
|
2017-02-18 10:31:42 -05:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
/** Parse super-node configuration.
|
2014-06-05 09:34:52 +00:00
|
|
|
*
|
2017-03-12 17:01:24 -03:00
|
|
|
* @param sn The super-node datastructure to fill.
|
|
|
|
* @param cfg A libconfig setting object.
|
2014-07-14 11:49:44 +00:00
|
|
|
* @retval 0 Success. Everything went well.
|
|
|
|
* @retval <0 Error. Something went wrong.
|
2014-06-05 09:34:52 +00:00
|
|
|
*/
|
2017-03-12 17:01:24 -03:00
|
|
|
int super_node_parse(struct super_node *sn, config_setting_t *cfg);
|
|
|
|
|
|
|
|
/** Check validity of super node configuration. */
|
|
|
|
int super_node_check(struct super_node *sn);
|
2017-03-06 08:59:28 -04:00
|
|
|
|
2017-03-12 17:01:24 -03:00
|
|
|
/** Initialize after parsing the configuration file. */
|
|
|
|
int super_node_start(struct super_node *sn);
|
|
|
|
|
|
|
|
int super_node_stop(struct super_node *sn);
|
|
|
|
|
|
|
|
/** Desctroy configuration object. */
|
|
|
|
int super_node_destroy(struct super_node *sn);
|