use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMRest method createNodeSource.
/**
* @deprecated As of version 8.1, replaced by {@link #defineNodeSource(String, String,String, String[], String[],
* String, String[], String[], String)} and {@link #deployNodeSource(String, String)}
*
* Create a NodeSource
* <p>
*
* @param sessionId
* current session id
* @param nodeSourceName
* name of the node source to create
* @param infrastructureType
* fully qualified class name of the infrastructure to create
* @param infrastructureParameters
* String parameters of the infrastructure, without the
* parameters containing files or credentials
* @param infrastructureFileParameters
* File or credential parameters
* @param policyType
* fully qualified class name of the policy to create
* @param policyParameters
* String parameters of the policy, without the parameters
* containing files or credentials
* @param policyFileParameters
* File or credential parameters
* @param nodesRecoverable
* Whether the nodes can be recovered after a crash of the RM
* @return true if a node source has been created
* @throws NotConnectedException
*/
@Deprecated
@Override
@POST
@Path("nodesource/create/recovery")
@Produces("application/json")
public NSState createNodeSource(@HeaderParam("sessionid") String sessionId, @FormParam("nodeSourceName") String nodeSourceName, @FormParam("infrastructureType") String infrastructureType, @FormParam("infrastructureParameters") String[] infrastructureParameters, @FormParam("infrastructureFileParameters") String[] infrastructureFileParameters, @FormParam("policyType") String policyType, @FormParam("policyParameters") String[] policyParameters, @FormParam("policyFileParameters") String[] policyFileParameters, @FormParam("nodesRecoverable") String nodesRecoverable) throws NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
NSState nsState = new NSState();
Object[] allInfrastructureParameters = this.getAllInfrastructureParameters(infrastructureType, infrastructureParameters, infrastructureFileParameters, rm);
Object[] allPolicyParameters = this.getAllPolicyParameters(policyType, policyParameters, policyFileParameters, rm);
try {
nsState.setResult(rm.createNodeSource(nodeSourceName, infrastructureType, allInfrastructureParameters, policyType, allPolicyParameters, Boolean.parseBoolean(nodesRecoverable)).getBooleanValue());
} catch (RuntimeException ex) {
nsState.setResult(false);
nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
} finally {
return nsState;
}
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class RMRest method undeployNodeSource.
/**
* Remove the nodes of the node source and keep the node source undeployed
*
* @param sessionId a valid session id
* @param nodeSourceName the name of the node source to undeploy
* @return the result of the action, possibly containing the error message
* @throws NotConnectedException
*/
@Override
@PUT
@Path("nodesource/undeploy")
@Produces("application/json")
public NSState undeployNodeSource(@HeaderParam("sessionid") String sessionId, @FormParam("nodeSourceName") String nodeSourceName, @FormParam("preempt") boolean preempt) throws NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
NSState nsState = new NSState();
try {
nsState.setResult(rm.undeployNodeSource(nodeSourceName, preempt).getBooleanValue());
} catch (RuntimeException ex) {
nsState.setResult(false);
nsState.setErrorMessage(cleanDisplayedErrorMessage(ex.getMessage()));
nsState.setStackTrace(StringEscapeUtils.escapeJson(getStackTrace(ex)));
}
return nsState;
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class CommandLineBuilder method buildCommandLineAsList.
/**
* Same as {@link CommandLineBuilder#buildCommandLine(boolean)} but the command is a list of String.
* @param displayCredentials if true displays the credentials in the command line if false, obfuscates them
* @return The RMNodeStarter command line as a list of String.
* @throws java.io.IOException if you supplied a ProActive Configuration file that doesn't exist.
*/
public List<String> buildCommandLineAsList(boolean displayCredentials) throws IOException {
final ArrayList<String> command = new ArrayList<>();
final OperatingSystem os = targetOS;
final Properties paProp = paPropProperties;
String rmHome = this.getRmHome();
if (rmHome != null) {
if (!rmHome.endsWith(os.fs)) {
rmHome = rmHome + os.fs;
}
} else {
rmHome = "";
}
if (detached) {
makeDetachedCommand(command, os);
}
final String libRoot = rmHome + "dist" + os.fs + "lib" + os.fs;
String javaPath = this.javaPath;
if (javaPath != null) {
command.add(javaPath);
} else {
RMNodeStarter.logger.warn("Java path isn't set in RMNodeStarter configuration.");
command.add("java");
}
// building configuration
if (paProp != null) {
Set<Object> keys = paProp.keySet();
for (Object key : keys) {
command.add("-D" + key + "=" + paProp.get(key));
}
} else {
if (this.paPropList != null) {
command.addAll(this.paPropList);
}
}
// forward current charset to the forked JVM
String currentJvmCharset = PAProperties.getFileEncoding();
command.add("-Dfile.encoding=" + currentJvmCharset);
RMNodeStarter.logger.info("Using '" + currentJvmCharset + "' as file encoding");
// building classpath
command.add("-cp");
final StringBuilder classpath = new StringBuilder(".");
// add the content of addons dir on the classpath
classpath.append(os.ps).append(rmHome).append(ADDONS_DIR);
// add jars inside the addons directory
classpath.append(os.ps).append(rmHome).append(ADDONS_DIR).append(os.fs).append("*");
classpath.append(os.ps).append(libRoot).append("*");
command.add(classpath.toString());
command.add(RMNodeStarter.class.getName());
// appending options
String credsEnv = credentialsEnv;
if (credsEnv != null) {
command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_ENV);
command.add(credsEnv);
}
String credsFile = this.getCredentialsFile();
if (credsFile != null) {
command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_FILE);
command.add(credsFile);
}
String credsValue = this.getCredentialsValue();
if (credsValue != null) {
command.add("-" + RMNodeStarter.OPTION_CREDENTIAL_VAL);
command.add(displayCredentials ? credsValue : OBFUSC);
}
String nodename = this.getNodeName();
if (nodename != null) {
command.add("-" + RMNodeStarter.OPTION_NODE_NAME);
command.add(nodename);
}
String nodesource = this.getSourceName();
if (nodesource != null) {
command.add("-" + RMNodeStarter.OPTION_SOURCE_NAME);
command.add(nodesource);
}
String rmurl = rmURL;
if (rmurl != null) {
command.add("-" + RMNodeStarter.OPTION_RM_URL);
command.add(rmurl);
}
command.add("-" + RMNodeStarter.OPTION_WORKERS);
command.add("" + nbNodes);
if (detached && os.equals(OperatingSystem.UNIX)) {
command.add("&");
}
return command;
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodesRecoveryManager method recoverFullyDeployedInfrastructureOrReset.
protected boolean recoverFullyDeployedInfrastructureOrReset(String nodeSourceName, NodeSource nodeSourceToDeploy, NodeSourceDescriptor descriptor) {
boolean recoverNodes = false;
boolean existPersistedNodes = this.existPersistedNodes(nodeSourceName);
if (existPersistedNodes) {
InfrastructureManager im = InfrastructureManagerFactory.recover(descriptor);
if (!im.getDeployingAndLostNodes().isEmpty()) {
// if there are deploying nodes, we will not recover
this.rmCore.getDbManager().removeAllNodesFromNodeSource(nodeSourceName);
} else {
recoverNodes = true;
nodeSourceToDeploy.setInfrastructureManager(im);
}
}
return recoverNodes;
}
use of org.ow2.proactive.resourcemanager.nodesource.NodeSource in project scheduling by ow2-proactive.
the class NodesRecoveryManager method recoverNodes.
protected void recoverNodes(NodeSource nodeSource) {
// this log line is important for performance tests
logger.info(START_TO_RECOVER_NODES);
int lookUpTimeout = PAResourceManagerProperties.RM_NODELOOKUP_TIMEOUT.getValueAsInt();
String nodeSourceName = nodeSource.getName();
this.logWarnIfNodeSourceHasNoNode(nodeSource, nodeSourceName);
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<RMNode>());
Map<NodeState, Integer> recoveredNodeStatesCounter = new HashMap<>();
// as down node
for (RMNodeData rmNodeData : nodesData) {
String nodeUrl = rmNodeData.getNodeUrl();
Node node = this.tryToLookupNode(nodeSource, lookUpTimeout, nodeUrl);
RMNode rmnode = this.recoverRMNode(nodeSource, recoveredNodeStatesCounter, rmNodeData, nodeUrl, node);
if (this.isEligible(rmnode)) {
recoveredEligibleNodes.add(rmnode);
}
}
this.rmCore.setEligibleNodesToRecover(recoveredEligibleNodes);
this.logNodeRecoverySummary(nodeSourceName, recoveredNodeStatesCounter, recoveredEligibleNodes.size());
}
Aggregations