From 73c12a15e420bf0072fee3d7936ae96be35e6eab Mon Sep 17 00:00:00 2001 From: arshiam2 <arshiam2@illinois.edu> Date: Sat, 1 Dec 2018 21:59:33 -0600 Subject: [PATCH] update --- cli/src/commands/get-stream.js | 44 ++++++++++++++++++++++++++++++++++ cli/src/commands/put-stream.js | 6 +++-- sfds/index.js | 4 ++++ 3 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 cli/src/commands/get-stream.js diff --git a/cli/src/commands/get-stream.js b/cli/src/commands/get-stream.js new file mode 100644 index 0000000..6b9b7ee --- /dev/null +++ b/cli/src/commands/get-stream.js @@ -0,0 +1,44 @@ +// @flow +const path = require("path"); +const chalk = require("chalk"); +const fs = require("fs"); +const util = require("util"); +const net = require("net"); +const process = require("process"); +var request = require("request"); +var csv = require("csv-stream"); +const fetch = require("node-fetch"); + +const handleErrors = require("../utils/handleErrors"); +const getMaster = require("../utils/getMaster"); + +module.exports.command = "put-stream"; +module.exports.describe = "Writes localfilename to the SDFS as sdfsfilename."; +module.exports.builder = (yargs: any) => yargs; + + + +module.exports.handler = handleErrors(async (argv: {}) => { + const master = await getMaster(); + getCSVdata(); + + setInterval(function sync() { + // if (queue.length > 0) { + // const body = queue.pop(); + var target = "http://"+ master + ":3000/sink/"; + // console.log(target) + // console.log(JSON.stringify(body).state) + fetch(target) + .then(res => console.log(res.text())) + // .then(json => { + // // if (json.action !== "END") { + // // queue.push(json); + // // } else { + // // console.log(json); + // // } + // }); + // } + + }, 500); + +}); diff --git a/cli/src/commands/put-stream.js b/cli/src/commands/put-stream.js index 71f5cf7..e7bef32 100644 --- a/cli/src/commands/put-stream.js +++ b/cli/src/commands/put-stream.js @@ -40,7 +40,7 @@ async function getCSVdata() { if (messages.length == 10000) { allMessages.push(messages); const body = { action: "START", state: messages[0] }; - console.log(body) + // console.log(body) queue.push(body); messages = []; } @@ -78,7 +78,9 @@ module.exports.handler = handleErrors(async (argv: {}) => { // console.log(json); // } }); - } + } else { + process.exit() + } }, 500); diff --git a/sfds/index.js b/sfds/index.js index fcf4c41..a0e4273 100644 --- a/sfds/index.js +++ b/sfds/index.js @@ -408,6 +408,10 @@ app.post("/spout", function(req, res) { res.send("got it"); }); +app.post("/sink", function(req, res) { + // console.log("bolt state: " +req.body.state) + res.send("IM A SINK"); +}); round_robin = 0 -- GitLab