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