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

Fix: create method getHaaSClient

parent 3c1fc6c3
No related branches found
No related tags found
1 merge request!14Iss1026
...@@ -56,7 +56,7 @@ public class Job { ...@@ -56,7 +56,7 @@ public class Job {
public Job(JobManager4Job jobManager, String name, Path basePath, Supplier<HaaSClient> haasClientSupplier) throws IOException { public Job(JobManager4Job jobManager, String name, Path basePath, Supplier<HaaSClient> haasClientSupplier) throws IOException {
this(jobManager,haasClientSupplier); this(jobManager,haasClientSupplier);
HaaSClient client = this.haasClientSupplier.get(); HaaSClient client = getHaaSClient();
long id = client.createJob(name, Collections.emptyList()); long id = client.createJob(name, Collections.emptyList());
jobDir = basePath.resolve("" + id); jobDir = basePath.resolve("" + id);
propertyHolder = new PropertyHolder(jobDir.resolve(JOB_INFO_FILE)); propertyHolder = new PropertyHolder(jobDir.resolve(JOB_INFO_FILE));
...@@ -76,7 +76,7 @@ public class Job { ...@@ -76,7 +76,7 @@ public class Job {
} }
public void uploadFiles(Iterable<UploadingFile> files, Progress notifier) { public void uploadFiles(Iterable<UploadingFile> files, Progress notifier) {
HaaSClient client = this.haasClientSupplier.get(); HaaSClient client = getHaaSClient();
try(HaaSFileTransfer transfer = client.startFileTransfer(getId(), new P_ProgressNotifierAdapter(notifier))){ try(HaaSFileTransfer transfer = client.startFileTransfer(getId(), new P_ProgressNotifierAdapter(notifier))){
transfer.upload(files); transfer.upload(files);
} }
...@@ -89,7 +89,7 @@ public class Job { ...@@ -89,7 +89,7 @@ public class Job {
} }
public void submit() { public void submit() {
HaaSClient client = this.haasClientSupplier.get(); HaaSClient client = getHaaSClient();
client.submitJob(jobId); client.submitJob(jobId);
} }
...@@ -120,8 +120,8 @@ public class Job { ...@@ -120,8 +120,8 @@ public class Job {
} }
synchronized public void download(Predicate<String> predicate, Progress notifier) { synchronized public void download(Predicate<String> predicate, Progress notifier) {
try (HaaSFileTransfer fileTransfer = haasClientSupplier.get().startFileTransfer(jobId, new P_ProgressNotifierAdapter(notifier))) { try (HaaSFileTransfer fileTransfer = getHaaSClient().startFileTransfer(jobId, new P_ProgressNotifierAdapter(notifier))) {
fileTransfer.download(haasClientSupplier.get().getChangedFiles(jobId).stream().filter(predicate).collect(Collectors.toList()), jobDir); fileTransfer.download(getHaaSClient().getChangedFiles(jobId).stream().filter(predicate).collect(Collectors.toList()), jobDir);
} }
} }
...@@ -145,7 +145,7 @@ public class Job { ...@@ -145,7 +145,7 @@ public class Job {
HaaSClient.SynchronizableFiles taskFileOffset = new HaaSClient.SynchronizableFiles(); HaaSClient.SynchronizableFiles taskFileOffset = new HaaSClient.SynchronizableFiles();
long taskId = (Long) getJobInfo().getTasks().toArray()[0]; long taskId = (Long) getJobInfo().getTasks().toArray()[0];
output.forEach(file -> taskFileOffset.addFile(taskId, file.getType(), file.getOffset())); output.forEach(file -> taskFileOffset.addFile(taskId, file.getType(), file.getOffset()));
return haasClientSupplier.get().downloadPartsOfJobFiles(jobId, taskFileOffset).stream().map(f -> f.getContent()) return getHaaSClient().downloadPartsOfJobFiles(jobId, taskFileOffset).stream().map(f -> f.getContent())
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
...@@ -186,6 +186,10 @@ public class Job { ...@@ -186,6 +186,10 @@ public class Job {
return result; return result;
} }
private HaaSClient getHaaSClient() {
return this.haasClientSupplier.get();
}
private JobInfo getJobInfo() { private JobInfo getJobInfo() {
if (jobInfo == null) { if (jobInfo == null) {
updateJobInfo(); updateJobInfo();
...@@ -194,7 +198,7 @@ public class Job { ...@@ -194,7 +198,7 @@ public class Job {
} }
private void updateJobInfo() { private void updateJobInfo() {
jobInfo = haasClientSupplier.get().obtainJobInfo(getId()); jobInfo = getHaaSClient().obtainJobInfo(getId());
} }
private static boolean isValidPath(Path path) { private static boolean isValidPath(Path path) {
...@@ -245,22 +249,22 @@ public class Job { ...@@ -245,22 +249,22 @@ public class Job {
} }
public Collection<String> getChangedFiles() { public Collection<String> getChangedFiles() {
return haasClientSupplier.get().getChangedFiles(getId()); return getHaaSClient().getChangedFiles(getId());
} }
public void cancelJob() { public void cancelJob() {
haasClientSupplier.get().cancelJob(jobId); getHaaSClient().cancelJob(jobId);
} }
public List<Long> getFileSizes(List<String> names) { public List<Long> getFileSizes(List<String> names) {
try (HaaSFileTransfer transfer = haasClientSupplier.get().startFileTransfer(getId(), new DummyProgressNotifier())) { try (HaaSFileTransfer transfer = getHaaSClient().startFileTransfer(getId(), new DummyProgressNotifier())) {
return transfer.obtainSize(names); return transfer.obtainSize(names);
} }
} }
public List<String> getFileContents(List<String> logs) { public List<String> getFileContents(List<String> logs) {
try (HaaSFileTransfer transfer = haasClientSupplier.get().startFileTransfer(getId(), new DummyProgressNotifier())) { try (HaaSFileTransfer transfer = getHaaSClient().startFileTransfer(getId(), new DummyProgressNotifier())) {
return transfer.getContent(logs); return transfer.getContent(logs);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment