Search in sources :

Example 1 with NodeControllerState

use of org.apache.hyracks.control.cc.NodeControllerState in project asterixdb by apache.

the class CCMessageBroker method sendApplicationMessageToNC.

@Override
public void sendApplicationMessageToNC(INcAddressedMessage msg, String nodeId) throws Exception {
    INodeManager nodeManager = ccs.getNodeManager();
    NodeControllerState state = nodeManager.getNodeControllerState(nodeId);
    state.getNodeController().sendApplicationMessageToNC(JavaSerializationUtils.serialize(msg), null, nodeId);
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 2 with NodeControllerState

use of org.apache.hyracks.control.cc.NodeControllerState in project asterixdb by apache.

the class NodeManagerTest method mockNodeControllerState.

private NodeControllerState mockNodeControllerState(String nodeId, boolean invalidIpAddr) {
    NodeControllerState ncState = mock(NodeControllerState.class);
    String ipAddr = invalidIpAddr ? "255.255.255:255" : "127.0.0.2";
    NetworkAddress dataAddr = new NetworkAddress(ipAddr, 1001);
    NetworkAddress resultAddr = new NetworkAddress(ipAddr, 1002);
    NetworkAddress msgAddr = new NetworkAddress(ipAddr, 1003);
    when(ncState.getCapacity()).thenReturn(new NodeCapacity(NODE_MEMORY_SIZE, NODE_CORES));
    when(ncState.getDataPort()).thenReturn(dataAddr);
    when(ncState.getDatasetPort()).thenReturn(resultAddr);
    when(ncState.getMessagingPort()).thenReturn(msgAddr);
    NCConfig ncConfig = new NCConfig(nodeId);
    ncConfig.setDataPublicAddress(ipAddr);
    when(ncState.getNCConfig()).thenReturn(ncConfig);
    return ncState;
}
Also used : NetworkAddress(org.apache.hyracks.api.comm.NetworkAddress) NodeCapacity(org.apache.hyracks.api.job.resource.NodeCapacity) NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 3 with NodeControllerState

use of org.apache.hyracks.control.cc.NodeControllerState in project asterixdb by apache.

the class NodeManagerTest method testException.

@Test
public void testException() throws HyracksException {
    IResourceManager resourceManager = new ResourceManager();
    INodeManager nodeManager = new NodeManager(makeCCConfig(), resourceManager);
    NodeControllerState ncState1 = mockNodeControllerState(NODE1, true);
    boolean invalidNetworkAddress = false;
    // Verifies states after a failure during adding nodes.
    try {
        nodeManager.addNode(NODE1, ncState1);
    } catch (HyracksException e) {
        invalidNetworkAddress = e.getErrorCode() == ErrorCode.INVALID_NETWORK_ADDRESS;
    }
    Assert.assertTrue(invalidNetworkAddress);
    // Verifies that the cluster is empty.
    verifyEmptyCluster(resourceManager, nodeManager);
}
Also used : IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) ResourceManager(org.apache.hyracks.control.cc.scheduler.ResourceManager) IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState) Test(org.junit.Test)

Example 4 with NodeControllerState

use of org.apache.hyracks.control.cc.NodeControllerState in project asterixdb by apache.

the class JobletCleanupNotificationWork method runWork.

@Override
public void runWork() {
    IJobManager jobManager = ccs.getJobManager();
    final JobRun run = jobManager.get(jobId);
    Set<String> cleanupPendingNodes = run.getCleanupPendingNodeIds();
    if (!cleanupPendingNodes.remove(nodeId)) {
        if (LOGGER.isLoggable(Level.WARNING)) {
            LOGGER.warning(nodeId + " not in pending cleanup nodes set: " + cleanupPendingNodes + " for Job: " + jobId);
        }
        return;
    }
    INodeManager nodeManager = ccs.getNodeManager();
    NodeControllerState ncs = nodeManager.getNodeControllerState(nodeId);
    if (ncs != null) {
        ncs.getActiveJobIds().remove(jobId);
    }
    if (cleanupPendingNodes.isEmpty()) {
        try {
            jobManager.finalComplete(run);
        } catch (HyracksException e) {
            // Fail the job with the caught exception during final completion.
            run.getExceptions().add(e);
            run.setStatus(JobStatus.FAILURE, run.getExceptions());
        }
    }
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IJobManager(org.apache.hyracks.control.cc.job.IJobManager) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState) JobRun(org.apache.hyracks.control.cc.job.JobRun)

Example 5 with NodeControllerState

use of org.apache.hyracks.control.cc.NodeControllerState in project asterixdb by apache.

the class GetNodeDetailsJSONWork method doRun.

@Override
protected void doRun() throws Exception {
    if (nodeId == null) {
        // null nodeId is a request for CC
        detail = getCCDetails();
        if (includeConfig) {
            ConfigUtils.addConfigToJSON(detail, ccConfig.getAppConfig(), CC_SECTIONS);
            detail.putPOJO("app.args", ccConfig.getAppArgs());
        }
    } else {
        NodeControllerState ncs = nodeManager.getNodeControllerState(nodeId);
        if (ncs != null) {
            detail = ncs.toDetailedJSON(includeStats, includeConfig);
            if (includeConfig) {
                final NCConfig ncConfig = ncs.getNCConfig();
                ConfigUtils.addConfigToJSON(detail, ncConfig.getConfigManager().getNodeEffectiveConfig(nodeId), NC_SECTIONS);
                detail.putPOJO("app.args", ncConfig.getAppArgs());
            }
        }
    }
    if (callback != null) {
        callback.setValue(detail == null ? null : om.writeValueAsString(detail));
    }
}
Also used : NCConfig(org.apache.hyracks.control.common.controllers.NCConfig) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Aggregations

NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)23 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)15 HashMap (java.util.HashMap)5 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 JobId (org.apache.hyracks.api.job.JobId)4 DeploymentId (org.apache.hyracks.api.deployment.DeploymentId)3 NodeCapacity (org.apache.hyracks.api.job.resource.NodeCapacity)3 INodeController (org.apache.hyracks.control.common.base.INodeController)3 ArrayList (java.util.ArrayList)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 NetworkAddress (org.apache.hyracks.api.comm.NetworkAddress)2 ActivityClusterGraph (org.apache.hyracks.api.job.ActivityClusterGraph)2 IResourceManager (org.apache.hyracks.control.cc.scheduler.IResourceManager)2 ResourceManager (org.apache.hyracks.control.cc.scheduler.ResourceManager)2 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)2 DeploymentRun (org.apache.hyracks.control.common.deployment.DeploymentRun)2 Test (org.junit.Test)2