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