-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNodeImpl.java
More file actions
39 lines (32 loc) · 1.04 KB
/
NodeImpl.java
File metadata and controls
39 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.rmi.*;
import java.net.*;
/*
* Implementation of Node Interface.
*/
class NodeLinkingException extends Exception {
private static final long serialVersionUID = 1L;
}
public class NodeImpl implements Node {
private static final long serialVersionUID = 1L;
// Global reference to container
private AgentContainer container;
public NodeImpl(int index) throws NodeLinkingException {
try {
container = (AgentContainer)Naming.lookup("rmi://127.0.0.1/container"+index);
System.out.println(container);
} catch (RemoteException e) {
System.err.println("Registry could not be contacted");
throw new NodeLinkingException();
} catch (MalformedURLException e) {
System.err.println("Wrong URL for binding");
throw new NodeLinkingException();
} catch (NotBoundException e) {
System.err.println("Object not bound");
throw new NodeLinkingException();
}
}
// Implementation of migrate method
public void migrate(Agent agent) throws RemoteException {
container.migrate(agent);
}
}