Search in sources :

Example 1 with NodeCapacity

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

the class NCApplication method getCapacity.

@Override
public NodeCapacity getCapacity() {
    StorageProperties storageProperties = runtimeContext.getStorageProperties();
    // Deducts the reserved buffer cache size and memory component size from the maxium heap size,
    // and deducts one core for processing heartbeats.
    long memorySize = Runtime.getRuntime().maxMemory() - storageProperties.getBufferCacheSize() - storageProperties.getMemoryComponentGlobalBudget();
    int allCores = Runtime.getRuntime().availableProcessors();
    int maximumCoresForComputation = allCores > 1 ? allCores - 1 : allCores;
    return new NodeCapacity(memorySize, maximumCoresForComputation);
}
Also used : StorageProperties(org.apache.asterix.common.config.StorageProperties) NodeCapacity(org.apache.hyracks.api.job.resource.NodeCapacity)

Example 2 with NodeCapacity

use of org.apache.hyracks.api.job.resource.NodeCapacity 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 NodeCapacity

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

the class NodeManager method removeDeadNodes.

@Override
public Pair<Collection<String>, Collection<JobId>> removeDeadNodes() throws HyracksException {
    Set<String> deadNodes = new HashSet<>();
    Set<JobId> affectedJobIds = new HashSet<>();
    Iterator<Map.Entry<String, NodeControllerState>> nodeIterator = nodeRegistry.entrySet().iterator();
    while (nodeIterator.hasNext()) {
        Map.Entry<String, NodeControllerState> entry = nodeIterator.next();
        String nodeId = entry.getKey();
        NodeControllerState state = entry.getValue();
        if (state.incrementLastHeartbeatDuration() >= ccConfig.getHeartbeatMaxMisses()) {
            deadNodes.add(nodeId);
            affectedJobIds.addAll(state.getActiveJobIds());
            // Removes the node from node map.
            nodeIterator.remove();
            // Removes the node from IP map.
            removeNodeFromIpAddressMap(nodeId, state);
            // Updates the cluster capacity.
            resourceManager.update(nodeId, new NodeCapacity(0L, 0));
            LOGGER.info(entry.getKey() + " considered dead");
        }
    }
    return Pair.of(deadNodes, affectedJobIds);
}
Also used : NodeCapacity(org.apache.hyracks.api.job.resource.NodeCapacity) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) JobId(org.apache.hyracks.api.job.JobId) HashSet(java.util.HashSet)

Example 4 with NodeCapacity

use of org.apache.hyracks.api.job.resource.NodeCapacity 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 NodeCapacity

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

the class NodeManager method removeNode.

@Override
public void removeNode(String nodeId) throws HyracksException {
    NodeControllerState ncState = nodeRegistry.remove(nodeId);
    removeNodeFromIpAddressMap(nodeId, ncState);
    // Updates the cluster capacity.
    resourceManager.update(nodeId, new NodeCapacity(0L, 0));
}
Also used : NodeCapacity(org.apache.hyracks.api.job.resource.NodeCapacity) NodeControllerState(org.apache.hyracks.control.cc.NodeControllerState)

Aggregations

NodeCapacity (org.apache.hyracks.api.job.resource.NodeCapacity)5 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)3 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 StorageProperties (org.apache.asterix.common.config.StorageProperties)1 NetworkAddress (org.apache.hyracks.api.comm.NetworkAddress)1 JobId (org.apache.hyracks.api.job.JobId)1 IResourceManager (org.apache.hyracks.control.cc.scheduler.IResourceManager)1 ResourceManager (org.apache.hyracks.control.cc.scheduler.ResourceManager)1 NCConfig (org.apache.hyracks.control.common.controllers.NCConfig)1