From 2708f0fa63f7cc2f382ae542c6adf7ace7ffc94d Mon Sep 17 00:00:00 2001 From: arshiam2 <arshiam2@illinois.edu> Date: Sat, 1 Dec 2018 22:13:55 -0600 Subject: [PATCH] update --- sfds/index.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sfds/index.js b/sfds/index.js index 4bd4d9e..539070d 100644 --- a/sfds/index.js +++ b/sfds/index.js @@ -10,7 +10,6 @@ const fetch = require("node-fetch"); const resolver = require("./topology"); - var app = express(); app.use(bodyParser.json()); // support json encoded bodies app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies @@ -399,13 +398,13 @@ queue = []; results = []; app.post("/bolt", function(req, res) { - console.log("bolt state: " +req.body.state) + console.log("bolt state: " + req.body.state); res.send(resolver(req.body)); }); app.post("/spout", function(req, res) { - console.log("spout got: " + req.body.state) - queue.push(req.body) + console.log("spout got: " + req.body.state); + queue.push(req.body); res.send("got it"); }); @@ -417,13 +416,15 @@ app.get("/sink", function(req, res) { } }); - -round_robin = 0 +round_robin = 0; setInterval(function sync() { if (queue.length > 0) { const body = queue.pop(); - let url = "http://" + machineToIps[clients[round_robin % clients.length] ] + ":3000/bolt/"; + let url = + "http://" + + machineToIps[clients[round_robin % clients.length]] + + ":3000/bolt/"; round_robin += 1; fetch(url, { method: "post", @@ -435,12 +436,11 @@ setInterval(function sync() { if (json.action !== "END") { queue.push(json); } else { - results.push(json.state) + results.push(json.state); console.log("result: " + json.state); } }); } - }, 250); http.createServer(app).listen(3000, machineToIps[process.env.VM], function() { -- GitLab