Search in sources :

Example 1 with IReadOnlyClusterCapacity

use of org.apache.hyracks.api.job.resource.IReadOnlyClusterCapacity in project asterixdb by apache.

the class NodeManagerTest method verifyEmptyCluster.

private void verifyEmptyCluster(IResourceManager resourceManager, INodeManager nodeManager) {
    Assert.assertTrue(nodeManager.getIpAddressNodeNameMap().isEmpty());
    Assert.assertTrue(nodeManager.getAllNodeIds().isEmpty());
    Assert.assertTrue(nodeManager.getAllNodeControllerStates().isEmpty());
    Assert.assertTrue(nodeManager.getNodeControllerState(NODE1) == null);
    Assert.assertTrue(nodeManager.getNodeControllerState(NODE2) == null);
    IReadOnlyClusterCapacity currentCapacity = resourceManager.getCurrentCapacity();
    IReadOnlyClusterCapacity maximumCapacity = resourceManager.getMaximumCapacity();
    Assert.assertTrue(currentCapacity.getAggregatedMemoryByteSize() == 0L);
    Assert.assertTrue(currentCapacity.getAggregatedCores() == 0);
    Assert.assertTrue(maximumCapacity.getAggregatedMemoryByteSize() == 0L);
    Assert.assertTrue(maximumCapacity.getAggregatedCores() == 0);
    verifyNodeNotExistInCapacity(currentCapacity, NODE1);
    verifyNodeNotExistInCapacity(currentCapacity, NODE2);
    verifyNodeNotExistInCapacity(maximumCapacity, NODE1);
    verifyNodeNotExistInCapacity(maximumCapacity, NODE1);
}
Also used : IReadOnlyClusterCapacity(org.apache.hyracks.api.job.resource.IReadOnlyClusterCapacity)

Example 2 with IReadOnlyClusterCapacity

use of org.apache.hyracks.api.job.resource.IReadOnlyClusterCapacity in project asterixdb by apache.

the class JobCapacityController method allocate.

@Override
public JobSubmissionStatus allocate(JobSpecification job) throws HyracksException {
    IClusterCapacity requiredCapacity = job.getRequiredClusterCapacity();
    long reqAggregatedMemoryByteSize = requiredCapacity.getAggregatedMemoryByteSize();
    int reqAggregatedNumCores = requiredCapacity.getAggregatedCores();
    IReadOnlyClusterCapacity maximumCapacity = resourceManager.getMaximumCapacity();
    if (!(reqAggregatedMemoryByteSize <= maximumCapacity.getAggregatedMemoryByteSize() && reqAggregatedNumCores <= maximumCapacity.getAggregatedCores())) {
        throw HyracksException.create(ErrorCode.JOB_REQUIREMENTS_EXCEED_CAPACITY, requiredCapacity.toString(), maximumCapacity.toString());
    }
    IClusterCapacity currentCapacity = resourceManager.getCurrentCapacity();
    long currentAggregatedMemoryByteSize = currentCapacity.getAggregatedMemoryByteSize();
    int currentAggregatedAvailableCores = currentCapacity.getAggregatedCores();
    if (!(reqAggregatedMemoryByteSize <= currentAggregatedMemoryByteSize && reqAggregatedNumCores <= currentAggregatedAvailableCores)) {
        return JobSubmissionStatus.QUEUE;
    }
    currentCapacity.setAggregatedMemoryByteSize(currentAggregatedMemoryByteSize - reqAggregatedMemoryByteSize);
    currentCapacity.setAggregatedCores(currentAggregatedAvailableCores - reqAggregatedNumCores);
    return JobSubmissionStatus.EXECUTE;
}
Also used : IClusterCapacity(org.apache.hyracks.api.job.resource.IClusterCapacity) IReadOnlyClusterCapacity(org.apache.hyracks.api.job.resource.IReadOnlyClusterCapacity)

Aggregations

IReadOnlyClusterCapacity (org.apache.hyracks.api.job.resource.IReadOnlyClusterCapacity)2 IClusterCapacity (org.apache.hyracks.api.job.resource.IClusterCapacity)1