use of org.apache.hyracks.control.common.config.ConfigManager in project asterixdb by apache.
the class ConfigUsageTest method generateUsage.
public void generateUsage(String startDelim, String midDelim, String endDelim, EnumMap<Column, Boolean> align, PrintStream output) {
ConfigManager configManager = getConfigManager();
StringBuilder buf = new StringBuilder();
final Column[] columns = Column.values();
for (Section section : getSections(configManager)) {
for (IOption option : getSectionOptions(configManager, section)) {
for (Column column : columns) {
if (align.computeIfAbsent(column, c -> false)) {
calculateMaxWidth(option, column);
}
}
}
}
// output header
for (Column column : columns) {
buf.append(column.ordinal() == 0 ? startDelim : midDelim);
pad(buf, StringUtils.capitalize(column.name().toLowerCase()), align.computeIfAbsent(column, c -> false) ? calculateMaxWidth(column, column.name()) : 0);
}
buf.append(endDelim).append('\n');
StringBuilder sepLine = new StringBuilder();
for (Column column : columns) {
sepLine.append(column.ordinal() == 0 ? startDelim : midDelim);
pad(sepLine, "", maxWidths.getOrDefault(column, 0), '-');
}
sepLine.append(endDelim).append('\n');
buf.append(sepLine.toString().replace(' ', '-'));
for (Section section : getSections(configManager)) {
List<IOption> options = new ArrayList<>(getSectionOptions(configManager, section));
options.sort(Comparator.comparing(IOption::ini));
for (IOption option : options) {
for (Column column : columns) {
buf.append(column.ordinal() == 0 ? startDelim : midDelim);
if (column == Column.SECTION) {
center(buf, extractValue(column, option), maxWidths.getOrDefault(column, 0));
} else {
pad(buf, extractValue(column, option), maxWidths.getOrDefault(column, 0));
}
}
buf.append(endDelim).append('\n');
}
}
output.println(buf);
}
use of org.apache.hyracks.control.common.config.ConfigManager in project asterixdb by apache.
the class NCDriver method main.
public static void main(String[] args) {
try {
final String nodeId = ConfigUtils.getOptionValue(args, NCConfig.Option.NODE_ID);
final ConfigManager configManager = new ConfigManager(args);
INCApplication application = getApplication(args);
application.registerConfig(configManager);
NCConfig ncConfig = new NCConfig(nodeId, configManager);
final NodeControllerService ncService = new NodeControllerService(ncConfig, application);
ncService.start();
while (true) {
Thread.sleep(10000);
}
} catch (CmdLineException e) {
LOGGER.log(Level.FINE, "Exception parsing command line: " + Arrays.toString(args), e);
System.exit(2);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exiting NCDriver due to exception", e);
System.exit(1);
}
}
use of org.apache.hyracks.control.common.config.ConfigManager in project asterixdb by apache.
the class CCDriver method main.
public static void main(String[] args) throws Exception {
try {
final ConfigManager configManager = new ConfigManager(args);
ICCApplication application = getApplication(args);
application.registerConfig(configManager);
CCConfig ccConfig = new CCConfig(configManager);
ClusterControllerService ccService = new ClusterControllerService(ccConfig, application);
ccService.start();
while (true) {
Thread.sleep(100000);
}
} catch (CmdLineException e) {
LOGGER.log(Level.FINE, "Exception parsing command line: " + Arrays.toString(args), e);
System.exit(2);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exiting CCDriver due to exception", e);
System.exit(1);
}
}
use of org.apache.hyracks.control.common.config.ConfigManager in project asterixdb by apache.
the class AsterixHyracksIntegrationUtil method init.
public void init(boolean deleteOldInstanceData) throws Exception {
final ICCApplication ccApplication = createCCApplication();
configManager = new ConfigManager();
ccApplication.registerConfig(configManager);
final CCConfig ccConfig = createCCConfig(configManager);
cc = new ClusterControllerService(ccConfig, ccApplication);
nodeNames = ccConfig.getConfigManager().getNodeNames();
if (deleteOldInstanceData) {
deleteTransactionLogs();
removeTestStorageFiles();
}
final List<NodeControllerService> nodeControllers = new ArrayList<>();
for (String nodeId : nodeNames) {
// mark this NC as virtual in the CC's config manager, so he doesn't try to contact NCService...
configManager.set(nodeId, NCConfig.Option.VIRTUAL_NC, true);
final INCApplication ncApplication = createNCApplication();
ConfigManager ncConfigManager = new ConfigManager();
ncApplication.registerConfig(ncConfigManager);
nodeControllers.add(new NodeControllerService(fixupIODevices(createNCConfig(nodeId, ncConfigManager)), ncApplication));
}
;
cc.start();
// Starts ncs.
nodeNames = ccConfig.getConfigManager().getNodeNames();
List<Thread> startupThreads = new ArrayList<>();
for (NodeControllerService nc : nodeControllers) {
Thread ncStartThread = new Thread("IntegrationUtil-" + nc.getId()) {
@Override
public void run() {
try {
nc.start();
} catch (Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
}
}
};
ncStartThread.start();
startupThreads.add(ncStartThread);
}
//wait until all NCs complete their startup
for (Thread thread : startupThreads) {
thread.join();
}
// Wait until cluster becomes active
ClusterStateManager.INSTANCE.waitForState(ClusterState.ACTIVE);
hcc = new HyracksConnection(cc.getConfig().getClientListenAddress(), cc.getConfig().getClientListenPort());
this.ncs = nodeControllers.toArray(new NodeControllerService[nodeControllers.size()]);
}
use of org.apache.hyracks.control.common.config.ConfigManager in project asterixdb by apache.
the class ConfigUsageTest method getConfigManager.
protected ConfigManager getConfigManager() {
ConfigManager configManager = new ConfigManager();
CCApplication application = new CCApplication();
application.registerConfig(configManager);
ControllerConfig.Option.DEFAULT_DIR.setDefaultValue(((String) ControllerConfig.Option.DEFAULT_DIR.defaultValue()).replace(System.getProperty("java.io.tmpdir"), "${java.io.tmpdir}/"));
return configManager;
}
Aggregations