Search in sources :

Example 6 with NodeControllerService

use of org.apache.hyracks.control.nc.NodeControllerService 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 7 with NodeControllerService

use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.

the class NCApplication method getHcc.

protected IHyracksClientConnection getHcc() throws Exception {
    NodeControllerService ncSrv = (NodeControllerService) ncServiceCtx.getControllerService();
    ClusterControllerInfo ccInfo = ncSrv.getNodeParameters().getClusterControllerInfo();
    return new HyracksConnection(ccInfo.getClientNetAddress(), ccInfo.getClientNetPort());
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) ClusterControllerInfo(org.apache.hyracks.api.client.ClusterControllerInfo) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection)

Example 8 with NodeControllerService

use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.

the class NCApplication method updateOnNodeJoin.

private void updateOnNodeJoin() {
    MetadataProperties metadataProperties = runtimeContext.getMetadataProperties();
    if (!metadataProperties.getNodeNames().contains(nodeId)) {
        Cluster cluster = ClusterProperties.INSTANCE.getCluster();
        if (cluster == null) {
            throw new IllegalStateException("No cluster configuration found for this instance");
        }
        NCConfig ncConfig = ((NodeControllerService) ncServiceCtx.getControllerService()).getConfiguration();
        ncConfig.getConfigManager().registerVirtualNode(nodeId);
        String asterixInstanceName = metadataProperties.getInstanceName();
        TransactionProperties txnProperties = runtimeContext.getTransactionProperties();
        Node self = null;
        List<Node> nodes;
        if (cluster.getSubstituteNodes() != null) {
            nodes = cluster.getSubstituteNodes().getNode();
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
        for (Node node : nodes) {
            String ncId = asterixInstanceName + "_" + node.getId();
            if (ncId.equalsIgnoreCase(nodeId)) {
                String storeDir = ClusterProperties.INSTANCE.getStorageDirectoryName();
                String nodeIoDevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
                String[] ioDevicePaths = nodeIoDevices.trim().split(",");
                for (int i = 0; i < ioDevicePaths.length; i++) {
                    // construct full store path
                    ioDevicePaths[i] += File.separator + storeDir;
                }
                metadataProperties.getStores().put(nodeId, ioDevicePaths);
                String coredumpPath = node.getLogDir() == null ? cluster.getLogDir() : node.getLogDir();
                metadataProperties.getCoredumpPaths().put(nodeId, coredumpPath);
                String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
                txnProperties.getLogDirectories().put(nodeId, txnLogDir);
                if (LOGGER.isLoggable(Level.INFO)) {
                    LOGGER.info("Store set to : " + storeDir);
                    LOGGER.info("Coredump dir set to : " + coredumpPath);
                    LOGGER.info("Transaction log dir set to :" + txnLogDir);
                }
                self = node;
                break;
            }
        }
        if (self != null) {
            cluster.getSubstituteNodes().getNode().remove(self);
            cluster.getNode().add(self);
        } else {
            throw new IllegalStateException("Unknown node joining the cluster");
        }
    }
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) TransactionProperties(org.apache.asterix.common.config.TransactionProperties) Node(org.apache.asterix.event.schema.cluster.Node) Cluster(org.apache.asterix.event.schema.cluster.Cluster) MetadataProperties(org.apache.asterix.common.config.MetadataProperties)

Example 9 with NodeControllerService

use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.

the class HyracksUtils method init.

public static void init() throws Exception {
    CCConfig ccConfig = new CCConfig();
    ccConfig.setClientListenAddress(CC_HOST);
    ccConfig.setClusterListenAddress(CC_HOST);
    ccConfig.setClusterListenPort(TEST_HYRACKS_CC_PORT);
    ccConfig.setClientListenPort(TEST_HYRACKS_CC_CLIENT_PORT);
    ccConfig.setJobHistorySize(0);
    ccConfig.setProfileDumpPeriod(-1);
    // cluster controller
    cc = new ClusterControllerService(ccConfig);
    cc.start();
    // two node controllers
    NCConfig ncConfig1 = new NCConfig(NC1_ID);
    ncConfig1.setClusterAddress("localhost");
    ncConfig1.setClusterListenAddress("localhost");
    ncConfig1.setClusterPort(TEST_HYRACKS_CC_PORT);
    ncConfig1.setDataListenAddress("127.0.0.1");
    ncConfig1.setResultListenAddress("127.0.0.1");
    nc1 = new NodeControllerService(ncConfig1);
    nc1.start();
    NCConfig ncConfig2 = new NCConfig(NC2_ID);
    ncConfig2.setClusterAddress("localhost");
    ncConfig2.setClusterListenAddress("localhost");
    ncConfig2.setClusterPort(TEST_HYRACKS_CC_PORT);
    ncConfig2.setDataListenAddress("127.0.0.1");
    ncConfig2.setResultListenAddress("127.0.0.1");
    nc2 = new NodeControllerService(ncConfig2);
    nc2.start();
    // hyracks connection
    hcc = new HyracksConnection(CC_HOST, TEST_HYRACKS_CC_CLIENT_PORT);
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) CCConfig(org.apache.hyracks.control.common.controllers.CCConfig) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) HyracksConnection(org.apache.hyracks.api.client.HyracksConnection) ClusterControllerService(org.apache.hyracks.control.cc.ClusterControllerService)

