Search in sources :

Example 21 with NodeControllerState

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

the class JobManagerTest method mockNodeManager.

private INodeManager mockNodeManager() {
    INodeManager nodeManager = mock(NodeManager.class);
    NodeControllerState ncState = mock(NodeControllerState.class);
    INodeController nodeController = mock(INodeController.class);
    when(nodeManager.getNodeControllerState(any())).thenReturn(ncState);
    when(ncState.getNodeController()).thenReturn(nodeController);
    return nodeManager;
}
Also used : INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) INodeController(org.apache.hyracks.control.common.base.INodeController) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 22 with NodeControllerState

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

the class RegisterNodeWork method doRun.

@Override
protected void doRun() throws Exception {
    String id = reg.getNodeId();
    IIPCHandle ncIPCHandle = ccs.getClusterIPC().getHandle(reg.getNodeControllerAddress());
    CCNCFunctions.NodeRegistrationResult result;
    Map<IOption, Object> ncConfiguration = new HashMap<>();
    try {
        INodeController nodeController = new NodeControllerRemoteProxy(ncIPCHandle);
        NodeControllerState state = new NodeControllerState(nodeController, reg);
        INodeManager nodeManager = ccs.getNodeManager();
        nodeManager.addNode(id, state);
        IApplicationConfig cfg = state.getNCConfig().getConfigManager().getNodeEffectiveConfig(id);
        for (IOption option : cfg.getOptions()) {
            ncConfiguration.put(option, cfg.get(option));
        }
        LOGGER.log(Level.INFO, "Registered INodeController: id = " + id);
        NodeParameters params = new NodeParameters();
        params.setClusterControllerInfo(ccs.getClusterControllerInfo());
        params.setDistributedState(ccs.getContext().getDistributedState());
        params.setHeartbeatPeriod(ccs.getCCConfig().getHeartbeatPeriod());
        params.setProfileDumpPeriod(ccs.getCCConfig().getProfileDumpPeriod());
        result = new CCNCFunctions.NodeRegistrationResult(params, null);
    } catch (Exception e) {
        result = new CCNCFunctions.NodeRegistrationResult(null, e);
    }
    ncIPCHandle.send(-1, result, null);
    ccs.getContext().notifyNodeJoin(id, ncConfiguration);
}
Also used : IIPCHandle(org.apache.hyracks.ipc.api.IIPCHandle) INodeManager(org.apache.hyracks.control.cc.cluster.INodeManager) NodeControllerRemoteProxy(org.apache.hyracks.control.common.ipc.NodeControllerRemoteProxy) INodeController(org.apache.hyracks.control.common.base.INodeController) HashMap(java.util.HashMap) CCNCFunctions(org.apache.hyracks.control.common.ipc.CCNCFunctions) NodeParameters(org.apache.hyracks.control.common.controllers.NodeParameters) IOption(org.apache.hyracks.api.config.IOption) IApplicationConfig(org.apache.hyracks.api.config.IApplicationConfig) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Example 23 with NodeControllerState

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

the class NodeManagerTest method testNormal.

@Test
public void testNormal() throws HyracksException {
    IResourceManager resourceManager = new ResourceManager();
    INodeManager nodeManager = new NodeManager(makeCCConfig(), resourceManager);
    NodeControllerState ncState1 = mockNodeControllerState(NODE1, false);
    NodeControllerState ncState2 = mockNodeControllerState(NODE2, false);
    // Verifies states after adding nodes.
    nodeManager.addNode(NODE1, ncState1);
    nodeManager.addNode(NODE2, ncState2);
    Assert.assertTrue(nodeManager.getIpAddressNodeNameMap().size() == 1);
    Assert.assertTrue(nodeManager.getAllNodeIds().size() == 2);
    Assert.assertTrue(nodeManager.getAllNodeControllerStates().size() == 2);
    Assert.assertTrue(nodeManager.getNodeControllerState(NODE1) == ncState1);
    Assert.assertTrue(nodeManager.getNodeControllerState(NODE2) == ncState2);
    Assert.assertTrue(resourceManager.getCurrentCapacity().getAggregatedMemoryByteSize() == NODE_MEMORY_SIZE * 2);
    Assert.assertTrue(resourceManager.getCurrentCapacity().getAggregatedCores() == NODE_CORES * 2);
    Assert.assertTrue(resourceManager.getMaximumCapacity().getAggregatedMemoryByteSize() == NODE_MEMORY_SIZE * 2);
    Assert.assertTrue(resourceManager.getMaximumCapacity().getAggregatedCores() == NODE_CORES * 2);
    // Verifies states after removing dead nodes.
    nodeManager.removeDeadNodes();
    verifyEmptyCluster(resourceManager, nodeManager);
}
Also used : IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager) 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)

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