diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-11-15 20:56:40 +0100 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-11-15 20:56:40 +0100 |
commit | 9594857ea2b95675fc8c393aa4da21baa3d0f7f8 (patch) | |
tree | 20322af94fb9d25119b84500601d423360853b84 | |
parent | 8a008f55fa16b4388e49a21301bf84c7e4a2b2f7 (diff) | |
download | biruda-9594857ea2b95675fc8c393aa4da21baa3d0f7f8.tar.gz biruda-9594857ea2b95675fc8c393aa4da21baa3d0f7f8.tar.bz2 |
..
-rw-r--r-- | PROTOCOL | 4 | ||||
-rw-r--r-- | src/GNUmakefile | 7 | ||||
-rw-r--r-- | src/coordinator.c | 1 | ||||
-rw-r--r-- | src/master.c | 2 | ||||
-rw-r--r-- | src/worker.c | 22 | ||||
-rw-r--r-- | src/worker.h | 4 | ||||
-rw-r--r-- | src/workertest.c | 26 |
7 files changed, 62 insertions, 4 deletions
@@ -20,10 +20,11 @@ setup). Operations: Discovery: +---------- Master sends: -{ "op": "discover" } +{ "op": "discover", "role": "master" } Coordinators answer with: @@ -38,4 +39,3 @@ On receiving a 'register' operation the master must handle accordingly, usually adding the coordinator as known and alive and provide new platforms and architectures to run workers on. Also currently scheduled jobs must be examined. - diff --git a/src/GNUmakefile b/src/GNUmakefile index 5b99579..3e84523 100644 --- a/src/GNUmakefile +++ b/src/GNUmakefile @@ -1,9 +1,10 @@ .PHONY: all clean install -all: biruda +all: biruda workertest CFLAGS = -g -O0 -std=c99 -Wall -pedantic -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE CFLAGS += -I/usr/local/include -I3rdParty/linenoise -I3rdParty/http_tiny +CFLAGS += `pkg-config --cflags glib-2.0` LDFLAGS = -L/usr/local/lib LIBS = -lconfuse -lpthread -lnanomsg -ljson-c -lmicrohttpd @@ -29,10 +30,14 @@ biruda_cmdline.c: biruda.ggo biruda_cmdline.h: biruda.ggo gengetopt -F biruda_cmdline --unamed-opts --conf-parser --include-getopt -i $< +workertest: workertest.o +workertest.o: workertest.c + clean: @-rm *.o @-rm biruda @-rm biruda_cmdline.[ch] + @-rm workertest # default values DESTDIR ?= diff --git a/src/coordinator.c b/src/coordinator.c index 361de48..b88313e 100644 --- a/src/coordinator.c +++ b/src/coordinator.c @@ -183,5 +183,4 @@ int coordinator_free( ) } return 0; - } diff --git a/src/master.c b/src/master.c index 3cd2173..84fd062 100644 --- a/src/master.c +++ b/src/master.c @@ -105,6 +105,8 @@ NEXT_DISCOVER: json_object *obj = json_object_new_object( ); json_object *op = json_object_new_string( "discover" ); json_object_object_add( obj, "op", op ); + json_object *role = json_object_new_string( "master" ); + json_object_object_add( obj, "role", role ); const char *msg = json_object_to_json_string( obj ); int msg_size = strlen( msg ) + 1; printf( "master send: %s\n", msg ); diff --git a/src/worker.c b/src/worker.c index 7560393..7c538d2 100644 --- a/src/worker.c +++ b/src/worker.c @@ -1 +1,23 @@ #include "worker.h" + +#include "nanomsg/nn.h" + +#include <glib.h> + +int worker_init( const char *control ) +{ + //~ gboolean ret = g_spawn_async_with_pipes( NULL, +//~ ret = g_spawn_async_with_pipes( NULL, argv, NULL, + //~ G_SPAWN_DO_NOT_REAP_CHILD, NULL, + //~ NULL, &pid, NULL, &out, &err, NULL ); + return 0; +} + +void worker_terminate( ) +{ +} + +int worker_free( ) +{ + return 0; +} diff --git a/src/worker.h b/src/worker.h index 799ef9c..d0ca595 100644 --- a/src/worker.h +++ b/src/worker.h @@ -1,4 +1,8 @@ #ifndef _BIRUDA_WORKER_HEADER_INCLUDED #define _BIRUDA_WORKER_HEADER_INCLUDED +int worker_init( const char *control ); +void worker_terminate( ); +int worker_free( ); + #endif diff --git a/src/workertest.c b/src/workertest.c new file mode 100644 index 0000000..ecc980e --- /dev/null +++ b/src/workertest.c @@ -0,0 +1,26 @@ +#include <stdio.h> + +#include "port.h" + +#define RUN_TIME 60 + +int main( void ) +{ + for( int i = 0; i < RUN_TIME; i++ ) { + char msg[1024]; + + snprintf( msg, sizeof( msg ), "Msg %d\n", i ); + + if( i % 3 == 0 ) { + fputs( msg, stderr ); + fflush( stderr ); + } else { + fputs( msg, stdout ); + fflush( stdout ); + } + + sleep( 1 ); + } + + return 0; +} |