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

refactoring

parent beacc8a4
No related branches found
No related tags found
No related merge requests found
...@@ -81,8 +81,6 @@ public class HaaSClient { ...@@ -81,8 +81,6 @@ public class HaaSClient {
private String sessionID; private String sessionID;
private Path workDirectory;
private UserAndLimitationManagementWsSoap userAndLimitationManagement; private UserAndLimitationManagementWsSoap userAndLimitationManagement;
private JobManagementWsSoap jobManagement; private JobManagementWsSoap jobManagement;
...@@ -111,9 +109,8 @@ public class HaaSClient { ...@@ -111,9 +109,8 @@ public class HaaSClient {
WS_STATE2STATE = Collections.unmodifiableMap(map); WS_STATE2STATE = Collections.unmodifiableMap(map);
} }
public HaaSClient(Path workDirectory, Long templateId, Integer timeOut,Long clusterNodeType, String projectId) { public HaaSClient(Long templateId, Integer timeOut,Long clusterNodeType, String projectId) {
super(); super();
this.workDirectory = workDirectory;
this.templateId = templateId; this.templateId = templateId;
this.timeOut = timeOut; this.timeOut = timeOut;
this.clusterNodeType = clusterNodeType; this.clusterNodeType = clusterNodeType;
...@@ -181,7 +178,7 @@ public class HaaSClient { ...@@ -181,7 +178,7 @@ public class HaaSClient {
} }
} }
public void download(long jobId) { public void download(long jobId, Path workDirectory) {
try { try {
FileTransferMethodExt ft = getFileTransfer().getFileTransferMethod(jobId, getSessionID()); FileTransferMethodExt ft = getFileTransfer().getFileTransferMethod(jobId, getSessionID());
try (ScpClient scpClient = getScpClient(ft)) { try (ScpClient scpClient = getScpClient(ft)) {
......
package cz.it4i.fiji.haas_java_client; package cz.it4i.fiji.haas_java_client;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.rmi.RemoteException;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -14,11 +16,16 @@ import cz.it4i.fiji.haas_java_client.proxy.JobFileContentExt; ...@@ -14,11 +16,16 @@ import cz.it4i.fiji.haas_java_client.proxy.JobFileContentExt;
public class TestHaaSJavaClient { public class TestHaaSJavaClient {
public static void main(String[] args) throws RemoteException, ServiceException { public static void main(String[] args) throws ServiceException, IOException {
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
params.put("inputParam", "someStringParam"); params.put("inputParam", "someStringParam");
HaaSClient client = new HaaSClient(Paths.get("/home/koz01/aaa"), 1l,600, 7l,"DD-17-31"); Path baseDir = Paths.get("/home/koz01/aaa");
HaaSClient client = new HaaSClient( 1l,600, 7l,"DD-17-31");
long jobId = client.start(Arrays.asList(Paths.get("/home/koz01/aaa/vecmath.jar")), "TestOutRedirect", params.entrySet()); long jobId = client.start(Arrays.asList(Paths.get("/home/koz01/aaa/vecmath.jar")), "TestOutRedirect", params.entrySet());
Path workDir = baseDir.resolve("" + jobId);
if (!Files.isDirectory(workDir)) {
Files.createDirectories(workDir);
}
JobInfo info; JobInfo info;
do { do {
try { try {
...@@ -33,7 +40,7 @@ public class TestHaaSJavaClient { ...@@ -33,7 +40,7 @@ public class TestHaaSJavaClient {
} }
client.downloadPartsOfJobFiles(jobId, taskFileOffset).forEach(jfc -> showJFC(jfc)); client.downloadPartsOfJobFiles(jobId, taskFileOffset).forEach(jfc -> showJFC(jfc));
if (info.getState() == JobState.Finished) { if (info.getState() == JobState.Finished) {
client.download(jobId); client.download(jobId,workDir);
} }
System.out.println("JobId :" + jobId + ", state" + info.getState()); System.out.println("JobId :" + jobId + ", state" + info.getState());
} while (info.getState() != JobState.Canceled && info.getState() != JobState.Failed } while (info.getState() != JobState.Canceled && info.getState() != JobState.Failed
......
package cz.it4i.fiji.haas_java_client; package cz.it4i.fiji.haas_java_client;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.rmi.RemoteException;
import java.util.Collections;
import javax.xml.rpc.ServiceException; import javax.xml.rpc.ServiceException;
...@@ -11,11 +12,16 @@ import cz.it4i.fiji.haas_java_client.proxy.JobFileContentExt; ...@@ -11,11 +12,16 @@ import cz.it4i.fiji.haas_java_client.proxy.JobFileContentExt;
public class TestHaaSJavaClientWithSPIM { public class TestHaaSJavaClientWithSPIM {
public static void main(String[] args) throws RemoteException, ServiceException { public static void main(String[] args) throws ServiceException, IOException {
HaaSClient client = new HaaSClient(Paths.get("/home/koz01/Work/vyzkumnik/fiji/work/aaa"), 2l, 9600, 6l, HaaSClient client = new HaaSClient(2l, 9600, 6l, "DD-17-31");
"DD-17-31"); Path baseDir = Paths.get("/home/koz01/Work/vyzkumnik/fiji/work/aaa");
long jobId = 36;// client.start(Collections.emptyList(), "TestOutRedirect", long jobId = 36;// client.start(Collections.emptyList(), "TestOutRedirect",
// Collections.emptyList()); // Collections.emptyList());
Path workDir = baseDir.resolve("" + jobId);
if (!Files.isDirectory(workDir)) {
Files.createDirectories(workDir);
}
JobInfo info; JobInfo info;
boolean firstIteration = true; boolean firstIteration = true;
do { do {
...@@ -33,7 +39,7 @@ public class TestHaaSJavaClientWithSPIM { ...@@ -33,7 +39,7 @@ public class TestHaaSJavaClientWithSPIM {
} }
client.downloadPartsOfJobFiles(jobId, taskFileOffset).forEach(jfc -> showJFC(jfc)); client.downloadPartsOfJobFiles(jobId, taskFileOffset).forEach(jfc -> showJFC(jfc));
if (info.getState() == JobState.Finished) { if (info.getState() == JobState.Finished) {
client.download(jobId); client.download(jobId, workDir);
} }
System.out.println("JobId :" + jobId + ", state" + info.getState()); System.out.println("JobId :" + jobId + ", state" + info.getState());
firstIteration = false; firstIteration = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment