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

command descriptions updated

parent 25b23b56
No related branches found
No related tags found
No related merge requests found
...@@ -5,12 +5,11 @@ const chalk = require("chalk"); ...@@ -5,12 +5,11 @@ const chalk = require("chalk");
const handleErrors = require("../utils/handleErrors"); const handleErrors = require("../utils/handleErrors");
module.exports.command = "init"; module.exports.command = "init";
module.exports.describe = "test commands"; module.exports.describe = "Sets up five nodes (VMs 2 through 6) in a group, with VM 1 as the introducer.";
module.exports.builder = (yargs: any) => yargs; module.exports.builder = (yargs: any) => yargs;
const PORT = 20000; const PORT = 20000;
const MULTICAST_ADDR = "233.255.255.255";
const HOST = "172.22.156.15"; const HOST = "172.22.156.15";
const dgram = require("dgram"); const dgram = require("dgram");
......
...@@ -5,12 +5,11 @@ const chalk = require("chalk"); ...@@ -5,12 +5,11 @@ const chalk = require("chalk");
const handleErrors = require("../utils/handleErrors"); const handleErrors = require("../utils/handleErrors");
module.exports.command = "join [number]"; module.exports.command = "join [number]";
module.exports.describe = "test commands"; module.exports.describe = "Adds the specified VM to the group";
module.exports.builder = (yargs: any) => yargs; module.exports.builder = (yargs: any) => yargs;
const PORT = 20000; const PORT = 20000;
const MULTICAST_ADDR = "233.255.255.255";
const HOST = "172.22.156.15"; const HOST = "172.22.156.15";
const dgram = require("dgram"); const dgram = require("dgram");
......
...@@ -5,7 +5,7 @@ const chalk = require("chalk"); ...@@ -5,7 +5,7 @@ const chalk = require("chalk");
const handleErrors = require("../utils/handleErrors"); const handleErrors = require("../utils/handleErrors");
module.exports.command = "leave [number]"; module.exports.command = "leave [number]";
module.exports.describe = "test commands"; module.exports.describe = "Voluntarily removal of the specified VM from group";
module.exports.builder = (yargs: any) => yargs; module.exports.builder = (yargs: any) => yargs;
...@@ -21,7 +21,6 @@ const socket = dgram.createSocket({ type: "udp4", reuseAddr: true }); ...@@ -21,7 +21,6 @@ const socket = dgram.createSocket({ type: "udp4", reuseAddr: true });
socket.bind(PORT); socket.bind(PORT);
function sendMessage(number) { function sendMessage(number) {
// console.log(number)
const message = Buffer.from(`leave ${number}`); const message = Buffer.from(`leave ${number}`);
socket.send(message, 0, message.length, PORT, HOST, function() {}); socket.send(message, 0, message.length, PORT, HOST, function() {});
} }
......
...@@ -5,14 +5,13 @@ const chalk = require("chalk"); ...@@ -5,14 +5,13 @@ const chalk = require("chalk");
const handleErrors = require("../utils/handleErrors"); const handleErrors = require("../utils/handleErrors");
module.exports.command = "list [number]"; module.exports.command = "list [number]";
module.exports.describe = "test commands"; module.exports.describe = "Lists the membership list local the specified VM.";
module.exports.builder = (yargs: any) => yargs; module.exports.builder = (yargs: any) => yargs;
const PORT = 5000; const PORT = 5000;
const MULTICAST_ADDR = "233.255.255.255";
const HOST = "172.22.158.17"; const HOST = "172.22.158.17";
// const HOST = "fa18-cs425-g05-02.cs.illinois.edu";
const dgram = require("dgram"); const dgram = require("dgram");
const process = require("process"); const process = require("process");
...@@ -35,9 +34,7 @@ const machineToIps = { ...@@ -35,9 +34,7 @@ const machineToIps = {
socket.bind(PORT); socket.bind(PORT);
socket.on("listening", function() { socket.on("listening", function() {
socket.addMembership(MULTICAST_ADDR);
socket.setBroadcast(true); socket.setBroadcast(true);
// setInterval(sendMessage, 2500);
const address = socket.address(); const address = socket.address();
console.log( console.log(
`UDP socket listening on ${address.address}:${address.port} pid: ${ `UDP socket listening on ${address.address}:${address.port} pid: ${
...@@ -46,11 +43,6 @@ socket.on("listening", function() { ...@@ -46,11 +43,6 @@ socket.on("listening", function() {
); );
}); });
socket.on("message", function(message, rinfo) {
console.log("GOT message")
// const parsedMessage = JSON.parse(message);
// Object.keys(JSON.parse(message)).map(key => console.log(key + " " + parsedMessage[key]["status"]))
});
function sendMessage(host, number) { function sendMessage(host, number) {
const message = Buffer.from(`list`); const message = Buffer.from(`list`);
...@@ -62,5 +54,4 @@ module.exports.handler = handleErrors(async (argv: {}) => { ...@@ -62,5 +54,4 @@ module.exports.handler = handleErrors(async (argv: {}) => {
console.log("Sending message to introducer"); console.log("Sending message to introducer");
let number = argv.number; let number = argv.number;
await sendMessage(machineToIps[number], number); await sendMessage(machineToIps[number], number);
// process.exit(0);
}); });
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