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