#1 scaffold the Root Nameserver
This commit is contained in:
parent
db7d78bab9
commit
7e3854810b
25
src/main/java/dslab/nameserver/NameServerRemote.java
Normal file
25
src/main/java/dslab/nameserver/NameServerRemote.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package dslab.nameserver;
|
||||||
|
|
||||||
|
import java.rmi.RemoteException;
|
||||||
|
|
||||||
|
public class NameServerRemote implements INameserverRemote {
|
||||||
|
@Override
|
||||||
|
public void registerNameserver(String domain, INameserverRemote nameserver) throws RemoteException, AlreadyRegisteredException, InvalidDomainException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerMailboxServer(String domain, String address) throws RemoteException, AlreadyRegisteredException, InvalidDomainException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public INameserverRemote getNameserver(String zone) throws RemoteException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String lookup(String username) throws RemoteException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,12 +2,18 @@ package dslab.nameserver;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.rmi.*;
|
||||||
|
import java.rmi.registry.LocateRegistry;
|
||||||
|
import java.rmi.registry.Registry;
|
||||||
|
import java.rmi.server.UnicastRemoteObject;
|
||||||
|
|
||||||
import dslab.ComponentFactory;
|
import dslab.ComponentFactory;
|
||||||
import dslab.util.Config;
|
import dslab.util.Config;
|
||||||
|
|
||||||
public class Nameserver implements INameserver {
|
public class Nameserver implements INameserver {
|
||||||
|
|
||||||
|
static Registry REGISTRY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new server instance.
|
* Creates a new server instance.
|
||||||
*
|
*
|
||||||
@ -17,7 +23,24 @@ public class Nameserver implements INameserver {
|
|||||||
* @param out the output stream to write console output to
|
* @param out the output stream to write console output to
|
||||||
*/
|
*/
|
||||||
public Nameserver(String componentId, Config config, InputStream in, PrintStream out) {
|
public Nameserver(String componentId, Config config, InputStream in, PrintStream out) {
|
||||||
// TODO
|
// only root nameserver creates RMI registry
|
||||||
|
if (componentId.equals("ns-root")) {
|
||||||
|
int registryPort = config.getInt("registry.port");
|
||||||
|
String registryName = config.getString("root_id");
|
||||||
|
INameserverRemote nameserverRemote = new NameServerRemote();
|
||||||
|
try {
|
||||||
|
INameserverRemote stub = (INameserverRemote) UnicastRemoteObject.exportObject(nameserverRemote, registryPort);
|
||||||
|
REGISTRY = LocateRegistry.createRegistry(registryPort);
|
||||||
|
REGISTRY.rebind(registryName, stub);
|
||||||
|
System.out.println("Nameserver bound.");
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
System.err.println("Nameserver exception:");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// TODO zone nameservers
|
||||||
|
System.out.println("Zone Nameserver");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user