+/EE360P

distributed systems

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

vijaygarg1included dependenciesde0e46f

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