use of org.ow2.proactive_grid_cloud_portal.cli.json.FieldMetaDataView.Type in project scheduling by ow2-proactive.
the class SchedulerStateRest method valueOfTaskResult.
/**
* Returns the value of the task result of task <code>taskName</code> of the
* job <code>jobId</code> <strong>the result is deserialized before sending
* to the client, if the class is not found the content is replaced by the
* string 'Unknown value type' </strong>. To get the serialized form of a
* given result, one has to call the following restful service
* jobs/{jobid}/tasks/{taskname}/result/serializedvalue
*
* @param sessionId
* a valid session id
* @param jobId
* the id of the job
* @param taskname
* the name of the task
* @return the value of the task result
*/
@Override
@GET
@GZIP
@Path("jobs/{jobid}/tasks/{taskname}/result/value")
@Produces("*/*")
public Serializable valueOfTaskResult(@HeaderParam("sessionid") String sessionId, @PathParam("jobid") String jobId, @PathParam("taskname") String taskname) throws Throwable {
Scheduler s = checkAccess(sessionId, "jobs/" + jobId + "/tasks/" + taskname + "/result/value");
TaskResult taskResult = s.getTaskResult(jobId, taskname);
return getTaskResultValueAsStringOrExceptionStackTrace(taskResult);
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.FieldMetaDataView.Type in project scheduling by ow2-proactive.
the class RMCore method executeScript.
/**
* {@inheritDoc}
*/
public <T> List<ScriptResult<T>> executeScript(Script<T> script, String targetType, Set<String> targets) {
// Depending on the target type, select nodes for script execution
final TargetType tType = TargetType.valueOf(targetType);
final HashSet<RMNode> selectedRMNodes = new HashSet<>();
switch(tType) {
case NODESOURCE_NAME:
// If target is a nodesource name select all its nodes
for (String target : targets) {
NodeSource nodeSource = this.deployedNodeSources.get(target);
if (nodeSource != null) {
for (RMNode candidateNode : this.allNodes.values()) {
if (candidateNode.getNodeSource().equals(nodeSource)) {
this.selectCandidateNode(selectedRMNodes, candidateNode);
}
}
}
}
break;
case NODE_URL:
// If target is node url select the node
for (String target : targets) {
RMNode candidateNode = this.allNodes.get(target);
if (candidateNode != null) {
this.selectCandidateNode(selectedRMNodes, candidateNode);
}
}
break;
case HOSTNAME:
// If target is hostname select first node from that host
for (String target : targets) {
for (RMNode node : this.allNodes.values()) {
if (node.getHostName().equals(target)) {
this.selectCandidateNode(selectedRMNodes, node);
break;
}
}
}
break;
default:
throw new IllegalArgumentException("Unable to execute script, unknown target type: " + targetType);
}
// Return a ProActive future on the list of results
return this.selectionManager.executeScript(script, selectedRMNodes, null);
// To avoid blocking rmcore ao the call is delegated to the selection
// manager ao and each node is unlocked as soon as the script has
// finished it's execution.
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.FieldMetaDataView.Type in project scheduling by ow2-proactive.
the class SSHInfrastructureV2 method configure.
/**
* Configures the Infrastructure
*
* @param parameters
* parameters[4] : ssh server port parameters[5] : ssh username
* parameters[6] : ssh password parameters[7] : ssh private key
* parameters[8] : optional ssh options file parameters[9] : java
* path on the remote machines parameters[10] : Scheduling path on
* remote machines parameters[11] : target OS' type (Linux,
* Windows or Cygwin) parameters[12] : extra java options
* @throws IllegalArgumentException
* configuration failed
*/
@Override
public void configure(Object... parameters) {
super.configure(parameters);
int index = 4;
if (parameters == null || parameters.length < 12) {
throw new IllegalArgumentException("Invalid parameters for infrastructure creation");
}
try {
this.sshPort = Integer.parseInt(parameters[index++].toString());
} catch (NumberFormatException e) {
throw new IllegalArgumentException("A valid port for ssh must be supplied");
}
this.sshUsername = parameters[index++].toString();
if (this.sshUsername == null || this.sshUsername.equals("")) {
throw new IllegalArgumentException("A valid ssh username must be supplied");
}
this.sshPassword = parameters[index++].toString();
this.sshPrivateKey = (byte[]) parameters[index++];
if (this.sshPassword.equals("")) {
if (this.sshPrivateKey.length == 0)
throw new IllegalArgumentException("If no password a valid private key must be supplied");
else
this.sshPassword = null;
}
this.sshOptions = new Properties();
byte[] bytes = (byte[]) parameters[index++];
if (bytes.length == 0) {
this.sshOptions.put("StrictHostKeyChecking", "no");
} else {
try {
this.sshOptions.load(new ByteArrayInputStream(bytes));
} catch (IOException e) {
throw new IllegalArgumentException("Could not read ssh options file", e);
}
}
this.javaPath = parameters[index++].toString();
if (this.javaPath == null || this.javaPath.equals("")) {
throw new IllegalArgumentException("A valid Java path must be supplied");
}
this.schedulingPath = parameters[index++].toString();
if (this.schedulingPath == null || this.schedulingPath.equals("")) {
throw new IllegalArgumentException("A valid path of the scheduling dir must be supplied");
}
// target OS
if (parameters[index] == null) {
throw new IllegalArgumentException("Target OS parameter cannot be null");
}
OperatingSystem configuredTargetOs = OperatingSystem.getOperatingSystem(parameters[index++].toString());
if (configuredTargetOs == null) {
throw new IllegalArgumentException("Only 'Linux', 'Windows' and 'Cygwin' are valid values for Target OS Property.");
}
persistedInfraVariables.put(TARGET_OS_OBJ_KEY, configuredTargetOs);
this.javaOptions = parameters[index++].toString();
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.FieldMetaDataView.Type in project scheduling by ow2-proactive.
the class FileSystem method list.
public static ListFile list(FileObject fo, List<String> includes, List<String> excludes) throws FileSystemException {
fo.refresh();
ListFile answer = new ListFile();
List<String> dirList = Lists.newArrayList();
List<String> fileList = Lists.newArrayList();
List<String> fullList = Lists.newArrayList();
List<FileObject> foundFileObjects = new LinkedList<>();
if (isNullOrEmpty(includes) && isNullOrEmpty(excludes)) {
fo.findFiles(Selectors.SELECT_CHILDREN, false, foundFileObjects);
} else {
FileSelector selector = new org.objectweb.proactive.extensions.dataspaces.vfs.selector.FileSelector(includes, excludes);
fo.findFiles(selector, false, foundFileObjects);
}
for (FileObject child : foundFileObjects) {
FileType type = child.getType();
FileName childName = child.getName();
switch(type) {
case FOLDER:
if (!child.equals(fo)) {
// exclude root directory from the list
String relativePath = fo.getName().getRelativeName(childName);
dirList.add(relativePath);
fullList.add(relativePath);
}
break;
case FILE:
String relativePath = fo.getName().getRelativeName(childName);
fileList.add(relativePath);
fullList.add(relativePath);
break;
default:
throw new RuntimeException("Unknown : " + type);
}
}
Collections.sort(dirList);
Collections.sort(fileList);
Collections.sort(fullList);
answer.setDirectoryListing(dirList);
answer.setFileListing(fileList);
answer.setFullListing(fullList);
return answer;
}
use of org.ow2.proactive_grid_cloud_portal.cli.json.FieldMetaDataView.Type in project scheduling by ow2-proactive.
the class SetInfrastructureCommand method execute.
@Override
public void execute(ApplicationContext currentContext) throws CLIException {
Map<String, PluginView> infrastructures = currentContext.getInfrastructures();
if (infrastructures == null) {
HttpGet request = new HttpGet(currentContext.getResourceUrl("infrastructures"));
HttpResponseWrapper response = execute(request, currentContext);
if (statusCode(OK) == statusCode(response)) {
infrastructures = new HashMap<>();
List<PluginView> pluginViewList = readValue(response, new TypeReference<List<PluginView>>() {
}, currentContext);
for (PluginView pluginView : pluginViewList) {
infrastructures.put(pluginView.getPluginName(), pluginView);
}
currentContext.setInfrastructures(infrastructures);
} else {
handleError("Unable to retrieve known infrastructure types:", response, currentContext);
}
}
if (infrastructures != null) {
PluginView pluginView = infrastructures.get(infrastructureType);
if (pluginView == null) {
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("Unknown infrastructure type: %s", infrastructureType));
}
ConfigurableFieldView[] configurableFields = pluginView.getConfigurableFields();
if (configurableFields.length != infrastructureArgs.length) {
throw new CLIException(REASON_INVALID_ARGUMENTS, String.format("Invalid number of arguments specified for '%s' type.", infrastructureType));
}
QueryStringBuilder queryStringBuilder = new QueryStringBuilder();
queryStringBuilder.add("infrastructureType", infrastructureType);
for (int index = 0; index < configurableFields.length; index++) {
ConfigurableFieldView cf = configurableFields[index];
Type ft = cf.getMeta().type();
if (FILEBROWSER.equals(ft) || CREDENTIAL.equals(ft)) {
if ("".equals(infrastructureArgs[index])) {
String contents = "";
queryStringBuilder.add("infrastructureFileParameters", contents);
} else {
String contents = FileUtility.readFileToString(new File(infrastructureArgs[index]));
queryStringBuilder.add("infrastructureFileParameters", contents);
}
} else {
queryStringBuilder.add("infrastructureParameters", infrastructureArgs[index]);
}
}
currentContext.setProperty(SET_INFRASTRUCTURE, queryStringBuilder);
}
}
Aggregations