Skip to content
Snippets Groups Projects
Commit e50da487 authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

set number of nodes

parent c682eacb
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ import java.util.LinkedList;
import java.util.Map;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.xml.rpc.ServiceException;
......@@ -193,12 +194,15 @@ public class HaaSClient {
private final Settings settings;
private final int numberOfNodes;
public HaaSClient(Settings settings) {
this.settings = settings;
this.templateId = settings.getTemplateId();
this.timeOut = settings.getTimeout();
this.clusterNodeType = settings.getClusterNodeType();
this.projectId = settings.getProjectId();
this.numberOfNodes = settings.getNumberOfNodes();
}
public long createJob(String name, Collection<Entry<String, String>> templateParameters) {
......@@ -315,8 +319,10 @@ public class HaaSClient {
private long doCreateJob(String name, Collection<Entry<String, String>> templateParameters)
throws RemoteException, ServiceException {
TaskSpecificationExt taskSpec = createTaskSpecification(name, templateId, templateParameters);
JobSpecificationExt jobSpecification = createJobSpecification(name, Arrays.asList(taskSpec));
Collection<TaskSpecificationExt> taskSpec = IntStream.range(0, numberOfNodes)
.mapToObj(index -> createTaskSpecification(name + ": " + index, templateId, templateParameters))
.collect(Collectors.toList());
JobSpecificationExt jobSpecification = createJobSpecification(name, taskSpec);
SubmittedJobInfoExt job = getJobManagement().createJob(jobSpecification, getSessionID());
return job.getId();
}
......@@ -344,6 +350,7 @@ public class HaaSClient {
testJob.setClusterNodeTypeId(clusterNodeType);
testJob.setEnvironmentVariables(new EnvironmentVariableExt[0]);
testJob.setTasks(tasks.stream().toArray(TaskSpecificationExt[]::new));
return testJob;
}
......@@ -370,7 +377,6 @@ public class HaaSClient {
testTask.setTemplateParameterValues(templateParameters.stream()
.map(pair -> new CommandTemplateParameterValueExt(pair.getKey(), pair.getValue()))
.toArray(CommandTemplateParameterValueExt[]::new));
return testTask;
}
......
......@@ -10,4 +10,5 @@ public interface Settings {
long getClusterNodeType();
String getProjectId();
String getJobName();
int getNumberOfNodes();
}
......@@ -3,6 +3,10 @@ package cz.it4i.fiji.haas_java_client;
public interface SettingsProvider {
static Settings getSettings(long templateId, int timeOut, long clusterNodeType, String projectId, String configFileName) {
return getSettings(templateId, timeOut, clusterNodeType, projectId, 1, configFileName);
}
static Settings getSettings(long templateId, int timeOut, long clusterNodeType, String projectId, int numberOfNodes,String configFileName) {
Constants constants = new Constants(configFileName);
return new Settings() {
......@@ -50,6 +54,11 @@ public interface SettingsProvider {
public String getJobName() {
return "TestOutRedirect";
}
@Override
public int getNumberOfNodes() {
return numberOfNodes;
}
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment