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;
}
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);
}
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);
}
Aggregations