+/EE360P

distributed systems

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

vijaygarg1fixed blockingFind bug3480f4c

master
1.1 KiB35 linesraw
1import java.rmi.*;
2import java.rmi.server.UnicastRemoteObject;
3import java.net.*;
4public class NameServiceImpl extends UnicastRemoteObject
5        implements NameService {
6    NameTable table;
7    public NameServiceImpl() throws RemoteException {
8	table = new NameTable();
9    }
10    public InetSocketAddress search(String s) throws RemoteException {
11        return table.search(s);
12    }
13    public InetSocketAddress blockingFind(String s) throws RemoteException {
14        return table.blockingFind(s);
15    }
16    public int insert(String s, String hostName, int portNumber)
17            throws RemoteException {
18            return table.insert(s, hostName, portNumber);
19    }
20    public static void main(String args[]) {
21        // create security manager
22	if (System.getSecurityManager() == null) {
23        	System.setSecurityManager(new SecurityManager());
24    	}
25
26        try {
27            NameServiceImpl obj = new NameServiceImpl();
28            Naming.rebind("MyNameServer", obj);
29            System.out.println("MyNameServer bound in registry");
30        } catch (Exception e) {
31            System.out.println("NameServiceImpl err: " + e.getMessage());
32        }
33    }
34}
35