Skip to content
Snippets Groups Projects
Commit 2708f0fa authored by arshiam2's avatar arshiam2
Browse files

update

parent 89e8a6f8
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment