Search in sources :

Example 1 with IResourceManager

use of org.apache.hyracks.control.cc.scheduler.IResourceManager 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 2 with IResourceManager

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

the class NodeManagerTest method testNullNode.

@Test
public void testNullNode() throws HyracksException {
    IResourceManager resourceManager = new ResourceManager();
    INodeManager nodeManager = new NodeManager(makeCCConfig(), resourceManager);
    boolean invalidParameter = false;
    // Verifies states after a failure during adding nodes.
    try {
        nodeManager.addNode(null, null);
    } catch (HyracksException e) {
        invalidParameter = e.getErrorCode() == ErrorCode.INVALID_INPUT_PARAMETER;
    }
    Assert.assertTrue(invalidParameter);
    // 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) Test(org.junit.Test)

Example 3 with IResourceManager

use of org.apache.hyracks.control.cc.scheduler.IResourceManager 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)

Example 4 with IResourceManager

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

the class JobCapacityControllerTest method makeResourceManagerWithCapacity.

private IResourceManager makeResourceManagerWithCapacity(long memorySize, int cores) throws HyracksException {
    IResourceManager resourceManager = new ResourceManager();
    resourceManager.update("node1", new NodeCapacity(memorySize, cores));
    return resourceManager;
}
Also used : NodeCapacity(org.apache.hyracks.api.job.resource.NodeCapacity) IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager) ResourceManager(org.apache.hyracks.control.cc.scheduler.ResourceManager) IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager)

Example 5 with IResourceManager

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

the class JobCapacityControllerTest method test.

@Test
public void test() throws HyracksException {
    IResourceManager resourceManager = makeResourceManagerWithCapacity(4294967296L, 33);
    JobCapacityController capacityController = new JobCapacityController(resourceManager);
    // Verifies the correctness of the allocate method.
    Assert.assertTrue(capacityController.allocate(makeJobWithRequiredCapacity(4294967296L, 16)) == IJobCapacityController.JobSubmissionStatus.EXECUTE);
    Assert.assertTrue(capacityController.allocate(makeJobWithRequiredCapacity(2147483648L, 16)) == IJobCapacityController.JobSubmissionStatus.QUEUE);
    Assert.assertTrue(capacityController.allocate(makeJobWithRequiredCapacity(2147483648L, 32)) == IJobCapacityController.JobSubmissionStatus.QUEUE);
    boolean exceedCapacity = false;
    try {
        capacityController.allocate(makeJobWithRequiredCapacity(2147483648L, 64));
    } catch (HyracksException e) {
        exceedCapacity = e.getErrorCode() == ErrorCode.JOB_REQUIREMENTS_EXCEED_CAPACITY;
    }
    Assert.assertTrue(exceedCapacity);
    Assert.assertTrue(capacityController.allocate(makeJobWithRequiredCapacity(4294967296L, 32)) == IJobCapacityController.JobSubmissionStatus.QUEUE);
    exceedCapacity = false;
    try {
        capacityController.allocate(makeJobWithRequiredCapacity(4294967297L, 33));
    } catch (HyracksException e) {
        exceedCapacity = e.getErrorCode() == ErrorCode.JOB_REQUIREMENTS_EXCEED_CAPACITY;
    }
    Assert.assertTrue(exceedCapacity);
    // Verifies that the release method does not leak resource.
    capacityController.release(makeJobWithRequiredCapacity(4294967296L, 16));
    Assert.assertTrue(resourceManager.getCurrentCapacity().getAggregatedMemoryByteSize() == 4294967296L);
    Assert.assertTrue(resourceManager.getCurrentCapacity().getAggregatedCores() == 33);
}
Also used : IJobCapacityController(org.apache.hyracks.api.job.resource.IJobCapacityController) IResourceManager(org.apache.hyracks.control.cc.scheduler.IResourceManager) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) Test(org.junit.Test)

Aggregations

IResourceManager (org.apache.hyracks.control.cc.scheduler.IResourceManager)5 ResourceManager (org.apache.hyracks.control.cc.scheduler.ResourceManager)4 Test (org.junit.Test)4 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)3 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)2 IJobCapacityController (org.apache.hyracks.api.job.resource.IJobCapacityController)1 NodeCapacity (org.apache.hyracks.api.job.resource.NodeCapacity)1