Search in sources :

Example 1 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class NodeSource method buildRMNodeAfterRecovery.

/**
 * Rebuild a RMNode from a node that could be looked up again after a
 * recovery of the RM. This builder configures nothing for the node
 * because it is configured already as it suppoesed to be recovered from
 * the database.
 * @return the expected RMNode
 */
private RMNode buildRMNodeAfterRecovery(Node node, RMNodeData rmNodeData) {
    RMNodeImpl rmNode = new RMNodeImpl(node, stub, rmNodeData.getName(), rmNodeData.getNodeUrl(), rmNodeData.getProvider(), rmNodeData.getHostname(), rmNodeData.getJmxUrls(), rmNodeData.getJvmName(), rmNodeData.getUserPermission(), rmNodeData.getState(), rmNodeData.getTags());
    if (rmNodeData.getState().equals(NodeState.BUSY)) {
        logger.info("Node " + rmNodeData.getName() + " was found busy after scheduler recovery with owner " + rmNodeData.getOwner());
        rmNode.setBusy(rmNodeData.getOwner(), rmNodeData.getUsageInfo());
    }
    return rmNode;
}
Also used : RMNodeImpl(org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)

Example 2 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class NodeSource method internalAddNodeAfterRecovery.

/**
 * Recover the internal data structure of the node source so that
 * recovered nodes and RMnodes are linked again to the node source.
 * @return the {@link RMNode} that could be recovered.
 */
public RMNode internalAddNodeAfterRecovery(Node node, RMNodeData rmNodeData) {
    RMNode recoveredRmNode;
    String nodeUrl = rmNodeData.getNodeUrl();
    // the infrastructure manager is up to date already because it was
    // saved in database, contrarily to the node source internal data structures
    RMNode rmNode = infrastructureManager.searchForNotAcquiredRmNode(nodeUrl);
    if (rmNode != null) {
        // Deploying or lost RMNodes can be directly found in the saved infrastructure.
        recoveredRmNode = rmNode;
    } else {
        // the node is acquired in the infrastructure. We can recover the
        // RMNode representation on top of it and save it in the node source
        recoveredRmNode = buildRMNodeAfterRecovery(node, rmNodeData);
    }
    // we finally put back the node in the data structure of the node source
    if (rmNodeData.getState().equals(NodeState.DOWN)) {
        downNodes.put(nodeUrl, node);
    } else {
        nodes.put(nodeUrl, node);
    }
    return recoveredRmNode;
}
Also used : RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) AbstractRMNode(org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)

Example 3 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class NodesRecoveryManager method recoverNodes.

public void recoverNodes(NodeSource nodeSource) {
    // this log line is important for performance tests
    logger.info(START_TO_RECOVER_NODES);
    String nodeSourceName = nodeSource.getName();
    Collection<RMNodeData> nodesData = this.rmCore.getDbManager().getNodesByNodeSource(nodeSourceName);
    logger.info("Number of nodes found in database for node source " + nodeSourceName + ": " + nodesData.size());
    List<RMNode> recoveredEligibleNodes = Collections.synchronizedList(new ArrayList<>());
    Map<NodeState, Integer> recoveredNodeStatesCounter = new HashMap<>();
    // for each node found in database, try to lookup node or recover it
    // as down node
    ExecutorService nodeRecoveryThreadPool = PAExecutors.newCachedBoundedThreadPool(1, PAResourceManagerProperties.RM_NODESOURCE_MAX_THREAD_NUMBER.getValueAsInt(), 120L, TimeUnit.SECONDS, new NamedThreadFactory("NodeRecoveryThreadPool"));
    List<Future<RMNode>> nodesFutures = new ArrayList<>(nodesData.size());
    for (RMNodeData rmNodeData : nodesData) {
        nodesFutures.add(nodeRecoveryThreadPool.submit(() -> this.recoverNode(rmNodeData, nodeSource, recoveredNodeStatesCounter)));
    }
    for (Future<RMNode> rmNodeFuture : nodesFutures) {
        RMNode node = null;
        try {
            node = rmNodeFuture.get();
        } catch (Exception e) {
            logger.error("Unexpected error occurred while recovering node source " + nodeSource.getName(), e);
            nodeRecoveryThreadPool.shutdownNow();
            return;
        }
        if (this.isEligible(node)) {
            recoveredEligibleNodes.add(node);
        }
        if (node != null) {
            final RMNodeEvent event = node.createNodeEvent(RMEventType.NODE_ADDED, null, node.getProvider().getName());
            this.rmCore.registerAndEmitNodeEvent(event);
        }
    }
    nodeRecoveryThreadPool.shutdownNow();
    this.rmCore.addEligibleNodesToRecover(recoveredEligibleNodes);
    this.logNodeRecoverySummary(nodeSourceName, recoveredNodeStatesCounter, recoveredEligibleNodes.size());
}
Also used : NodeState(org.ow2.proactive.resourcemanager.common.NodeState) HashMap(java.util.HashMap) NamedThreadFactory(org.objectweb.proactive.utils.NamedThreadFactory) ArrayList(java.util.ArrayList) AddingNodesException(org.ow2.proactive.resourcemanager.exception.AddingNodesException) RMNode(org.ow2.proactive.resourcemanager.rmnode.RMNode) RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData) ExecutorService(java.util.concurrent.ExecutorService) Future(java.util.concurrent.Future) RMNodeEvent(org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)

Example 4 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerTest method addNRMNodeData.

private Map<String, RMNodeData> addNRMNodeData(int nbEntries) {
    Map<String, RMNodeData> entries = new HashMap<>();
    for (int i = 0; i < nbEntries; i++) {
        RMNodeData rmNodeData = addRMNodeData(NODE_NAME_BASE + i, NODE_STATE_BASE);
        entries.put(NODE_NAME_BASE + i, rmNodeData);
    }
    return entries;
}
Also used : HashMap(java.util.HashMap) RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData)

Example 5 with RMNodeData

use of org.ow2.proactive.resourcemanager.db.RMNodeData in project scheduling by ow2-proactive.

the class RMDBManagerBufferTest method addRMNodeData.

private RMNodeData addRMNodeData(String nodeName, NodeState state) {
    RMNodeData rmNodeData = new RMNodeData(nodeName, NODE_URL, owner, provider, permission, state, STATE_CHANGE_TIME_BASE, HOSTNAME, JMX_URLS, JVM_NAME);
    rmNodeData.setNodeSource(nodeSourceData);
    dbManager.addNode(rmNodeData, NODE_SOURCE_NAME_BASE);
    return rmNodeData;
}
Also used : RMNodeData(org.ow2.proactive.resourcemanager.db.RMNodeData)

Aggregations

RMNodeData (org.ow2.proactive.resourcemanager.db.RMNodeData)19 Test (org.junit.Test)12 RMNode (org.ow2.proactive.resourcemanager.rmnode.RMNode)7 HashMap (java.util.HashMap)3 NodeState (org.ow2.proactive.resourcemanager.common.NodeState)3 AddingNodesException (org.ow2.proactive.resourcemanager.exception.AddingNodesException)3 Node (org.objectweb.proactive.core.node.Node)2 NodeSourceData (org.ow2.proactive.resourcemanager.db.NodeSourceData)2 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 NamedThreadFactory (org.objectweb.proactive.utils.NamedThreadFactory)1 RMNodeEvent (org.ow2.proactive.resourcemanager.common.event.RMNodeEvent)1 AbstractRMNode (org.ow2.proactive.resourcemanager.rmnode.AbstractRMNode)1 RMNodeImpl (org.ow2.proactive.resourcemanager.rmnode.RMNodeImpl)1