use of org.apache.hyracks.api.config.IOption in project asterixdb by apache.
the class ConfigManager method processCommandLine.
// use of System.err, System.exit()
@SuppressWarnings({ "squid:S106", "squid:S1147" })
private List<String> processCommandLine(Collection<Section> sections, OptionHandlerFilter usageFilter, BiConsumer<IOption, Object> setAction) throws CmdLineException {
final Args4jBean bean = new Args4jBean();
CmdLineParser cmdLineParser = new CmdLineParser(bean);
final List<String> appArgs = new ArrayList<>();
List<IOption> commandLineOptions = new ArrayList<>();
for (Map.Entry<Section, Map<String, IOption>> sectionMapEntry : sectionMap.entrySet()) {
if (!sections.contains(sectionMapEntry.getKey())) {
continue;
}
for (IOption option : sectionMapEntry.getValue().values()) {
if (option.section() != Section.VIRTUAL) {
commandLineOptions.add(option);
}
}
}
commandLineOptions.sort(Comparator.comparing(IOption::cmdline));
commandLineOptions.forEach(option -> cmdLineParser.addOption(new Args4jSetter(option, setAction, false), new Args4jOption(option, this, option.type().targetType())));
if (!argListeners.isEmpty()) {
cmdLineParser.addArgument(new Args4jSetter(o -> appArgs.add(String.valueOf(o)), true, String.class), new Args4jArgument());
}
LOGGER.fine("parsing cmdline: " + Arrays.toString(args));
if (args == null || args.length == 0) {
LOGGER.info("no command line args supplied");
return appArgs;
}
try {
cmdLineParser.parseArgument(args);
} catch (CmdLineException e) {
if (!bean.help) {
ConfigUtils.printUsage(e, usageFilter, System.err);
throw e;
} else {
LOGGER.log(Level.FINE, "Ignoring parse exception due to -help", e);
}
}
if (bean.help) {
ConfigUtils.printUsage(cmdLineParser, usageFilter, System.err);
System.exit(0);
} else if (bean.version) {
System.err.println(versionString);
System.exit(0);
}
return appArgs;
}
use of org.apache.hyracks.api.config.IOption in project asterixdb by apache.
the class ConfigManager method toIni.
public Ini toIni(boolean includeDefaults) {
Ini ini = new Ini();
for (Map.Entry<IOption, Object> entry : (includeDefaults ? configurationMap : definedMap).entrySet()) {
if (entry.getValue() != null) {
final IOption option = entry.getKey();
ini.add(option.section().sectionName(), option.ini(), option.type().serializeToIni(entry.getValue()));
}
}
for (Map.Entry<String, Map<IOption, Object>> nodeMapEntry : nodeSpecificMap.entrySet()) {
String section = Section.NC.sectionName() + "/" + nodeMapEntry.getKey();
for (Map.Entry<IOption, Object> entry : nodeMapEntry.getValue().entrySet()) {
if (entry.getValue() != null) {
final IOption option = entry.getKey();
ini.add(section, option.ini(), option.type().serializeToIni(entry.getValue()));
}
}
}
return ini;
}
use of org.apache.hyracks.api.config.IOption in project asterixdb by apache.
the class RegisterNodeWork method doRun.
@Override
protected void doRun() throws Exception {
String id = reg.getNodeId();
IIPCHandle ncIPCHandle = ccs.getClusterIPC().getHandle(reg.getNodeControllerAddress());
CCNCFunctions.NodeRegistrationResult result;
Map<IOption, Object> ncConfiguration = new HashMap<>();
try {
INodeController nodeController = new NodeControllerRemoteProxy(ncIPCHandle);
NodeControllerState state = new NodeControllerState(nodeController, reg);
INodeManager nodeManager = ccs.getNodeManager();
nodeManager.addNode(id, state);
IApplicationConfig cfg = state.getNCConfig().getConfigManager().getNodeEffectiveConfig(id);
for (IOption option : cfg.getOptions()) {
ncConfiguration.put(option, cfg.get(option));
}
LOGGER.log(Level.INFO, "Registered INodeController: id = " + id);
NodeParameters params = new NodeParameters();
params.setClusterControllerInfo(ccs.getClusterControllerInfo());
params.setDistributedState(ccs.getContext().getDistributedState());
params.setHeartbeatPeriod(ccs.getCCConfig().getHeartbeatPeriod());
params.setProfileDumpPeriod(ccs.getCCConfig().getProfileDumpPeriod());
result = new CCNCFunctions.NodeRegistrationResult(params, null);
} catch (Exception e) {
result = new CCNCFunctions.NodeRegistrationResult(null, e);
}
ncIPCHandle.send(-1, result, null);
ccs.getContext().notifyNodeJoin(id, ncConfiguration);
}
Aggregations