diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-05 12:31:14 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-12-05 12:31:14 +0100 |
commit | b64f784061d7576716d66e6f637d2827b46b2587 (patch) | |
tree | 02627e118700c2b1e68dbb016c3652454b2aaf7b | |
parent | 9d44c565a7e9ded7eea2a8df7665518c622d02d0 (diff) | |
download | biruda-b64f784061d7576716d66e6f637d2827b46b2587.tar.gz biruda-b64f784061d7576716d66e6f637d2827b46b2587.tar.bz2 |
better configration testing, added 'data' channel
-rw-r--r-- | src/biruda.c | 45 | ||||
-rw-r--r-- | src/biruda.conf | 24 |
2 files changed, 65 insertions, 4 deletions
diff --git a/src/biruda.c b/src/biruda.c index 0e0379c..834b72f 100644 --- a/src/biruda.c +++ b/src/biruda.c @@ -77,10 +77,49 @@ static int conf_validate_worker_execution( cfg_t *cfg, cfg_opt_t *opt, const cha return 0; } +static int conf_validate_master( cfg_t *cfg, cfg_opt_t *opt ) +{ + cfg_t *master = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 ); + + if( cfg_size( master, "control" ) == 0 ) { + cfg_error( cfg, "missing required option 'control' for master" ); + return -1; + } + + if( cfg_size( master, "data" ) == 0 ) { + cfg_error( cfg, "missing required option 'data' for master" ); + return -1; + } + + return 0; +} + +static int conf_validate_coordinator( cfg_t *cfg, cfg_opt_t *opt ) +{ + cfg_t *coordinator = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 ); + + if( cfg_size( coordinator, "control" ) == 0 ) { + cfg_error( cfg, "missing required option 'control' for coordinator" ); + return -1; + } + + return 0; +} + static int conf_validate_worker( cfg_t *cfg, cfg_opt_t *opt ) { cfg_t *worker = cfg_opt_getnsec( opt, cfg_opt_size( opt ) - 1 ); + if( cfg_size( worker, "control" ) == 0 ) { + cfg_error( cfg, "missing required option 'control' for worker" ); + return -1; + } + + if( cfg_size( worker, "data" ) == 0 ) { + cfg_error( cfg, "missing required option 'data' for worker" ); + return -1; + } + worker_execution_mode_t mode = (worker_execution_mode_t)cfg_getint( worker, "execution" ); switch( mode ) { @@ -103,6 +142,7 @@ static int read_config( const char *filename, cfg_t **cfg ) { cfg_opt_t opts_master[] = { CFG_STR( "control", 0, CFGF_NODEFAULT ), + CFG_STR( "data", 0, CFGF_NODEFAULT ), CFG_END( ) }; @@ -113,6 +153,7 @@ static int read_config( const char *filename, cfg_t **cfg ) cfg_opt_t opts_worker[] = { CFG_STR( "control", 0, CFGF_NODEFAULT ), + CFG_STR( "data", 0, CFGF_NODEFAULT ), CFG_INT_CB( "execution", WORKER_EXECUTION_DISABLED, CFGF_NONE, &conf_validate_worker_execution ), CFG_STR( "command", NULL, CFGF_NODEFAULT ), CFG_END( ) @@ -135,6 +176,8 @@ static int read_config( const char *filename, cfg_t **cfg ) *cfg = cfg_init( opts, CFGF_NONE ); + cfg_set_validate_func( *cfg, "master", &conf_validate_master ); + cfg_set_validate_func( *cfg, "coordinator", &conf_validate_coordinator ); cfg_set_validate_func( *cfg, "worker", &conf_validate_worker ); switch( cfg_parse( *cfg, filename ) ) { @@ -171,6 +214,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg ) if( has_master ) { puts( "Master:" ); printf( " Control channel: %s\n", cfg_getstr( master_cfg, "control" ) ); + printf( " Data channel: %s\n", cfg_getstr( master_cfg, "data" ) ); puts( "" ); } @@ -190,6 +234,7 @@ static void print_config( struct gengetopt_args_info *args_info, cfg_t *cfg ) printf( " Worker %s:\n", cfg_title( worker_cfg ) ); printf( " Control channel: %s\n", cfg_getstr( worker_cfg, "control" ) ); + printf( " Data channel: %s\n", cfg_getstr( worker_cfg, "data" ) ); printf( " Execution mode: %s\n", worker_exection_mode_str( (worker_execution_mode_t)cfg_getint( worker_cfg, "execution" ) ) ); if( cfg_getint( worker_cfg, "execution" ) == WORKER_EXECUTION_DIRECT ) { char *command = cfg_getstr( worker_cfg, "command" ); diff --git a/src/biruda.conf b/src/biruda.conf index 3f3fed5..9269bab 100644 --- a/src/biruda.conf +++ b/src/biruda.conf @@ -2,33 +2,49 @@ master { -# control = "ipc:///tmp/biruda.ipc" +# control = "ipc:///tmp/biruda_control.ipc" # control = "inproc://control" control = "tcp://*:5555" + +# data = "ipc:///tmp/biruda_data.ipc" +# data = "inproc://data" + data = "tcp://*:5556" } coordinator { -# control = "ipc:///tmp/biruda.ipc" +# control = "ipc:///tmp/biruda_control.ipc" # control = "inproc://control" control = "tcp://localhost:5555" } worker worker1 { -# control = "ipc:///tmp/biruda.ipc" +# control = "ipc:///tmp/biruda_control.ipc" # control = "inproc://control" control = "tcp://localhost:5555" + +# data = "ipc:///tmp/biruda_data.ipc" +# data = "inproc://data" + data = "tcp://localhost:5556" + execution = direct + command = "./workertest 60" # command = "workertest.exe 60" } worker worker2 { -# control = "ipc:///tmp/biruda.ipc" +# control = "ipc:///tmp/biruda_control.ipc" # control = "inproc://control" control = "tcp://localhost:5555" + +# data = "ipc:///tmp/biruda_data.ipc" +# data = "inproc://data" + data = "tcp://localhost:5556" + + execution = disabled } webserver |