use of org.ow2.proactive.resourcemanager.db.NodeSourceData in project scheduling by ow2-proactive.
the class RMCore method updateNodeSourceDescriptorWithStatusAndPersist.
private void updateNodeSourceDescriptorWithStatusAndPersist(NodeSourceDescriptor descriptor, NodeSourceStatus status) {
descriptor.setStatus(status);
NodeSourceData nodeSourceData = NodeSourceData.fromNodeSourceDescriptor(descriptor);
this.dbManager.updateNodeSource(nodeSourceData);
}
use of org.ow2.proactive.resourcemanager.db.NodeSourceData in project scheduling by ow2-proactive.
the class RMCore method persistNodeSourceAndGetDescriptor.
private NodeSourceDescriptor persistNodeSourceAndGetDescriptor(String nodeSourceName, String infrastructureType, Object[] infraParams, String policyType, Object[] policyParams, boolean nodesRecoverable) {
List<Serializable> serializableInfraParams = this.getSerializableParamsOrFail(infraParams);
List<Serializable> serializablePolicyParams = this.getSerializableParamsOrFail(policyParams);
NodeSourceData persistedNodeSource = new NodeSourceData(nodeSourceName, infrastructureType, serializableInfraParams, policyType, serializablePolicyParams, this.caller, nodesRecoverable, NodeSourceStatus.NODES_UNDEPLOYED);
boolean success = this.dbManager.addNodeSource(persistedNodeSource);
if (!success) {
this.dbManager.removeNodeSource(nodeSourceName);
}
return persistedNodeSource.toNodeSourceDescriptor();
}
use of org.ow2.proactive.resourcemanager.db.NodeSourceData in project scheduling by ow2-proactive.
the class RMCore method editNodeSource.
/**
* {@inheritDoc}
*/
@Override
public BooleanWrapper editNodeSource(String nodeSourceName, String infrastructureType, Object[] infraParams, String policyType, Object[] policyParams, boolean nodesRecoverable) {
logger.info("Edit node source " + nodeSourceName + REQUESTED_BY_STRING + this.caller.getName());
NodeSource oldNodeSource = this.getEditableNodeSourceOrFail(nodeSourceName);
NodeSourceData nodeSourceData = this.getNodeSourceToPersist(nodeSourceName, infrastructureType, infraParams, policyType, policyParams, nodesRecoverable);
this.dbManager.updateNodeSource(nodeSourceData);
try {
NodeSource newNodeSource = this.createNodeSourceInstance(nodeSourceData.toNodeSourceDescriptor());
this.definedNodeSources.put(nodeSourceName, newNodeSource);
this.emitNodeSourceEvent(newNodeSource, RMEventType.NODESOURCE_DEFINED);
logger.info(NODE_SOURCE_STRING + nodeSourceName + " has been successfully edited");
return new BooleanWrapper(true);
} catch (Exception e) {
this.dbManager.updateNodeSource(NodeSourceData.fromNodeSourceDescriptor(oldNodeSource.getDescriptor()));
this.definedNodeSources.put(nodeSourceName, oldNodeSource);
logger.warn(NODE_SOURCE_STRING + nodeSourceName + " failed to be edited. Infrastructure parameters: " + Arrays.toString(infraParams) + ". Policy parameters: " + Arrays.toString(policyParams) + ".", e);
throw e;
}
}
use of org.ow2.proactive.resourcemanager.db.NodeSourceData in project scheduling by ow2-proactive.
the class NodesRecoveryManager method recoverNodeSourcesAndNodes.
public void recoverNodeSourcesAndNodes() {
Collection<NodeSourceData> nodeSources = this.rmCore.getDbManager().getNodeSources();
this.logPersistedNodeSourceInfo(nodeSources);
for (NodeSourceData nodeSourceData : nodeSources) {
String nodeSourceName = nodeSourceData.getName();
if (RMConstants.DEFAULT_LOCAL_NODES_NODE_SOURCE_NAME.equals(nodeSourceName)) {
// will be recreated by SchedulerStarter
this.rmCore.getDbManager().removeNodeSource(nodeSourceName);
} else {
this.recoverNodeSourceSuccessfullyOrRemove(nodeSourceData, nodeSourceName);
}
}
}
use of org.ow2.proactive.resourcemanager.db.NodeSourceData in project scheduling by ow2-proactive.
the class NodeSourcesTest method createNodeSource.
private NodeSourceData createNodeSource() {
List<Serializable> infraParams = new ArrayList<>(1);
infraParams.add("infrastructure");
List<Serializable> policyParams = new ArrayList<>(1);
policyParams.add("policy");
return new NodeSourceData("ns1", DefaultInfrastructureManager.class.getName(), infraParams, StaticPolicy.class.getName(), policyParams, new Client(null, false), false, NodeSourceStatus.NODES_DEPLOYED, null);
}
Aggregations