This commit is contained in:
parent
d6437cef33
commit
2355a6bf8a
@ -47,7 +47,7 @@ public class Nameserver implements INameserver {
|
|||||||
// Root Nameserver
|
// Root Nameserver
|
||||||
nameServerLocal = new NameServerRemote("root");
|
nameServerLocal = new NameServerRemote("root");
|
||||||
try {
|
try {
|
||||||
nameserverRemote = (INameserverRemote) UnicastRemoteObject.exportObject(nameServerLocal, registryPort);
|
nameserverRemote = (INameserverRemote) UnicastRemoteObject.exportObject(nameServerLocal, 0);
|
||||||
registry = LocateRegistry.createRegistry(registryPort);
|
registry = LocateRegistry.createRegistry(registryPort);
|
||||||
registry.rebind(registryName, nameserverRemote);
|
registry.rebind(registryName, nameserverRemote);
|
||||||
System.out.println("Nameserver bound.");
|
System.out.println("Nameserver bound.");
|
||||||
@ -62,6 +62,7 @@ public class Nameserver implements INameserver {
|
|||||||
try {
|
try {
|
||||||
registry = LocateRegistry.getRegistry(registryHost, registryPort);
|
registry = LocateRegistry.getRegistry(registryHost, registryPort);
|
||||||
nameserverRemote = (INameserverRemote) registry.lookup(registryName);
|
nameserverRemote = (INameserverRemote) registry.lookup(registryName);
|
||||||
|
UnicastRemoteObject.exportObject(nameServerLocal, 0);
|
||||||
nameserverRemote.registerNameserver(domain, nameServerLocal);
|
nameserverRemote.registerNameserver(domain, nameServerLocal);
|
||||||
} catch (RemoteException | NotBoundException e) {
|
} catch (RemoteException | NotBoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -107,20 +108,20 @@ public class Nameserver implements INameserver {
|
|||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
// shell is already interrupted
|
// shell is already interrupted
|
||||||
// so just close other things
|
// so just close other things
|
||||||
|
try {
|
||||||
|
UnicastRemoteObject.unexportObject(nameServerLocal, true);
|
||||||
|
} catch (NoSuchObjectException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (this.componentId.equals("ns-root")) {
|
if (this.componentId.equals("ns-root")) {
|
||||||
try {
|
try {
|
||||||
registry.unbind(registryName);
|
this.registry.unbind(registryName);
|
||||||
UnicastRemoteObject.unexportObject(nameServerLocal, true);
|
UnicastRemoteObject.unexportObject(this.registry, true);
|
||||||
} catch (RemoteException e) {
|
} catch(RemoteException | NotBoundException e){
|
||||||
e.printStackTrace();
|
|
||||||
} catch (NotBoundException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this.nameservers();
|
|
||||||
System.out.println("Zone Nameserver...");
|
|
||||||
}
|
}
|
||||||
System.out.println("Nameserver shut down successfully!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user