{
super(properties, systemRegistry, txnProxy,
new LoggerWrapper(Logger.getLogger(PKG_NAME)));
logger.log(Level.CONFIG, "Creating NodeMappingServiceImpl");
PropertiesWrapper wrappedProps = new PropertiesWrapper(properties);
try {
watchdogService = txnProxy.getService(WatchdogService.class);
contextFactory = new ContextFactory(txnProxy);
/*
* Check service version.
*/
transactionScheduler.runTask(
new AbstractKernelRunnable("CheckServiceVersion") {
public void run() {
checkServiceVersion(
NodeMapUtil.VERSION_KEY,
NodeMapUtil.MAJOR_VERSION,
NodeMapUtil.MINOR_VERSION);
} }, taskOwner);
// Find or create our server.
String localHost =
InetAddress.getLocalHost().getHostName();
NodeType nodeType =
wrappedProps.getEnumProperty(StandardProperties.NODE_TYPE,
NodeType.class,
NodeType.singleNode);
boolean instantiateServer = nodeType != NodeType.appNode;
String host;
int port;
if (instantiateServer) {
serverImpl =
new NodeMappingServerImpl(properties,
systemRegistry, txnProxy);
// Use the port actually used by our server instance
host = localHost;
port = serverImpl.getPort();
} else {
serverImpl = null;
host =
wrappedProps.getProperty(
SERVER_HOST_PROPERTY,
wrappedProps.getProperty(
StandardProperties.SERVER_HOST));
if (host == null) {
throw new IllegalArgumentException(
"A server host must be specified");
}
port = wrappedProps.getIntProperty(
NodeMappingServerImpl.SERVER_PORT_PROPERTY,
NodeMappingServerImpl.DEFAULT_SERVER_PORT, 0, 65535);
}
// TODO This code assumes that the server has already been started.
// Perhaps it'd be better to block until the server is available?
Registry registry = LocateRegistry.getRegistry(host, port);
server = (NodeMappingServer) registry.lookup(
NodeMappingServerImpl.SERVER_EXPORT_NAME);
// Export our client object for server callbacks.
int clientPort = wrappedProps.getIntProperty(
CLIENT_PORT_PROPERTY,
DEFAULT_CLIENT_PORT, 0, 65535);
changeNotifierImpl = new MapChangeNotifier();
exporter = new Exporter<NotifyClient>(NotifyClient.class);
clientPort = exporter.export(changeNotifierImpl, clientPort);