use of org.apache.crail.rpc.RpcBinding in project incubator-crail by apache.
the class NameNode method main.
public static void main(String[] args) throws Exception {
LOG.info("initalizing namenode ");
CrailConfiguration conf = new CrailConfiguration();
CrailConstants.updateConstants(conf);
URI uri = CrailUtils.getPrimaryNameNode();
String address = uri.getHost();
int port = uri.getPort();
if (args != null) {
Option addressOption = Option.builder("a").desc("ip address namenode is started on").hasArg().build();
Option portOption = Option.builder("p").desc("port namenode is started on").hasArg().build();
Options options = new Options();
options.addOption(portOption);
options.addOption(addressOption);
CommandLineParser parser = new DefaultParser();
try {
CommandLine line = parser.parse(options, Arrays.copyOfRange(args, 0, args.length));
if (line.hasOption(addressOption.getOpt())) {
address = line.getOptionValue(addressOption.getOpt());
}
if (line.hasOption(portOption.getOpt())) {
port = Integer.parseInt(line.getOptionValue(portOption.getOpt()));
}
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("Namenode", options);
System.exit(-1);
}
}
String namenode = "crail://" + address + ":" + port;
long serviceId = CrailUtils.getServiceId(namenode);
long serviceSize = CrailUtils.getServiceSize();
if (!CrailUtils.verifyNamenode(namenode)) {
throw new Exception("Namenode address/port [" + namenode + "] has to be listed in crail.namenode.address " + CrailConstants.NAMENODE_ADDRESS);
}
CrailConstants.NAMENODE_ADDRESS = namenode + "?id=" + serviceId + "&size=" + serviceSize;
CrailConstants.printConf();
CrailConstants.verify();
RpcNameNodeService service = RpcNameNodeService.createInstance(CrailConstants.NAMENODE_RPC_SERVICE);
if (!CrailConstants.NAMENODE_LOG.isEmpty()) {
LogDispatcher logDispatcher = new LogDispatcher(service);
service = logDispatcher;
}
RpcBinding rpcBinding = RpcBinding.createInstance(CrailConstants.NAMENODE_RPC_TYPE);
RpcServer rpcServer = rpcBinding.launchServer(service);
rpcServer.init(conf, null);
rpcServer.printConf(LOG);
rpcServer.run();
System.exit(0);
;
}
Aggregations