Commit 66dc57aa authored by Naman Dixit's avatar Naman Dixit

Fixed some outstanding bugs,

Reverted Prometheus related changes as unstable VPN made it hard to test them, will implement later when college starts
parent 1e2d3ca4
......@@ -3,14 +3,14 @@
* Notice: © Copyright 2020 Naman Dixit
*/
#define logMessage(s, ...) printf(s "\n", ##__VA_ARGS__)
#define logError(s, ...) fprintf(stderr, s "\n", ##__VA_ARGS__)
#define logMessage(s, ...) say(s "\n", ##__VA_ARGS__)
#define logError(s, ...) err(s "\n", ##__VA_ARGS__)
#include "nlib/nlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#undef internal_malloc
#undef internal_free
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netdb.h>
......@@ -66,6 +66,12 @@ Sint main (Sint argc, Char *argv[])
signal(SIGINT, signalHandlerSIGINT);
{ // Init cJSON
cJSON_Hooks hook = {.malloc_fn = dlmalloc,
.free_fn = dlfree};
cJSON_InitHooks(&hook);
}
Configuration conf = {0};
{ // Default config values
conf.kafka_address = "10.129.6.5:9092";
......
......@@ -22,18 +22,18 @@ Sint confCallback (void* user, const Char *section,
{
Configuration* conf = (Configuration*)user;
if (strequal(section, "Arbiter")) {
if (strequal(name, "MessageReadGap")) {
if (stringEqual(section, "Arbiter")) {
if (stringEqual(name, "MessageReadGap")) {
conf->message_read_gap = atoi(value);
} else if (strequal(name, "GruntTimeToDie")) {
} else if (stringEqual(name, "GruntTimeToDie")) {
conf->grunt_time_to_die = atoi(value);
} else if (strequal(name, "GruntResponseWaitTime")) {
} else if (stringEqual(name, "GruntResponseWaitTime")) {
conf->grunt_response_wait_time = strtoul(value, NULL, 10);
} else {
return 0; /* unknown section/name, error */
}
} else if (strequal(section, "Kafka")) {
if (strequal(name, "Address")) {
} else if (stringEqual(section, "Kafka")) {
if (stringEqual(name, "Address")) {
conf->kafka_address = strdup(value);
} else {
return 0; /* unknown section/name, error */
......
Subproject commit 75bc1a11e2a10cf249f566b40c85d6526c16f123
Subproject commit f71785e7c6a820e65c450d526c60519b250f3115
......@@ -21,16 +21,16 @@ Sint confCallback (void* user, const Char *section,
{
Configuration* conf = (Configuration*)user;
if (strequal(section, "Grunt")) {
if (strequal(name, "MessageReadGap")) {
if (stringEqual(section, "Grunt")) {
if (stringEqual(name, "MessageReadGap")) {
conf->message_read_gap = atoi(value);
} else if (strequal(name, "HeartbeatGap")) {
} else if (stringEqual(name, "HeartbeatGap")) {
conf->heartbeat_gap = strtoul(value, NULL, 10);
} else {
return 0; /* unknown section/name, error */
}
} else if (strequal(section, "Kafka")) {
if (strequal(name, "Address")) {
} else if (stringEqual(section, "Kafka")) {
if (stringEqual(name, "Address")) {
conf->kafka_address = strdup(value);
} else {
return 0; /* unknown section/name, error */
......
......@@ -5,9 +5,9 @@
#include "nlib/nlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#undef internal_malloc
#undef internal_free
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
......@@ -113,6 +113,18 @@ int main(int argc, char** argv)
signal(SIGINT, signalHandlerSIGINT);
{ // Init third party libraries
{ // Init cJSON
cJSON_Hooks hook = {.malloc_fn = dlmalloc,
.free_fn = dlfree};
cJSON_InitHooks(&hook);
}
{ // Init
prom_collector_registry_default_init();
}
}
Configuration conf = {0};
{ // Default config values
conf.kafka_address = "10.129.6.5:9092";
......@@ -251,7 +263,7 @@ int main(int argc, char** argv)
} else if (kafka_message_read->rkt == topic_rej_a2g) {
Char *node_id = cJSON_GetObjectItem(root, "node_id")->valuestring;
if (strequal(node_id, node_name)) {
if (stringEqual(node_id, node_name)) {
join_successful = false;
Sint timestamp = (Sint)time(0);
......@@ -267,9 +279,9 @@ int main(int argc, char** argv)
} else if (kafka_message_read->rkt == topic_log) {
cJSON *msg_type_json = cJSON_GetObjectItem(root, "message_type");
if (msg_type_json == NULL) {
if (strequal(msg_type_json->valuestring, "deployment_launch")) {
if (stringEqual(msg_type_json->valuestring, "deployment_launch")) {
Char *node_id = cJSON_GetObjectItem(root, "node_id")->valuestring;
if (strequal(node_id, node_name)) {
if (stringEqual(node_id, node_name)) {
Char *resource_id = cJSON_GetObjectItem(root, "resource_id")->valuestring;
Char *entity_id = cJSON_GetObjectItem(root, "entity_id")->valuestring;
Char *entity_type = cJSON_GetObjectItem(root, "entity_type")->valuestring;
......@@ -278,7 +290,7 @@ int main(int argc, char** argv)
.resource_id = strdup(resource_id)};
B32 add_command = false;
if (strequal(entity_type, "docker")) {
if (stringEqual(entity_type, "docker")) {
tmc.kind = Thread_Manager_Command_DOCKER_CREATE;
add_command = true;
}
......
......@@ -10,9 +10,9 @@
#include "nlib/nlib.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#undef internal_malloc
#undef internal_free
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment