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

feature: define number of nodes

parent eb64c3c3
Branches
Tags
No related merge requests found
......@@ -15,7 +15,6 @@ 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;
......@@ -194,7 +193,7 @@ public class HaaSClient {
private final Settings settings;
private final int numberOfNodes;
private final int numberOfCoresPerNodes;
public HaaSClient(Settings settings) {
this.settings = settings;
......@@ -202,16 +201,20 @@ public class HaaSClient {
this.timeOut = settings.getTimeout();
this.clusterNodeType = settings.getClusterNodeType();
this.projectId = settings.getProjectId();
this.numberOfNodes = settings.getNumberOfNodes();
this.numberOfCoresPerNodes = settings.getNumberOfCoresPerNode();
}
public long createJob(String name, Collection<Entry<String, String>> templateParameters) {
public long createJob(String name,int numberOfNodes, Collection<Entry<String, String>> templateParameters) {
try {
return doCreateJob(name, templateParameters);
return doCreateJob(name, numberOfNodes, templateParameters);
} catch (RemoteException | ServiceException e) {
throw new RuntimeException(e);
}
}
public long createJob(String name, Collection<Entry<String, String>> templateParameters) {
return createJob(name, 1, templateParameters);
}
public HaaSFileTransfer startFileTransfer(long jobId, TransferFileProgress notifier) {
try {
......@@ -321,12 +324,11 @@ public class HaaSClient {
getJobManagement().submitJob(jobId, getSessionID());
}
private long doCreateJob(String name, Collection<Entry<String, String>> templateParameters)
private long doCreateJob(String name, int numberOfNodes, Collection<Entry<String, String>> templateParameters)
throws RemoteException, ServiceException {
Collection<TaskSpecificationExt> taskSpec = IntStream.range(0, numberOfNodes)
.mapToObj(index -> createTaskSpecification(name + ": " + index, templateId, templateParameters))
.collect(Collectors.toList());
JobSpecificationExt jobSpecification = createJobSpecification(name, taskSpec);
Collection<TaskSpecificationExt> taskSpec = Arrays
.asList(createTaskSpecification(name + ": ", templateId, numberOfNodes, templateParameters));
JobSpecificationExt jobSpecification = createJobSpecification(name, numberOfNodes, taskSpec);
SubmittedJobInfoExt job = getJobManagement().createJob(jobSpecification, getSessionID());
return job.getId();
}
......@@ -337,11 +339,11 @@ public class HaaSClient {
return new ScpClient(fileTransfer.getServerHostname(), fileTransfer.getCredentials().getUsername(), pvtKey);
}
private JobSpecificationExt createJobSpecification(String name, Collection<TaskSpecificationExt> tasks) {
private JobSpecificationExt createJobSpecification(String name, int numberOfNodes, Collection<TaskSpecificationExt> tasks) {
JobSpecificationExt testJob = new JobSpecificationExt();
testJob.setName(name);
testJob.setMinCores(1);
testJob.setMaxCores(1);
testJob.setMinCores(numberOfCoresPerNodes * numberOfNodes);
testJob.setMaxCores(numberOfCoresPerNodes * numberOfNodes);
testJob.setPriority(JobPriorityExt.Average);
testJob.setProject(projectId);
testJob.setWaitingLimit(null);
......@@ -359,12 +361,12 @@ public class HaaSClient {
}
private TaskSpecificationExt createTaskSpecification(String name, long templateId,
Collection<Entry<String, String>> templateParameters) {
int numberOfNodes, Collection<Entry<String, String>> templateParameters) {
TaskSpecificationExt testTask = new TaskSpecificationExt();
testTask.setName(name);
testTask.setMinCores(1);
testTask.setMaxCores(1);
testTask.setMinCores(numberOfCoresPerNodes * numberOfNodes);
testTask.setMaxCores(numberOfCoresPerNodes * numberOfNodes);
testTask.setWalltimeLimit(timeOut);
testTask.setRequiredNodes(null);
testTask.setIsExclusive(false);
......
......@@ -10,5 +10,5 @@ public interface Settings {
long getClusterNodeType();
String getProjectId();
String getJobName();
int getNumberOfNodes();
int getNumberOfCoresPerNode();
}
......@@ -6,7 +6,7 @@ public interface SettingsProvider {
return getSettings(templateId, timeOut, clusterNodeType, projectId, 1, configFileName);
}
static Settings getSettings(long templateId, int timeOut, long clusterNodeType, String projectId, int numberOfNodes,String configFileName) {
static Settings getSettings(long templateId, int timeOut, long clusterNodeType, String projectId, int numberOfCores,String configFileName) {
Constants constants = new Constants(configFileName);
return new Settings() {
......@@ -56,8 +56,8 @@ public interface SettingsProvider {
}
@Override
public int getNumberOfNodes() {
return numberOfNodes;
public int getNumberOfCoresPerNode() {
return numberOfCores;
}
};
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment