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