Command-line option -metadata-port to specify fixed port for metadata RMI
Change-Id: Ibf039b481a23ef82c9e80950e3b8daa1e9afb07a
Reviewed-on: http://fulliautomatix.ics.uci.edu:8443/212
Reviewed-by: Ian Maxon <imaxon@uci.edu>
Tested-by: Chris Hillery <ceej@lambda.nu>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 295fac7..2f71dcf 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -42,9 +42,17 @@
import edu.uci.ics.hyracks.api.lifecycle.ILifeCycleComponentManager;
import edu.uci.ics.hyracks.api.lifecycle.LifeCycleComponentManager;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.CmdLineException;
+import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
+
public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
+ @Option(name = "-metadata-port", usage = "IP port to bind metadata listener (default: random port)", required = false)
+ public int metadataRmiPort = 0;
+
private INCApplicationContext ncApplicationContext = null;
private IAsterixAppRuntimeContext runtimeContext;
private String nodeId;
@@ -55,6 +63,18 @@
@Override
public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
+ CmdLineParser parser = new CmdLineParser(this);
+
+ try {
+ parser.parseArgument(args);
+ }
+ catch (CmdLineException e) {
+ System.err.println(e.getMessage());
+ System.err.println("Usage:");
+ parser.printUsage(System.err);
+ throw e;
+ }
+
ncAppCtx.setThreadFactory(new AsterixThreadFactory(ncAppCtx.getLifeCycleComponentManager()));
ncApplicationContext = ncAppCtx;
nodeId = ncApplicationContext.getNodeId();
@@ -188,7 +208,7 @@
if (isMetadataNode) {
IMetadataNode stub = null;
- stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
+ stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, metadataRmiPort);
proxy.setMetadataNode(stub);
}