Search in sources :

Example 1 with INCApplication

use of org.apache.hyracks.api.application.INCApplication 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 2 with INCApplication

use of org.apache.hyracks.api.application.INCApplication 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)

Aggregations

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