Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 858a420

Browse filesBrowse files
author
LENOVO-PC\Vasilis
committed
more printings added
1 parent f80c7da commit 858a420
Copy full SHA for 858a420

File tree

3 files changed

+22
-2
lines changed
Filter options

3 files changed

+22
-2
lines changed

‎Assignment3/src/assignment3/node/IComponent.java

Copy file name to clipboardExpand all lines: Assignment3/src/assignment3/node/IComponent.java
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ public interface IComponent extends Remote {
1616
public void setEntities(IComponent[] entities) throws RemoteException ;
1717
public void wakeUp() throws RemoteException;
1818
public IComponent[] getEntities() throws RemoteException;
19-
19+
public int getID() throws RemoteException;
2020
}

‎Assignment3/src/assignment3/node/Node.java

Copy file name to clipboardExpand all lines: Assignment3/src/assignment3/node/Node.java
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,10 @@ public void setEntities(IComponent[] entities) throws RemoteException {
537537
public IComponent[] getEntities() throws RemoteException{
538538
return nodes;
539539
}
540+
541+
@Override
542+
public int getID() throws RemoteException {
543+
// TODO Auto-generated method stub
544+
return id;
545+
}
540546
}

‎Assignment3/src/assignment3/server/Client1.java

Copy file name to clipboardExpand all lines: Assignment3/src/assignment3/server/Client1.java
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public static void main(String[] args) throws AlreadyBoundException, NotBoundExc
3232
Registry registry = LocateRegistry.createRegistry(Constant.RMI_PORT);
3333
links = new HashMap<Integer, List<Link>>();
3434
initializeEdges();
35+
for(int k: links.keySet()){
36+
System.out.println("Node " + k + " has edges");
37+
for (Link l: links.get(k)){
38+
System.out.println("from "+l.getFrom()+ " to " + l.getTo()+ " with weight " +l.getWeight());
39+
}
40+
}
3541
// "clients" files contain the name of the remote processes used
3642
BufferedReader br = new BufferedReader(new FileReader("tests/nodes_cr4.txt"));
3743
String line = br.readLine();
@@ -68,6 +74,9 @@ public static void main(String[] args) throws AlreadyBoundException, NotBoundExc
6874
i++;
6975
}
7076
br.close();
77+
for (int id:localIDS){
78+
System.out.println("Local id "+ id);
79+
}
7180
setRegistry();
7281
System.out.println("Client 1 started");
7382
}
@@ -112,7 +121,7 @@ public static void initializeEdges() throws IOException{
112121
public static void setRegistry() throws NotBoundException, NumberFormatException, IOException, InterruptedException {
113122
Registry registry = LocateRegistry.getRegistry("localhost", Constant.RMI_PORT);
114123
RMI_IDS = new IComponent[numProc]; // the remote process array is instantiated
115-
Thread[] myThreads = new Thread[numProc]; // and numProc number of threads are created
124+
Thread[] myThreads = new Thread[localProc]; // and numProc number of threads are created
116125
boolean success;
117126
for(int i=0; i<numProc; i++){
118127
success = false;
@@ -130,6 +139,7 @@ public static void setRegistry() throws NotBoundException, NumberFormatException
130139

131140
for(int i=0; i<localProc; i++){
132141
// initialization of each remote process of the client
142+
System.out.println("Process wiht id "+ localIDS.get(i)+ " is initialized");
133143
RMI_IDS[localIDS.get(i)].setEntities(RMI_IDS);
134144
// a new runnable remote process is created and is binded with the process i
135145
RemoteProcess p = new RemoteProcess(RMI_IDS[localIDS.get(i)]);
@@ -140,6 +150,10 @@ public static void setRegistry() throws NotBoundException, NumberFormatException
140150
while(RMI_IDS[i].getEntities()==null){
141151
System.err.println("Node "+i+" not initialized yet");
142152
}
153+
System.out.println("Node " + i + " has array");
154+
for (IComponent temp: RMI_IDS[i].getEntities()){
155+
System.out.println(temp.getID());
156+
}
143157
}
144158
System.out.println("Tap when you are ready");
145159
System.in.read();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.