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 @@ ...@@ -3,14 +3,14 @@
* Notice: © Copyright 2020 Naman Dixit * Notice: © Copyright 2020 Naman Dixit
*/ */
#define logMessage(s, ...) printf(s "\n", ##__VA_ARGS__) #define logMessage(s, ...) say(s "\n", ##__VA_ARGS__)
#define logError(s, ...) fprintf(stderr, s "\n", ##__VA_ARGS__) #define logError(s, ...) err(s "\n", ##__VA_ARGS__)
#include "nlib/nlib.h" #include "nlib/nlib.h"
#include <stdio.h> #undef internal_malloc
#include <stdlib.h> #undef internal_free
#include <string.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/epoll.h> #include <sys/epoll.h>
#include <netdb.h> #include <netdb.h>
...@@ -66,6 +66,12 @@ Sint main (Sint argc, Char *argv[]) ...@@ -66,6 +66,12 @@ Sint main (Sint argc, Char *argv[])
signal(SIGINT, signalHandlerSIGINT); signal(SIGINT, signalHandlerSIGINT);
{ // Init cJSON
cJSON_Hooks hook = {.malloc_fn = dlmalloc,
.free_fn = dlfree};
cJSON_InitHooks(&hook);
}
Configuration conf = {0}; Configuration conf = {0};
{ // Default config values { // Default config values
conf.kafka_address = "10.129.6.5:9092"; conf.kafka_address = "10.129.6.5:9092";
......
...@@ -22,18 +22,18 @@ Sint confCallback (void* user, const Char *section, ...@@ -22,18 +22,18 @@ Sint confCallback (void* user, const Char *section,
{ {
Configuration* conf = (Configuration*)user; Configuration* conf = (Configuration*)user;
if (strequal(section, "Arbiter")) { if (stringEqual(section, "Arbiter")) {
if (strequal(name, "MessageReadGap")) { if (stringEqual(name, "MessageReadGap")) {
conf->message_read_gap = atoi(value); conf->message_read_gap = atoi(value);
} else if (strequal(name, "GruntTimeToDie")) { } else if (stringEqual(name, "GruntTimeToDie")) {
conf->grunt_time_to_die = atoi(value); 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); conf->grunt_response_wait_time = strtoul(value, NULL, 10);
} else { } else {
return 0; /* unknown section/name, error */ return 0; /* unknown section/name, error */
} }
} else if (strequal(section, "Kafka")) { } else if (stringEqual(section, "Kafka")) {
if (strequal(name, "Address")) { if (stringEqual(name, "Address")) {
conf->kafka_address = strdup(value); conf->kafka_address = strdup(value);
} else { } else {
return 0; /* unknown section/name, error */ return 0; /* unknown section/name, error */
......
Subproject commit 75bc1a11e2a10cf249f566b40c85d6526c16f123 Subproject commit f71785e7c6a820e65c450d526c60519b250f3115
...@@ -21,16 +21,16 @@ Sint confCallback (void* user, const Char *section, ...@@ -21,16 +21,16 @@ Sint confCallback (void* user, const Char *section,
{ {
Configuration* conf = (Configuration*)user; Configuration* conf = (Configuration*)user;
if (strequal(section, "Grunt")) { if (stringEqual(section, "Grunt")) {
if (strequal(name, "MessageReadGap")) { if (stringEqual(name, "MessageReadGap")) {
conf->message_read_gap = atoi(value); conf->message_read_gap = atoi(value);
} else if (strequal(name, "HeartbeatGap")) { } else if (stringEqual(name, "HeartbeatGap")) {
conf->heartbeat_gap = strtoul(value, NULL, 10); conf->heartbeat_gap = strtoul(value, NULL, 10);
} else { } else {
return 0; /* unknown section/name, error */ return 0; /* unknown section/name, error */
} }
} else if (strequal(section, "Kafka")) { } else if (stringEqual(section, "Kafka")) {
if (strequal(name, "Address")) { if (stringEqual(name, "Address")) {
conf->kafka_address = strdup(value); conf->kafka_address = strdup(value);
} else { } else {
return 0; /* unknown section/name, error */ return 0; /* unknown section/name, error */
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
#include "nlib/nlib.h" #include "nlib/nlib.h"
#include <stdio.h> #undef internal_malloc
#include <stdlib.h> #undef internal_free
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
...@@ -113,6 +113,18 @@ int main(int argc, char** argv) ...@@ -113,6 +113,18 @@ int main(int argc, char** argv)
signal(SIGINT, signalHandlerSIGINT); 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}; Configuration conf = {0};
{ // Default config values { // Default config values
conf.kafka_address = "10.129.6.5:9092"; conf.kafka_address = "10.129.6.5:9092";
...@@ -251,7 +263,7 @@ int main(int argc, char** argv) ...@@ -251,7 +263,7 @@ int main(int argc, char** argv)
} else if (kafka_message_read->rkt == topic_rej_a2g) { } else if (kafka_message_read->rkt == topic_rej_a2g) {
Char *node_id = cJSON_GetObjectItem(root, "node_id")->valuestring; Char *node_id = cJSON_GetObjectItem(root, "node_id")->valuestring;
if (strequal(node_id, node_name)) { if (stringEqual(node_id, node_name)) {
join_successful = false; join_successful = false;
Sint timestamp = (Sint)time(0); Sint timestamp = (Sint)time(0);
...@@ -267,9 +279,9 @@ int main(int argc, char** argv) ...@@ -267,9 +279,9 @@ int main(int argc, char** argv)
} else if (kafka_message_read->rkt == topic_log) { } else if (kafka_message_read->rkt == topic_log) {
cJSON *msg_type_json = cJSON_GetObjectItem(root, "message_type"); cJSON *msg_type_json = cJSON_GetObjectItem(root, "message_type");
if (msg_type_json == NULL) { 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; 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 *resource_id = cJSON_GetObjectItem(root, "resource_id")->valuestring;
Char *entity_id = cJSON_GetObjectItem(root, "entity_id")->valuestring; Char *entity_id = cJSON_GetObjectItem(root, "entity_id")->valuestring;
Char *entity_type = cJSON_GetObjectItem(root, "entity_type")->valuestring; Char *entity_type = cJSON_GetObjectItem(root, "entity_type")->valuestring;
...@@ -278,7 +290,7 @@ int main(int argc, char** argv) ...@@ -278,7 +290,7 @@ int main(int argc, char** argv)
.resource_id = strdup(resource_id)}; .resource_id = strdup(resource_id)};
B32 add_command = false; B32 add_command = false;
if (strequal(entity_type, "docker")) { if (stringEqual(entity_type, "docker")) {
tmc.kind = Thread_Manager_Command_DOCKER_CREATE; tmc.kind = Thread_Manager_Command_DOCKER_CREATE;
add_command = true; add_command = true;
} }
......
...@@ -10,9 +10,9 @@ ...@@ -10,9 +10,9 @@
#include "nlib/nlib.h" #include "nlib/nlib.h"
#include <stdio.h> #undef internal_malloc
#include <stdlib.h> #undef internal_free
#include <string.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.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