1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/include/villas/super_node.h

96 lines
2.9 KiB
C
Raw Permalink Normal View History

/** Configuration file parser.
*
* 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/
*
* @file
2015-06-02 21:53:04 +02:00
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
* @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-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-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
*********************************************************************************/
2017-02-16 09:04:12 -03:00
#pragma once
#include <libconfig.h>
2017-02-18 10:31:42 -05:00
#include "list.h"
#include "api.h"
#include "web.h"
#include "log.h"
#include "common.h"
2017-02-18 10:31:42 -05:00
/** Global configuration */
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-03-06 08:59:28 -04:00
struct {
int argc;
char **argv;
} cli;
enum state state;
2017-02-18 10:31:42 -05: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. */
};
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. */
int super_node_init(struct super_node *sn);
/** 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
/** 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
/** Parse super-node configuration.
*
* @param sn The super-node datastructure to fill.
* @param cfg A libconfig setting object.
* @retval 0 Success. Everything went well.
* @retval <0 Error. Something went wrong.
*/
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
/** 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);