+/EE360P

distributed systems

git clone https://git.julia.blue/+/EE360P

vijaygarg1init6bd33a4

master
851 B31 linesraw
1package dist;
2import java.io.*;
3import java.util.*;
4public class Topology {
5	// returns true if read neighbors successfully
6	public static boolean readNeighbors(int myId,
7			List<Integer> neighbors) {
8		System.out.println("Reading topology");
9		try {
10			Scanner sc = new Scanner(new FileReader("topology" + myId));
11			while (sc.hasNext()) {
12				int neighbor = sc.nextInt();
13				neighbors.add(neighbor);
14			}
15		} catch (FileNotFoundException e) {
16			return false;
17		}
18		System.out.println(neighbors.toString());
19		return true;
20	}
21	public static void setComplete(int myId,
22			List<Integer> neighbors, int numProc) {
23		for (int i = 0; i < numProc; ++i) {
24			if (i != myId) neighbors.add(i);
25		}
26	}
27	public static void main(String [] args) {
28		LinkedList<Integer> l = new LinkedList<Integer>();
29		Topology.readNeighbors(Integer.parseInt(args[0]),l);
30	}
31}