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