Commit 9c058045 authored by Naman Dixit's avatar Naman Dixit

Consistent message formatting

parent bcc9d84a
...@@ -367,14 +367,14 @@ Sint main (Sint argc, Char *argv[]) ...@@ -367,14 +367,14 @@ Sint main (Sint argc, Char *argv[])
topic = "REQUEST_RM_2_RD"; topic = "REQUEST_RM_2_RD";
sbufPrint(output, "{\n\"resource_id\": \"%s\"", c.resource_id); sbufPrint(output, "{\n\"resource_id\": \"%s\"", c.resource_id);
sbufPrint(output, ",\n\"memory\": %d\n", c.req_a2g.memory); sbufPrint(output, ",\n\"memory\": %d", c.req_a2g.memory);
sbufPrint(output, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(output, ",\n\"timestamp\": %d", timestamp);
sbufPrint(output, "\n}\n"); sbufPrint(output, "\n}\n");
} else if (c.kind == Command_RESPONSE_ARBITER_2_DM) { } else if (c.kind == Command_RESPONSE_ARBITER_2_DM) {
topic = "RESPONSE_RM_2_DM"; topic = "RESPONSE_RM_2_DM";
sbufPrint(output, "{\n\"resource_id\": \"%s\"", c.resource_id); sbufPrint(output, "{\n\"resource_id\": \"%s\"", c.resource_id);
sbufPrint(output, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(output, ",\n\"timestamp\": %d", timestamp);
sbufPrint(output, ",\n\"nodes\": ["); sbufPrint(output, ",\n\"nodes\": [");
for (Size k = 0; k < sbufElemin(c.res_a2d.grunt_ids); k++) { for (Size k = 0; k < sbufElemin(c.res_a2d.grunt_ids); k++) {
sbufPrint(output, "\"%s\"", c.res_a2d.grunt_ids[k]); sbufPrint(output, "\"%s\"", c.res_a2d.grunt_ids[k]);
...@@ -388,7 +388,7 @@ Sint main (Sint argc, Char *argv[]) ...@@ -388,7 +388,7 @@ Sint main (Sint argc, Char *argv[])
topic = "REJOIN_RM_2_RD"; topic = "REJOIN_RM_2_RD";
sbufPrint(output, "{\n\"node_id\": \"%s\"", c.rejoin_a2g.grunt_id); sbufPrint(output, "{\n\"node_id\": \"%s\"", c.rejoin_a2g.grunt_id);
sbufPrint(output, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(output, ",\n\"timestamp\": %d", timestamp);
sbufPrint(output, "\n}"); sbufPrint(output, "\n}");
free(c.rejoin_a2g.grunt_id); free(c.rejoin_a2g.grunt_id);
......
...@@ -153,7 +153,7 @@ int main(int argc, char** argv) ...@@ -153,7 +153,7 @@ int main(int argc, char** argv)
Sint timestamp = (Sint)time(0); Sint timestamp = (Sint)time(0);
Char *join_msg = NULL; Char *join_msg = NULL;
sbufPrint(join_msg, "{\"node_id\": \"%s\"", node_name); sbufPrint(join_msg, "{\"node_id\": \"%s\"", node_name);
sbufPrint(join_msg, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(join_msg, ",\n\"timestamp\": %d", timestamp);
sbufPrint(join_msg, "\n}\n"); sbufPrint(join_msg, "\n}\n");
if (!kafkaWrite(kafka.writer, "JOIN_RD_2_RM", "resource_daemon", join_msg)) { if (!kafkaWrite(kafka.writer, "JOIN_RD_2_RM", "resource_daemon", join_msg)) {
...@@ -210,7 +210,7 @@ int main(int argc, char** argv) ...@@ -210,7 +210,7 @@ int main(int argc, char** argv)
Sint timestamp = (Sint)time(0); Sint timestamp = (Sint)time(0);
Char *rejoin_msg = NULL; Char *rejoin_msg = NULL;
sbufPrint(rejoin_msg, "{\"node_id\": \"%s\"", node_name); sbufPrint(rejoin_msg, "{\"node_id\": \"%s\"", node_name);
sbufPrint(rejoin_msg, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(rejoin_msg, ",\n\"timestamp\": %d", timestamp);
sbufPrint(rejoin_msg, "\n}\n"); sbufPrint(rejoin_msg, "\n}\n");
if (!kafkaWrite(kafka.writer, "JOIN_RD_2_RM", "resource_daemon", rejoin_msg)) { if (!kafkaWrite(kafka.writer, "JOIN_RD_2_RM", "resource_daemon", rejoin_msg)) {
...@@ -267,12 +267,12 @@ int main(int argc, char** argv) ...@@ -267,12 +267,12 @@ int main(int argc, char** argv)
sbufPrint(output, "{\n\"node_id\": \"%s\"", node_name); sbufPrint(output, "{\n\"node_id\": \"%s\"", node_name);
sbufPrint(output, ",\n\"resource_id\": \"%s\"", c.txn_id); sbufPrint(output, ",\n\"resource_id\": \"%s\"", c.txn_id);
sbufPrint(output, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(output, ",\n\"timestamp\": %d", timestamp);
if (memory >= c.res.memory) { if (memory >= c.res.memory) {
sbufPrint(output, ",\n\"success\": true\n"); sbufPrint(output, ",\n\"success\": true\n");
// TODO(naman): Add port // TODO(naman): Add port
// sbufPrint(output, ",\n\"port\": %d\n", port); // sbufPrint(output, ",\n\"port\": %d", port);
} else { } else {
sbufPrint(output, ",\n\"success\": false\n"); sbufPrint(output, ",\n\"success\": false\n");
} }
...@@ -307,7 +307,7 @@ int main(int argc, char** argv) ...@@ -307,7 +307,7 @@ int main(int argc, char** argv)
Sint timestamp = (Sint)time(0); Sint timestamp = (Sint)time(0);
sbufPrint(output, "{\"node_id\": \"%s\"", node_name); sbufPrint(output, "{\"node_id\": \"%s\"", node_name);
sbufPrint(output, ",\n\"timestamp\": %d\n", timestamp); sbufPrint(output, ",\n\"timestamp\": %d", timestamp);
sbufPrint(output, ",\n\"memory\": %d", memory); sbufPrint(output, ",\n\"memory\": %d", memory);
sbufPrint(output, "\n}\n"); sbufPrint(output, "\n}\n");
......
...@@ -85,6 +85,7 @@ int main(int argc, char** argv) ...@@ -85,6 +85,7 @@ int main(int argc, char** argv)
Sint id = (Sint)time(NULL); Sint id = (Sint)time(NULL);
sbufPrint(output, "{\n\"resource_id\": \"%d\"", id); sbufPrint(output, "{\n\"resource_id\": \"%d\"", id);
sbufPrint(output, ",\n\"timestamp\": %d", id);
sbufPrint(output, ",\n\"memory\": %d", memory_required); sbufPrint(output, ",\n\"memory\": %d", memory_required);
sbufPrint(output, "\n}\n"); sbufPrint(output, "\n}\n");
......
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