Example 10 with NodeControllerService

use of org.apache.hyracks.control.nc.NodeControllerService in project asterixdb by apache.

the class ExecutionTestUtil method setUp.

public static List<ILibraryManager> setUp(boolean cleanup, String configFile, AsterixHyracksIntegrationUtil alternateIntegrationUtil, boolean startHdfs) throws Exception {
    System.out.println("Starting setup");
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("Starting setup");
    }
    System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, configFile);
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("initializing pseudo cluster");
    }
    integrationUtil = alternateIntegrationUtil;
    integrationUtil.init(cleanup);
    if (LOGGER.isLoggable(Level.INFO)) {
        LOGGER.info("initializing HDFS");
    }
    if (startHdfs) {
        HDFSCluster.getInstance().setup();
    }
    // Set the node resolver to be the identity resolver that expects node
    // names
    // to be node controller ids; a valid assumption in test environment.
    System.setProperty(ExternalDataConstants.NODE_RESOLVER_FACTORY_PROPERTY, IdentitiyResolverFactory.class.getName());
    FailedGroup = new TestGroup();
    FailedGroup.setName("failed");
    List<ILibraryManager> libraryManagers = new ArrayList<>();
    // Adds the library manager for CC.
    libraryManagers.add(((ICcApplicationContext) integrationUtil.cc.getApplicationContext()).getLibraryManager());
    // Adds library managers for NCs, one-per-NC.
    for (NodeControllerService nc : integrationUtil.ncs) {
        INcApplicationContext runtimeCtx = (INcApplicationContext) nc.getApplicationContext();
        libraryManagers.add(runtimeCtx.getLibraryManager());
    }
    return libraryManagers;
}
Also used : NodeControllerService(org.apache.hyracks.control.nc.NodeControllerService) INcApplicationContext(org.apache.asterix.common.api.INcApplicationContext) ILibraryManager(org.apache.asterix.common.library.ILibraryManager) ArrayList(java.util.ArrayList) TestGroup(org.apache.asterix.testframework.xml.TestGroup) IdentitiyResolverFactory(org.apache.asterix.external.util.IdentitiyResolverFactory)

Aggregations

NodeControllerService (org.apache.hyracks.control.nc.NodeControllerService)14 HyracksConnection (org.apache.hyracks.api.client.HyracksConnection)8 ClusterControllerService (org.apache.hyracks.control.cc.ClusterControllerService)7 CCConfig (org.apache.hyracks.control.common.controllers.CCConfig)7 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)7 File (java.io.File)4 ArrayList (java.util.ArrayList)3 BeforeClass (org.junit.BeforeClass)3 IOException (java.io.IOException)2 INcApplicationContext (org.apache.asterix.common.api.INcApplicationContext)2 MetadataProperties (org.apache.asterix.common.config.MetadataProperties)2 AsterixException (org.apache.asterix.common.exceptions.AsterixException)2 INCMessageBroker (org.apache.asterix.common.messaging.api.INCMessageBroker)2 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)2 CmdLineException (org.kohsuke.args4j.CmdLineException)2 NCAppRuntimeContext (org.apache.asterix.app.nc.NCAppRuntimeContext)1 AsterixThreadFactory (org.apache.asterix.common.api.AsterixThreadFactory)1 MessagingProperties (org.apache.asterix.common.config.MessagingProperties)1 TransactionProperties (org.apache.asterix.common.config.TransactionProperties)1 ILibraryManager (org.apache.asterix.common.library.ILibraryManager)1