Search in sources :

Example 1 with ConfigManager

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);
}
Also used : IOption(org.apache.hyracks.api.config.IOption) ArrayList(java.util.ArrayList) Section(org.apache.hyracks.api.config.Section) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager)

Example 2 with ConfigManager

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);
    }
}
Also used : INCApplication(org.apache.hyracks.api.application.INCApplication) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException) IOException(java.io.IOException)

Example 3 with ConfigManager

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);
    }
}
Also used : ICCApplication(org.apache.hyracks.api.application.ICCApplication) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager) CmdLineException(org.kohsuke.args4j.CmdLineException) CmdLineException(org.kohsuke.args4j.CmdLineException) IOException(java.io.IOException)

Example 4 with ConfigManager

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()]);
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) INCApplication(org.apache.hyracks.api.application.INCApplication) ArrayList(java.util.ArrayList) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager) AsterixException(org.apache.asterix.common.exceptions.AsterixException) IOException(java.io.IOException) CmdLineException(org.kohsuke.args4j.CmdLineException) ICCApplication(org.apache.hyracks.api.application.ICCApplication) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 5 with ConfigManager

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;
}
Also used : CCApplication(org.apache.asterix.hyracks.bootstrap.CCApplication) ConfigManager(org.apache.hyracks.control.common.config.ConfigManager)

Aggregations

ConfigManager (org.apache.hyracks.control.common.config.ConfigManager)5 IOException (java.io.IOException)3 CmdLineException (org.kohsuke.args4j.CmdLineException)3 ArrayList (java.util.ArrayList)2 ICCApplication (org.apache.hyracks.api.application.ICCApplication)2 INCApplication (org.apache.hyracks.api.application.INCApplication)2 CCConfig (org.apache.hyracks.control.common.controllers.CCConfig)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)1 CCApplication (org.apache.asterix.hyracks.bootstrap.CCApplication)1 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)1 IOption (org.apache.hyracks.api.config.IOption)1 Section (org.apache.hyracks.api.config.Section)1 ClusterControllerService (org.apache.hyracks.control.cc.ClusterControllerService)1 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)1 NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)1