diff --git a/README.md b/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..f4df5ea0fad03466995779b72d72e4ff965a070c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,106 @@
+
+# Uso da API REST do CSBase
+
+## Documentação da API REST do CSGrid que serve ao Portal ERAS
+
+- [Documentação Swagger da API](https://eras.tecgraf.puc-rio.br/workingserver/docs/?url=https://eras.tecgraf.puc-rio.br/workingserver/v1/swagger.yaml#/)
+
+## Demonstrações
+
+### JavaScript
+
+Execução de um algoritmo (Packgen): https://plnkr.co/edit/0xqIoNX3nLu3l8A7yd7r
+obs: o exemplo em JavaScript não é análogo ao exemplo Java.
+
+### Java
+
+Demonstração da execução do algoritmo de "Zip Utility" (zip) através da API REST de um servidor CSGrid.
+Condições para a demo executar:
+
+- algoritmo zip cadastrado
+- alguma maquina remota disponÃvel para executar
+- ter um usuário já cadastrado e com as permissões necessárias para execução do algoritmo zip nas máquinas disponÃveis
+- projeto previamente criado
+- usuário é o dono do projeto ou tem permissão de escrita no projeto
+- arquivos de entrada disponiveis localmente
+- caminho válido para arquivo de saÃda a ser criado localmente
+
+O código fonte da demo está disponÃvel em https://git.tecgraf.puc-rio.br/csbase-dev/rest-client-demo-java.
+
+Para melhor entendimento do código fonte e da parametrização de um algoritmo, pode ser útil ler as seguintes referências:
+
+- [Parametrização de um algoritmo para execução](https://jira.tecgraf.puc-rio.br/confluence/pages/viewpage.action?pageId=36504138)
+- [Manual de Criação de Configuradores para Algoritmos do CSGrid](http://webserver2.tecgraf.puc-rio.br/ftp_pub/csbase/1.5.5/manualConfiguradorXML.pdf)
+
+A demo está disponÃvel como um jar executável no Maven público do Tecgraf (http://maven.tecgraf.puc-rio.br:8081/nexus/)
+```
+
+br.puc-rio.tecgraf.csbase
+rest-client-demo-java
+1.0.0
+jar-with-dependencies
+
+```
+
+Para executar, basta criar um arquivo de configuração e passar como parâmetro.
+
+Exemplo de arquivo de configuração:
+**config.properties**
+```
+# Host do servidor CSGrid usado na demo
+host http://localhost:8010/v1/
+
+# Login de usuário existente
+username tester
+
+# Senha do usuário
+password tester
+
+# Projeto usado para execução remota
+project teste
+
+# Pasta do projeto onde os arquivos de entrada e saÃda serão gerados
+projectFolderPath root
+
+# Primeiro arquivo local que será transferido para o projeto e que é entrada do algoritmo
+input_file_1 input1.txt
+
+# Segundo arquivo local que será transferido para o projeto e que é entrada do algoritmo
+input_file_2 input2.txt
+
+# Arquivo local que será criado com o conteúdo lido do arquivo resultado da execução do algoritmo
+output_file output.zip
+```
+
+Exemplo de execução com o arquivo de configuração acima:
+```
+java -jar rest-client-demo-java-1.0.0-jar-with-dependencies.jar config.properties
+```
+
+A saÃda de demo é a seguinte:
+```
+-- Inicio da demo
+Propriedades carregadas de src/main/resources/config.properties
+Projeto tester/teste encontrado
+Algoritmo zip encontrado
+Algoritmo zip submetido com sucesso
+Job test@test.BBNB3I5AHL encontrado
+Job state (1548177277184): EXECUTING
+Job state (1548177277231): DOWNLOADING
+Job state (1548177278761): FINISHED
+Job test@test.BBNB3I5AHL terminou
+
+Resultado em input1.txt:
+Breve arquivo de exemplo de entrada para ser enviado ao servidor.
+
+Resultado em output.zip: 1882 bytes
+
+Resultado em OUTROoutput.zip: 1882 bytes
+```
+OBS: O jobId (test@test.BBNB3I5AHL) será sempre único a cada execução. O valor dentro dos parêntesis após "Job state" é sempre o timestamp em milissegundos.
+
+
+Para executar, a partir do código fonte, usando o Maven:
+```
+mvn exec:java -Dexec.args="config.properties"
+```
diff --git a/pom.xml b/pom.xml
index 1813f5efdf7411d729b3e21ed89baf871ca42750..303e2e0d3a50151bef53cacc606e933fcf9fbe5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
br.puc-rio.tecgraf.csbase
rest-client-demo-java
- 0.0.1
+ 1.0.0-SNAPSHOT
jar
resttest
diff --git a/src/main/java/Demo/CommandSubmissionClient.java b/src/main/java/Demo/CommandSubmissionClient.java
index 3c41b8536a88fba431dbc5e70551a1652ad0964d..bba5cb68ad91b5aa530d0d984495ffd3a749ec54 100644
--- a/src/main/java/Demo/CommandSubmissionClient.java
+++ b/src/main/java/Demo/CommandSubmissionClient.java
@@ -8,20 +8,38 @@ import Requests.Authentication.LoginOrPasswordNotProvidedException;
import Requests.Authentication.Token;
import Requests.Jobs.JobInfo;
import Requests.Jobs.JobServices;
-import Requests.Projects.*;
+import Requests.Projects.FileExplorer;
+import Requests.Projects.PermissionException;
+import Requests.Projects.Project;
+import Requests.Projects.ProjectExplorer;
+import Requests.Projects.ProjectOrFileNotFoundException;
+import java.io.File;
import java.io.FileInputStream;
+import java.io.IOException;
import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.StandardCopyOption;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Properties;
+/**
+ * Exemplo de submissão programática da execução de um algoritmo em um servidor
+ * CSBase.
+ *
+ * CompatÃvel com a versão 1.4.6 do iBase.
+ *
+ * @author Tecgraf/PUC-Rio
+ */
public class CommandSubmissionClient {
- private static final String ALGORITHM = "multmatrix";
- private static final String REMOTE_INPUT_FILE_1 = "data_1.in";
- private static final String REMOTE_INPUT_FILE_2 = "data_2.in";
- private static final String REMOTE_OUTPUT_FILE = "result.out";
+ private static final String ALGORITHM = "zip";
+ private static final String REMOTE_INPUT_FILE_1 = "input1.txt";
+ private static final String REMOTE_INPUT_FILE_2 = "input2.txt";
+ private static final String REMOTE_OUTPUT_FILE = "output.zip";
/**
* Nome do arquivo com as propriedades para a demo
@@ -33,7 +51,7 @@ public class CommandSubmissionClient {
* - usuário já cadastrado
* - projeto previamente criado
* - usuário é o dono do projeto
- * - algoritmo multmatrix cadastrado
+ * - algoritmo zip cadastrado
* - arquivos de entrada disponiveis localmente
* - caminho válido para arquivo de saÃda a ser criado localmente
* - alguma maquina remota disponivel para executar
@@ -69,37 +87,37 @@ public class CommandSubmissionClient {
System.exit(1);
}
String username = props.getProperty("username");
- if (host==null || host.isEmpty()) {
+ if (username == null || username.isEmpty()) {
System.out.println ("A propriedade username e' obrigatoria");
System.exit(1);
}
String password = props.getProperty("password");
- if (host==null || host.isEmpty()) {
+ if (password == null || password.isEmpty()) {
System.out.println ("A propriedade password e' obrigatoria");
System.exit(1);
}
String projectName = username + "/" + props.getProperty("project");
- if (host==null || host.isEmpty()) {
+ if (projectName.equals(username + "/" + null) || projectName.equals(username + "/")) {
System.out.println ("A propriedade project e' obrigatoria");
System.exit(1);
}
String projectFolderPath = props.getProperty("projectFolderPath");
- if (host==null || host.isEmpty()) {
+ if (projectFolderPath == null || projectFolderPath.isEmpty()) {
System.out.println ("A propriedade projectFolderPath e' obrigatoria");
System.exit(1);
}
String toUploadFilePath1 = props.getProperty("input_file_1");
- if (host==null || host.isEmpty()) {
+ if (toUploadFilePath1 == null || toUploadFilePath1.isEmpty()) {
System.out.println ("A propriedade input_file_1 e' obrigatoria");
System.exit(1);
}
String toUploadFilePath2 = props.getProperty("input_file_2");
- if (host==null || host.isEmpty()) {
+ if (toUploadFilePath2 == null || toUploadFilePath2.isEmpty()) {
System.out.println ("A propriedade input_file_2 e' obrigatoria");
System.exit(1);
}
String toSaveFilePath = props.getProperty("output_file");
- if (host==null || host.isEmpty()) {
+ if (toSaveFilePath == null || toSaveFilePath.isEmpty()) {
System.out.println ("A propriedade output_file e' obrigatoria");
System.exit(1);
}
@@ -132,17 +150,36 @@ public class CommandSubmissionClient {
/*
* Faz o upload dos dados de entrada na raiz do projeto
+ *
+ * Os arquivos que serão necessários para o algoritmo precisam ser enviados para o projeto, pois é de
+ * lá onde o algoritmo consegue ler os arquivos.
*/
FileExplorer.uploadFile(host, token, project, projectFolderPath, toUploadFilePath1, REMOTE_INPUT_FILE_1);
FileExplorer.uploadFile(host, token, project, projectFolderPath, toUploadFilePath2, REMOTE_INPUT_FILE_2);
/*
- * Executa o algoritmo Multmatrix
+ * Cria a lista que será utilizada como parâmetro do algoritmo.
+ *
+ * O algoritmo Zip recebe como parâmetro de entrada uma lista de arquivos (que
+ * pode conter somente um arquivo). No exemplo, utilizamos dois arquivos.
*/
- Map commandArgs = new HashMap<>();
- commandArgs.put("matrix1", REMOTE_INPUT_FILE_1);
- commandArgs.put("matrix2", REMOTE_INPUT_FILE_2);
- commandArgs.put("result", REMOTE_OUTPUT_FILE);
+ List inputFiles = new ArrayList<>();
+ inputFiles.add(REMOTE_INPUT_FILE_1);
+ inputFiles.add(REMOTE_INPUT_FILE_2);
+
+ /*
+ * O nome dos parâmetros (aqui no exemplo "ENTRADA" e "SAIDA") são definidos pelo próprio algoritmo, dentro de seu arquivo config.xml
+ * Acesse os links abaixo para mais informações sobre o config.xml
+ * https://jira.tecgraf.puc-rio.br/confluence/pages/viewpage.action?pageId=36504138
+ * http://webserver2.tecgraf.puc-rio.br/ftp_pub/csbase/1.5.5/manualConfiguradorXML.pdf
+ */
+ Map commandArgs = new HashMap<>();
+ commandArgs.put("ENTRADA", inputFiles);
+ commandArgs.put("SAIDA", REMOTE_OUTPUT_FILE);
+
+ /*
+ * Executa o algoritmo Zip (obtido previamente)
+ */
String jobId = JobServices.submitJob(host, token, project, algorithm, algorithm.getVersions().get(0),
"demo rest java", 0, false, new String[0], commandArgs);
if (jobId==null) {
@@ -151,6 +188,9 @@ public class CommandSubmissionClient {
}
System.out.println("Algoritmo " + ALGORITHM + " submetido com sucesso");
+ /*
+ * Obtém as informações do job criado para a execução do algoritmo.
+ */
JobInfo jinfo = JobServices.getJobInfo(host, token, jobId);
if (jinfo==null) {
System.out.println("Job "+ jobId + " nao foi encontrado");
@@ -158,21 +198,44 @@ public class CommandSubmissionClient {
}
System.out.println("Job " + jobId + " encontrado");
- /**
- * Aguarda o job terminar sua execução
- */
+ /*
+ * Aguarda o job terminar sua execução
+ */
JobServices.awaitJobEnd(host, token, jinfo);
- /**
- * Faz download do arquivo de saÃda (quando o arquivo é pequeno)
- */
- String result = FileExplorer.downloadFile(host, token, project, projectFolderPath, REMOTE_OUTPUT_FILE);
- System.out.println("Resultado em " + REMOTE_OUTPUT_FILE + ":\n"+result);
+ /*
+ * Faz download do arquivo (quando o arquivo é pequeno e somente
+ * texto)
+ *
+ * obs: como o arquivo de saÃda é um binário (zip), esse exemplo está
+ * sendo feito com um dos arquivos de entrada que foi enviado para o
+ * servidor, mas basta alterar o nome do arquivo na chamada para obter o
+ * arquivo pretendido.
+ */
+ String textResult = FileExplorer.downloadTextFile(host, token, project, projectFolderPath, REMOTE_INPUT_FILE_1);
+
+ System.out.println("\nResultado em " + REMOTE_INPUT_FILE_1 + ":\n" + textResult);
+
+ /*
+ * Faz download de arquivo. (quando o arquivo é pequeno e qualquer formato)
+ *
+ * obs: neste caso fazemos download do arquivo de saÃda.
+ */
+ InputStream fileStream = FileExplorer.downloadBinaryFile(host, token, project, projectFolderPath, REMOTE_OUTPUT_FILE);
+
+ long fileSize = Files.copy(fileStream, new File(toSaveFilePath).toPath(), StandardCopyOption.REPLACE_EXISTING);
+ fileStream.close();
- /**
+ System.out.println("\nResultado em " + REMOTE_OUTPUT_FILE + ": " + fileSize + " bytes ");
+
+ /*
* Faz download do arquivo de saÃda (quando o arquivo é grande)
+ *
+ * obs: colocamos um prefixo no nome do arquivo a ser salvo para diferenciar do arquivo obtido no exemplo acima.
*/
- FileExplorer.downloadLargeFile(host, token, project, projectFolderPath, REMOTE_OUTPUT_FILE, toSaveFilePath);
+ FileExplorer.downloadLargeFile(host, token, project, projectFolderPath, REMOTE_OUTPUT_FILE, "OUTRO" + toSaveFilePath);
+
+ System.out.println("\nResultado em " + "OUTRO" + toSaveFilePath + ": " + new File("OUTRO" + toSaveFilePath).length() + " bytes ");
} catch (LoginOrPasswordNotProvidedException e) {
e.printStackTrace();
@@ -182,6 +245,8 @@ public class CommandSubmissionClient {
e.printStackTrace();
} catch (PermissionException e) {
e.printStackTrace();
- }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/main/java/Requests/Algorithms/Algorithm.java b/src/main/java/Requests/Algorithms/Algorithm.java
index 0f30886859a08fa22c6991d3da06bac296848233..c39260c067e865264a1c3221fd163740cf09d35c 100644
--- a/src/main/java/Requests/Algorithms/Algorithm.java
+++ b/src/main/java/Requests/Algorithms/Algorithm.java
@@ -9,7 +9,7 @@ import java.util.Objects;
public class Algorithm {
private String id = null;
private String name = null;
- private String description = null;
+ private List categories = null;
private User whoCreated = null;
private AlgorithmVersion lastVersion = null;
private List versions = new ArrayList();
@@ -33,15 +33,18 @@ public class Algorithm {
public void setName(String name) {
this.name = name;
}
- public Algorithm description(String description) {
- this.description = description;
+
+ public Algorithm categories(List categories) {
+ this.categories = categories;
return this;
}
- public String getDescription() {
- return description;
+
+ public List getCategories() {
+ return categories;
}
- public void setDescription(String description) {
- this.description = description;
+
+ public void setCategories(List categories) {
+ this.categories = categories;
}
public Algorithm whoCreated(User whoCreated) {
this.whoCreated = whoCreated;
@@ -89,7 +92,7 @@ public class Algorithm {
Algorithm algorithm = (Algorithm) o;
return Objects.equals(this.id, algorithm.id) &&
Objects.equals(this.name, algorithm.name) &&
- Objects.equals(this.description, algorithm.description) &&
+ Objects.equals(this.categories, algorithm.categories) &&
Objects.equals(this.whoCreated, algorithm.whoCreated) &&
Objects.equals(this.lastVersion, algorithm.lastVersion) &&
Objects.equals(this.versions, algorithm.versions);
@@ -97,7 +100,7 @@ public class Algorithm {
@Override
public int hashCode() {
- return Objects.hash(id, name, description, whoCreated, lastVersion, versions);
+ return Objects.hash(id, name, categories, whoCreated, lastVersion, versions);
}
@Override
@@ -106,7 +109,7 @@ public class Algorithm {
sb.append("class Algorithm {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
- sb.append(" description: ").append(toIndentedString(description)).append("\n");
+ sb.append(" categories: ").append(toIndentedString(categories)).append("\n");
sb.append(" whoCreated: ").append(toIndentedString(whoCreated)).append("\n");
sb.append(" lastVersion: ").append(toIndentedString(lastVersion)).append("\n");
sb.append(" versions: ").append(toIndentedString(versions)).append("\n");
diff --git a/src/main/java/Requests/Jobs/JobInfo.java b/src/main/java/Requests/Jobs/JobInfo.java
index 851c97d2f4477d6413f06e0ba2e6676099bb0de1..e54462f29207ca6946de56a5a1f7922b9a4ae3c5 100644
--- a/src/main/java/Requests/Jobs/JobInfo.java
+++ b/src/main/java/Requests/Jobs/JobInfo.java
@@ -1,488 +1,777 @@
package Requests.Jobs;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Objects;
+import java.util.Map;
+/**
+ * JobInfo
+ */
public class JobInfo {
- private String jobId = null;
-
- private String sessionId = null;
-
- public enum SubmitedByEnum {
- REST_SERVICE("REST Service"),
- RMI_SERVICE("RMI Service");
- private String value;
- SubmitedByEnum(String value) {
- this.value = value;
- }
- @Override
- public String toString() {
- return String.valueOf(value);
- }
- }
-
- public enum StatusType {
- SCHEDULED("SCHEDULED"),
- INIT("INIT"),
- UPLOADING("UPLOADING"),
- QUEUED("QUEUED"),
- EXECUTING("EXECUTING"),
- DOWNLOADING("DOWNLOADING"),
- FINISHED("FINISHED"),
- UNKNOWN("UNKNOWN");
- private String value;
- StatusType(String value) {
- this.value = value;
- }
- @Override
- public String toString() {
- return String.valueOf(value);
- }
- }
-
- private SubmitedByEnum submitedBy = null;
- private String projectId = null;
- private String algorithmId = null;
- private String algorithmVersion = null;
- private String jobOwner = null;
- private Boolean automaticallyMachineSelection = null;
- private String submissionMachine = null;
- private String submissionTime = null;
- private String executionMachine = null;
- private String endTime = null;
- private Integer numberOfAttempts = null;
- private String description = null;
- private Integer priority = null;
- private StatusType state = null;
- private Integer exitCode = null;
-
- public enum ExitStatusEnum {
- UNKNOWN("unknown"),
- SUCCESS("success"),
- EXECUTION_ERROR("execution_error"),
- JOB_IDENTIFIER_NOT_FOUND("job_identifier_not_found"),
- UNEXPECTED_MACHINE_ERROR("unexpected_machine_error"),
- PROJECT_NOT_FOUND("project_not_found"),
- FAILED_SETUP_EXECUTION_ENVIRONMENT("failed_setup_execution_environment"),
- NO_PERMISSION("no_permission"),
- NO_MACHINE_AVAILABLE("no_machine_available"),
- KILLED("killed"),
- LOST("lost"),
- UNDEFINED("undefined");
- private String value;
- ExitStatusEnum(String value) {
- this.value = value;
- }
- @Override
- public String toString() {
- return String.valueOf(value);
- }
- }
-
- private ExitStatusEnum exitStatus = null;
- private Double cpuTime = null;
- private Integer wallclockTime = null;
- private Double ramMemory = null;
- private String progressInfo = null;
- private List statusHistory = new ArrayList();
- private String lastModifiedTime = null;
-
- public JobInfo jobId(String jobId) {
- this.jobId = jobId;
- return this;
- }
-
- public String getJobId() {
- return jobId;
- }
-
- public void setJobId(String jobId) {
- this.jobId = jobId;
- }
-
- public JobInfo sessionId(String sessionId) {
- this.sessionId = sessionId;
- return this;
- }
-
- public String getSessionId() {
- return sessionId;
- }
-
- public void setSessionId(String sessionId) {
- this.sessionId = sessionId;
- }
-
- public JobInfo submitedBy(SubmitedByEnum submitedBy) {
- this.submitedBy = submitedBy;
- return this;
- }
-
- public SubmitedByEnum getSubmitedBy() {
- return submitedBy;
- }
-
- public void setSubmitedBy(SubmitedByEnum submitedBy) {
- this.submitedBy = submitedBy;
- }
-
- public JobInfo projectId(String projectId) {
- this.projectId = projectId;
- return this;
- }
-
- public String getProjectId() {
- return projectId;
- }
-
- public void setProjectId(String projectId) {
- this.projectId = projectId;
- }
-
- public JobInfo algorithmId(String algorithmId) {
- this.algorithmId = algorithmId;
- return this;
- }
-
- public String getAlgorithmId() {
- return algorithmId;
- }
-
- public void setAlgorithmId(String algorithmId) {
- this.algorithmId = algorithmId;
- }
-
- public JobInfo algorithmVersion(String algorithmVersion) {
- this.algorithmVersion = algorithmVersion;
- return this;
- }
-
- public String getAlgorithmVersion() {
- return algorithmVersion;
- }
-
- public void setAlgorithmVersion(String algorithmVersion) {
- this.algorithmVersion = algorithmVersion;
- }
-
- public JobInfo jobOwner(String jobOwner) {
- this.jobOwner = jobOwner;
- return this;
- }
-
- public String getJobOwner() {
- return jobOwner;
- }
-
- public void setJobOwner(String jobOwner) {
- this.jobOwner = jobOwner;
- }
-
- public JobInfo automaticallyMachineSelection(Boolean automaticallyMachineSelection) {
- this.automaticallyMachineSelection = automaticallyMachineSelection;
- return this;
- }
-
- public Boolean getAutomaticallyMachineSelection() {
- return automaticallyMachineSelection;
- }
-
- public void setAutomaticallyMachineSelection(Boolean automaticallyMachineSelection) {
- this.automaticallyMachineSelection = automaticallyMachineSelection;
- }
-
- public JobInfo submissionMachine(String submissionMachine) {
- this.submissionMachine = submissionMachine;
- return this;
- }
-
- public String getSubmissionMachine() {
- return submissionMachine;
- }
-
- public void setSubmissionMachine(String submissionMachine) {
- this.submissionMachine = submissionMachine;
- }
-
- public JobInfo submissionTime(String submissionTime) {
- this.submissionTime = submissionTime;
- return this;
- }
-
- public String getSubmissionTime() {
- return submissionTime;
- }
-
- public void setSubmissionTime(String submissionTime) {
- this.submissionTime = submissionTime;
- }
-
- public JobInfo executionMachine(String executionMachine) {
- this.executionMachine = executionMachine;
- return this;
- }
-
- public String getExecutionMachine() {
- return executionMachine;
- }
-
- public void setExecutionMachine(String executionMachine) {
- this.executionMachine = executionMachine;
- }
-
- public JobInfo endTime(String endTime) {
- this.endTime = endTime;
- return this;
- }
-
- public String getEndTime() {
- return endTime;
- }
-
- public void setEndTime(String endTime) {
- this.endTime = endTime;
- }
-
- public JobInfo numberOfAttempts(Integer numberOfAttempts) {
- this.numberOfAttempts = numberOfAttempts;
- return this;
- }
-
- public Integer getNumberOfAttempts() {
- return numberOfAttempts;
- }
-
- public void setNumberOfAttempts(Integer numberOfAttempts) {
- this.numberOfAttempts = numberOfAttempts;
- }
-
- public JobInfo description(String description) {
- this.description = description;
- return this;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public JobInfo priority(Integer priority) {
- this.priority = priority;
- return this;
- }
-
- public Integer getPriority() {
- return priority;
- }
-
- public void setPriority(Integer priority) {
- this.priority = priority;
- }
-
- public JobInfo state(StatusType state) {
- this.state = state;
- return this;
- }
-
- public StatusType getState() {
- return state;
- }
-
- public void setState(StatusType state) {
- this.state = state;
- }
-
- public JobInfo exitCode(Integer exitCode) {
- this.exitCode = exitCode;
- return this;
- }
-
- public Integer getExitCode() {
- return exitCode;
- }
-
- public void setExitCode(Integer exitCode) {
- this.exitCode = exitCode;
- }
-
- public JobInfo exitStatus(ExitStatusEnum exitStatus) {
- this.exitStatus = exitStatus;
- return this;
- }
-
- public ExitStatusEnum getExitStatus() {
- return exitStatus;
- }
-
- public void setExitStatus(ExitStatusEnum exitStatus) {
- this.exitStatus = exitStatus;
- }
-
- public JobInfo cpuTime(Double cpuTime) {
- this.cpuTime = cpuTime;
- return this;
- }
-
- public Double getCpuTime() {
- return cpuTime;
- }
-
- public void setCpuTime(Double cpuTime) {
- this.cpuTime = cpuTime;
- }
-
- public JobInfo wallclockTime(Integer wallclockTime) {
- this.wallclockTime = wallclockTime;
- return this;
- }
-
- public Integer getWallclockTime() {
- return wallclockTime;
- }
-
- public void setWallclockTime(Integer wallclockTime) {
- this.wallclockTime = wallclockTime;
- }
-
- public JobInfo ramMemory(Double ramMemory) {
- this.ramMemory = ramMemory;
- return this;
- }
-
- public Double getRamMemory() {
- return ramMemory;
- }
-
- public void setRamMemory(Double ramMemory) {
- this.ramMemory = ramMemory;
- }
-
- public JobInfo progressInfo(String progressInfo) {
- this.progressInfo = progressInfo;
- return this;
- }
-
- public String getProgressInfo() {
- return progressInfo;
- }
-
- public void setProgressInfo(String progressInfo) {
- this.progressInfo = progressInfo;
- }
-
- public JobInfo statusHistory(List statusHistory) {
- this.statusHistory = statusHistory;
- return this;
- }
-
- public JobInfo addStatusHistoryItem(StatusChangeHistory statusHistoryItem) {
- this.statusHistory.add(statusHistoryItem);
- return this;
- }
-
- public List getStatusHistory() {
- return statusHistory;
- }
-
- public void setStatusHistory(List statusHistory) {
- this.statusHistory = statusHistory;
- }
-
- public JobInfo lastModifiedTime(String lastModifiedTime) {
- this.lastModifiedTime = lastModifiedTime;
- return this;
- }
-
- public String getLastModifiedTime() {
- return lastModifiedTime;
- }
-
- public void setLastModifiedTime(String lastModifiedTime) {
- this.lastModifiedTime = lastModifiedTime;
- }
-
-
- @Override
- public boolean equals(java.lang.Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- JobInfo job = (JobInfo) o;
- return Objects.equals(this.jobId, job.jobId) &&
- Objects.equals(this.sessionId, job.sessionId) &&
- Objects.equals(this.submitedBy, job.submitedBy) &&
- Objects.equals(this.projectId, job.projectId) &&
- Objects.equals(this.algorithmId, job.algorithmId) &&
- Objects.equals(this.algorithmVersion, job.algorithmVersion) &&
- Objects.equals(this.jobOwner, job.jobOwner) &&
- Objects.equals(this.automaticallyMachineSelection, job.automaticallyMachineSelection) &&
- Objects.equals(this.submissionMachine, job.submissionMachine) &&
- Objects.equals(this.submissionTime, job.submissionTime) &&
- Objects.equals(this.executionMachine, job.executionMachine) &&
- Objects.equals(this.endTime, job.endTime) &&
- Objects.equals(this.numberOfAttempts, job.numberOfAttempts) &&
- Objects.equals(this.description, job.description) &&
- Objects.equals(this.priority, job.priority) &&
- Objects.equals(this.state, job.state) &&
- Objects.equals(this.exitCode, job.exitCode) &&
- Objects.equals(this.exitStatus, job.exitStatus) &&
- Objects.equals(this.cpuTime, job.cpuTime) &&
- Objects.equals(this.wallclockTime, job.wallclockTime) &&
- Objects.equals(this.ramMemory, job.ramMemory) &&
- Objects.equals(this.progressInfo, job.progressInfo) &&
- Objects.equals(this.statusHistory, job.statusHistory) &&
- Objects.equals(this.lastModifiedTime, job.lastModifiedTime);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(jobId, sessionId, submitedBy, projectId, algorithmId, algorithmVersion, jobOwner, automaticallyMachineSelection, submissionMachine, submissionTime, executionMachine, endTime, numberOfAttempts, description, priority, state, exitCode, exitStatus, cpuTime, wallclockTime, ramMemory, progressInfo, statusHistory, lastModifiedTime);
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("class JobInfo {\n");
-
- sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
- sb.append(" sessionId: ").append(toIndentedString(sessionId)).append("\n");
- sb.append(" submitedBy: ").append(toIndentedString(submitedBy)).append("\n");
- sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n");
- sb.append(" algorithmId: ").append(toIndentedString(algorithmId)).append("\n");
- sb.append(" algorithmVersion: ").append(toIndentedString(algorithmVersion)).append("\n");
- sb.append(" jobOwner: ").append(toIndentedString(jobOwner)).append("\n");
- sb.append(" automaticallyMachineSelection: ").append(toIndentedString(automaticallyMachineSelection)).append("\n");
- sb.append(" submissionMachine: ").append(toIndentedString(submissionMachine)).append("\n");
- sb.append(" submissionTime: ").append(toIndentedString(submissionTime)).append("\n");
- sb.append(" executionMachine: ").append(toIndentedString(executionMachine)).append("\n");
- sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n");
- sb.append(" numberOfAttempts: ").append(toIndentedString(numberOfAttempts)).append("\n");
- sb.append(" description: ").append(toIndentedString(description)).append("\n");
- sb.append(" priority: ").append(toIndentedString(priority)).append("\n");
- sb.append(" state: ").append(toIndentedString(state)).append("\n");
- sb.append(" exitCode: ").append(toIndentedString(exitCode)).append("\n");
- sb.append(" exitStatus: ").append(toIndentedString(exitStatus)).append("\n");
- sb.append(" cpuTime: ").append(toIndentedString(cpuTime)).append("\n");
- sb.append(" wallclockTime: ").append(toIndentedString(wallclockTime)).append("\n");
- sb.append(" ramMemory: ").append(toIndentedString(ramMemory)).append("\n");
- sb.append(" progressInfo: ").append(toIndentedString(progressInfo)).append("\n");
- sb.append(" statusHistory: ").append(toIndentedString(statusHistory)).append("\n");
- sb.append(" lastModifiedTime: ").append(toIndentedString(lastModifiedTime)).append("\n");
- sb.append("}");
- return sb.toString();
- }
-
- private String toIndentedString(java.lang.Object o) {
- if (o == null) {
- return "null";
- }
- return o.toString().replace("\n", "\n ");
- }
+ private String jobId = null;
+
+ private String groupId = null;
+
+ private String sessionId = null;
+
+ /**
+ * If the job was submit by the REST service or by RMI service.
+ */
+ public enum SubmitedByEnum {
+ REST_SERVICE("REST Service"),
+ RMI_SERVICE("RMI Service");
+ private String value;
+ SubmitedByEnum(String value) {
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+ }
+
+ public enum StatusType {
+ SCHEDULED("SCHEDULED"),
+ INIT("INIT"),
+ UPLOADING("UPLOADING"),
+ QUEUED("QUEUED"),
+ EXECUTING("EXECUTING"),
+ DOWNLOADING("DOWNLOADING"),
+ FINISHED("FINISHED"),
+ UNKNOWN("UNKNOWN");
+ private String value;
+
+ StatusType(String value) {
+ this.value = value;
+ }
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+ }
+
+ private SubmitedByEnum submitedBy = null;
+
+ private String projectId = null;
+
+ private String algorithmId = null;
+
+ private String algorithmVersion = null;
+
+ private String algorithmName = null;
+
+ private String jobOwner = null;
+
+ private String jobOwnerName = null;
+
+ private Boolean automaticallyMachineSelection = null;
+
+ private String submissionMachine = null;
+
+ private String submissionTime = null;
+
+ private String executionMachine = null;
+
+ private String endTime = null;
+
+ private Integer numberOfAttempts = null;
+
+ private String description = null;
+
+ private Integer priority = null;
+
+ private StatusType state = null;
+
+ private Integer exitCode = null;
+
+ /**
+ * The status describing the end of the execution. It can be empty if the job
+ * have not already finished.
+ */
+ public enum ExitStatusEnum {
+ UNKNOWN("unknown"),
+
+ SUCCESS("success"),
+
+ EXECUTION_ERROR("execution_error"),
+
+ JOB_IDENTIFIER_NOT_FOUND("job_identifier_not_found"),
+
+ UNEXPECTED_MACHINE_ERROR("unexpected_machine_error"),
+
+ PROJECT_NOT_FOUND("project_not_found"),
+
+ FAILED_SETUP_EXECUTION_ENVIRONMENT("failed_setup_execution_environment"),
+
+ NO_PERMISSION("no_permission"),
+
+ NO_MACHINE_AVAILABLE("no_machine_available"),
+
+ KILLED("killed"),
+
+ LOST("lost"),
+
+ UNDEFINED("undefined");
+
+ private String value;
+
+ ExitStatusEnum(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return String.valueOf(value);
+ }
+ }
+
+ private ExitStatusEnum exitStatus = null;
+ private Double cpuTime = null;
+ private Integer wallclockTime = null;
+ private Double ramMemory = null;
+ private String progressInfo = null;
+ private List statusHistory = new ArrayList();
+ private String lastModifiedTime = null;
+ private List monitoredFiles = new ArrayList();
+ private Map specificData = new HashMap();
+
+ public JobInfo jobId(String jobId) {
+ this.jobId = jobId;
+ return this;
+ }
+
+ /**
+ * The job Id.
+ *
+ * @return jobId
+ **/
+ public String getJobId() {
+ return jobId;
+ }
+
+ public void setJobId(String jobId) {
+ this.jobId = jobId;
+ }
+
+ public JobInfo groupId(String groupId) {
+ this.groupId = groupId;
+ return this;
+ }
+
+ /**
+ * The group Id of the job.
+ *
+ * @return groupId
+ **/
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public JobInfo sessionId(String sessionId) {
+ this.sessionId = sessionId;
+ return this;
+ }
+
+ /**
+ * The session Id used for job submission. By default, the sessionId is the
+ * project Id.
+ *
+ * @return sessionId
+ **/
+ public String getSessionId() {
+ return sessionId;
+ }
+
+ public void setSessionId(String sessionId) {
+ this.sessionId = sessionId;
+ }
+
+ public JobInfo submitedBy(SubmitedByEnum submitedBy) {
+ this.submitedBy = submitedBy;
+ return this;
+ }
+
+ /**
+ * If the job was submit by the REST service or by RMI service.
+ *
+ * @return submitedBy
+ **/
+ public SubmitedByEnum getSubmitedBy() {
+ return submitedBy;
+ }
+
+ public void setSubmitedBy(SubmitedByEnum submitedBy) {
+ this.submitedBy = submitedBy;
+ }
+
+ public JobInfo projectId(String projectId) {
+ this.projectId = projectId;
+ return this;
+ }
+
+ /**
+ * The project Id associated with the job.
+ *
+ * @return projectId
+ **/
+ public String getProjectId() {
+ return projectId;
+ }
+
+ public void setProjectId(String projectId) {
+ this.projectId = projectId;
+ }
+
+ public JobInfo algorithmId(String algorithmId) {
+ this.algorithmId = algorithmId;
+ return this;
+ }
+
+ /**
+ * The algorithm Id associated with the job.
+ *
+ * @return algorithmId
+ **/
+ public String getAlgorithmId() {
+ return algorithmId;
+ }
+
+ public void setAlgorithmId(String algorithmId) {
+ this.algorithmId = algorithmId;
+ }
+
+ public JobInfo algorithmVersion(String algorithmVersion) {
+ this.algorithmVersion = algorithmVersion;
+ return this;
+ }
+
+ /**
+ * The algoritm version associated with the job.
+ *
+ * @return algorithmVersion
+ **/
+ public String getAlgorithmVersion() {
+ return algorithmVersion;
+ }
+
+ public void setAlgorithmVersion(String algorithmVersion) {
+ this.algorithmVersion = algorithmVersion;
+ }
+
+ public JobInfo algorithmName(String algorithmName) {
+ this.algorithmName = algorithmName;
+ return this;
+ }
+
+ /**
+ * The algoritm name associated with the job.
+ *
+ * @return algorithmName
+ **/
+ public String getAlgorithmName() {
+ return algorithmName;
+ }
+
+ public void setAlgorithmName(String algorithmName) {
+ this.algorithmName = algorithmName;
+ }
+
+ public JobInfo jobOwner(String jobOwner) {
+ this.jobOwner = jobOwner;
+ return this;
+ }
+
+ /**
+ * The id of the user who submitted the job.
+ *
+ * @return jobOwner
+ **/
+ public String getJobOwner() {
+ return jobOwner;
+ }
+
+ public void setJobOwner(String jobOwner) {
+ this.jobOwner = jobOwner;
+ }
+
+ public JobInfo jobOwnerName(String jobOwnerName) {
+ this.jobOwnerName = jobOwnerName;
+ return this;
+ }
+
+ /**
+ * The name of the user who submitted the job.
+ *
+ * @return jobOwnerName
+ **/
+ public String getJobOwnerName() {
+ return jobOwnerName;
+ }
+
+ public void setJobOwnerName(String jobOwnerName) {
+ this.jobOwnerName = jobOwnerName;
+ }
+
+ public JobInfo automaticallyMachineSelection(Boolean automaticallyMachineSelection) {
+ this.automaticallyMachineSelection = automaticallyMachineSelection;
+ return this;
+ }
+
+ /**
+ * If the user select a machine for execution or not.
+ *
+ * @return automaticallyMachineSelection
+ **/
+ public Boolean getAutomaticallyMachineSelection() {
+ return automaticallyMachineSelection;
+ }
+
+ public void setAutomaticallyMachineSelection(Boolean automaticallyMachineSelection) {
+ this.automaticallyMachineSelection = automaticallyMachineSelection;
+ }
+
+ public JobInfo submissionMachine(String submissionMachine) {
+ this.submissionMachine = submissionMachine;
+ return this;
+ }
+
+ /**
+ * The machine selected for job execution. If the user choose the
+ * automatically machine selection, this information is empty.
+ *
+ * @return submissionMachine
+ **/
+ public String getSubmissionMachine() {
+ return submissionMachine;
+ }
+
+ public void setSubmissionMachine(String submissionMachine) {
+ this.submissionMachine = submissionMachine;
+ }
+
+ public JobInfo submissionTime(String submissionTime) {
+ this.submissionTime = submissionTime;
+ return this;
+ }
+
+ /**
+ * The submission time.
+ *
+ * @return submissionTime
+ **/
+ public String getSubmissionTime() {
+ return submissionTime;
+ }
+
+ public void setSubmissionTime(String submissionTime) {
+ this.submissionTime = submissionTime;
+ }
+
+ public JobInfo executionMachine(String executionMachine) {
+ this.executionMachine = executionMachine;
+ return this;
+ }
+
+ /**
+ * The machine where the job executed (or was scheduled to execute).
+ *
+ * @return executionMachine
+ **/
+ public String getExecutionMachine() {
+ return executionMachine;
+ }
+
+ public void setExecutionMachine(String executionMachine) {
+ this.executionMachine = executionMachine;
+ }
+
+ public JobInfo endTime(String endTime) {
+ this.endTime = endTime;
+ return this;
+ }
+
+ /**
+ * The end time of the execution. It can be empty if the job have not already
+ * finished.
+ *
+ * @return endTime
+ **/
+ public String getEndTime() {
+ return endTime;
+ }
+
+ public void setEndTime(String endTime) {
+ this.endTime = endTime;
+ }
+
+ public JobInfo numberOfAttempts(Integer numberOfAttempts) {
+ this.numberOfAttempts = numberOfAttempts;
+ return this;
+ }
+
+ /**
+ * The number of times the job has already been scheduled for execution.
+ *
+ * @return numberOfAttempts
+ **/
+ public Integer getNumberOfAttempts() {
+ return numberOfAttempts;
+ }
+
+ public void setNumberOfAttempts(Integer numberOfAttempts) {
+ this.numberOfAttempts = numberOfAttempts;
+ }
+
+ public JobInfo description(String description) {
+ this.description = description;
+ return this;
+ }
+
+ /**
+ * The description provided by the user at submission. It can be empty.
+ *
+ * @return description
+ **/
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public JobInfo priority(Integer priority) {
+ this.priority = priority;
+ return this;
+ }
+
+ /**
+ * The priority of the job.
+ *
+ * @return priority
+ **/
+ public Integer getPriority() {
+ return priority;
+ }
+
+ public void setPriority(Integer priority) {
+ this.priority = priority;
+ }
+
+ public JobInfo state(StatusType state) {
+ this.state = state;
+ return this;
+ }
+
+ /**
+ * Get state
+ *
+ * @return state
+ **/
+ public StatusType getState() {
+ return state;
+ }
+
+ public void setState(StatusType state) {
+ this.state = state;
+ }
+
+ public JobInfo exitCode(Integer exitCode) {
+ this.exitCode = exitCode;
+ return this;
+ }
+
+ /**
+ * The code returned by the job execution. It can be empty if the job have not
+ * already finished or if the system could not gather it.
+ *
+ * @return exitCode
+ **/
+ public Integer getExitCode() {
+ return exitCode;
+ }
+
+ public void setExitCode(Integer exitCode) {
+ this.exitCode = exitCode;
+ }
+
+ public JobInfo exitStatus(ExitStatusEnum exitStatus) {
+ this.exitStatus = exitStatus;
+ return this;
+ }
+
+ /**
+ * The status describing the end of the execution. It can be empty if the job
+ * have not already finished.
+ *
+ * @return exitStatus
+ **/
+ public ExitStatusEnum getExitStatus() {
+ return exitStatus;
+ }
+
+ public void setExitStatus(ExitStatusEnum exitStatus) {
+ this.exitStatus = exitStatus;
+ }
+
+ public JobInfo cpuTime(Double cpuTime) {
+ this.cpuTime = cpuTime;
+ return this;
+ }
+
+ /**
+ * Get cpuTime
+ *
+ * @return cpuTime
+ **/
+ public Double getCpuTime() {
+ return cpuTime;
+ }
+
+ public void setCpuTime(Double cpuTime) {
+ this.cpuTime = cpuTime;
+ }
+
+ public JobInfo wallclockTime(Integer wallclockTime) {
+ this.wallclockTime = wallclockTime;
+ return this;
+ }
+
+ /**
+ * Get wallclockTime
+ *
+ * @return wallclockTime
+ **/
+ public Integer getWallclockTime() {
+ return wallclockTime;
+ }
+
+ public void setWallclockTime(Integer wallclockTime) {
+ this.wallclockTime = wallclockTime;
+ }
+
+ public JobInfo ramMemory(Double ramMemory) {
+ this.ramMemory = ramMemory;
+ return this;
+ }
+
+ /**
+ * Get ramMemory
+ *
+ * @return ramMemory
+ **/
+ public Double getRamMemory() {
+ return ramMemory;
+ }
+
+ public void setRamMemory(Double ramMemory) {
+ this.ramMemory = ramMemory;
+ }
+
+ public JobInfo progressInfo(String progressInfo) {
+ this.progressInfo = progressInfo;
+ return this;
+ }
+
+ /**
+ * The progress info about a job.
+ *
+ * @return progressInfo
+ **/
+ public void setProgressInfo(String progressInfo) {
+ this.progressInfo = progressInfo;
+ }
+
+ public JobInfo statusHistory(List statusHistory) {
+ this.statusHistory = statusHistory;
+ return this;
+ }
+
+ public JobInfo addStatusHistoryItem(StatusChangeHistory statusHistoryItem) {
+ this.statusHistory.add(statusHistoryItem);
+ return this;
+ }
+
+ /**
+ * Get statusHistory
+ *
+ * @return statusHistory
+ **/
+ public List getStatusHistory() {
+ return statusHistory;
+ }
+
+ public void setStatusHistory(List statusHistory) {
+ this.statusHistory = statusHistory;
+ }
+
+ public JobInfo lastModifiedTime(String lastModifiedTime) {
+ this.lastModifiedTime = lastModifiedTime;
+ return this;
+ }
+
+ /**
+ * The time of job last modification.
+ *
+ * @return lastModifiedTime
+ **/
+ public String getLastModifiedTime() {
+ return lastModifiedTime;
+ }
+
+ public void setLastModifiedTime(String lastModifiedTime) {
+ this.lastModifiedTime = lastModifiedTime;
+ }
+
+ public JobInfo monitoredFiles(List monitoredFiles) {
+ this.monitoredFiles = monitoredFiles;
+ return this;
+ }
+
+ public JobInfo addMonitoredFilesItem(MonitoredFile monitoredFilesItem) {
+ this.monitoredFiles.add(monitoredFilesItem);
+ return this;
+ }
+
+ /**
+ * Monitored files during the job's execution
+ *
+ * @return monitoredFiles
+ **/
+ public List getMonitoredFiles() {
+ return monitoredFiles;
+ }
+
+ public void setMonitoredFiles(List monitoredFiles) {
+ this.monitoredFiles = monitoredFiles;
+ }
+
+ public JobInfo specificData(Map specificData) {
+ this.specificData = specificData;
+ return this;
+ }
+
+ public JobInfo putSpecificDataItem(String key, String specificDataItem) {
+ this.specificData.put(key, specificDataItem);
+ return this;
+ }
+
+ /**
+ * Specific data monitored during the job's execution
+ *
+ * @return specificData
+ **/
+ public Map getSpecificData() {
+ return specificData;
+ }
+
+ public void setSpecificData(Map specificData) {
+ this.specificData = specificData;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ JobInfo job = (JobInfo) o;
+ return Objects.equals(this.jobId, job.jobId) &&
+ Objects.equals(this.groupId, job.groupId) &&
+ Objects.equals(this.sessionId, job.sessionId) &&
+ Objects.equals(this.submitedBy, job.submitedBy) &&
+ Objects.equals(this.projectId, job.projectId) &&
+ Objects.equals(this.algorithmId, job.algorithmId) &&
+ Objects.equals(this.algorithmVersion, job.algorithmVersion) &&
+ Objects.equals(this.algorithmName, job.algorithmName) &&
+ Objects.equals(this.jobOwner, job.jobOwner) &&
+ Objects.equals(this.jobOwnerName, job.jobOwnerName) &&
+ Objects.equals(this.automaticallyMachineSelection, job.automaticallyMachineSelection) &&
+ Objects.equals(this.submissionMachine, job.submissionMachine) &&
+ Objects.equals(this.submissionTime, job.submissionTime) &&
+ Objects.equals(this.executionMachine, job.executionMachine) &&
+ Objects.equals(this.endTime, job.endTime) &&
+ Objects.equals(this.numberOfAttempts, job.numberOfAttempts) &&
+ Objects.equals(this.description, job.description) &&
+ Objects.equals(this.priority, job.priority) &&
+ Objects.equals(this.state, job.state) &&
+ Objects.equals(this.exitCode, job.exitCode) &&
+ Objects.equals(this.exitStatus, job.exitStatus) &&
+ Objects.equals(this.cpuTime, job.cpuTime) &&
+ Objects.equals(this.wallclockTime, job.wallclockTime) &&
+ Objects.equals(this.ramMemory, job.ramMemory) &&
+ Objects.equals(this.progressInfo, job.progressInfo) &&
+ Objects.equals(this.statusHistory, job.statusHistory) &&
+ Objects.equals(this.lastModifiedTime, job.lastModifiedTime) &&
+ Objects.equals(this.monitoredFiles, job.monitoredFiles) &&
+ Objects.equals(this.specificData, job.specificData);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(jobId, groupId, sessionId, submitedBy, projectId, algorithmId, algorithmVersion, algorithmName,
+ jobOwner, jobOwnerName, automaticallyMachineSelection, submissionMachine, submissionTime, executionMachine,
+ endTime, numberOfAttempts, description, priority, state, exitCode, exitStatus, cpuTime, wallclockTime, ramMemory,
+ progressInfo, statusHistory, lastModifiedTime, monitoredFiles, specificData);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class JobInfo {\n");
+
+ sb.append(" jobId: ").append(toIndentedString(jobId)).append("\n");
+ sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n");
+ sb.append(" sessionId: ").append(toIndentedString(sessionId)).append("\n");
+ sb.append(" submitedBy: ").append(toIndentedString(submitedBy)).append("\n");
+ sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n");
+ sb.append(" algorithmId: ").append(toIndentedString(algorithmId)).append("\n");
+ sb.append(" algorithmVersion: ").append(toIndentedString(algorithmVersion)).append("\n");
+ sb.append(" algorithmName: ").append(toIndentedString(algorithmName)).append("\n");
+ sb.append(" jobOwner: ").append(toIndentedString(jobOwner)).append("\n");
+ sb.append(" jobOwnerName: ").append(toIndentedString(jobOwnerName)).append("\n");
+ sb.append(" automaticallyMachineSelection: ").append(toIndentedString(automaticallyMachineSelection)).append(
+ "\n");
+ sb.append(" submissionMachine: ").append(toIndentedString(submissionMachine)).append("\n");
+ sb.append(" submissionTime: ").append(toIndentedString(submissionTime)).append("\n");
+ sb.append(" executionMachine: ").append(toIndentedString(executionMachine)).append("\n");
+ sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n");
+ sb.append(" numberOfAttempts: ").append(toIndentedString(numberOfAttempts)).append("\n");
+ sb.append(" description: ").append(toIndentedString(description)).append("\n");
+ sb.append(" priority: ").append(toIndentedString(priority)).append("\n");
+ sb.append(" state: ").append(toIndentedString(state)).append("\n");
+ sb.append(" exitCode: ").append(toIndentedString(exitCode)).append("\n");
+ sb.append(" exitStatus: ").append(toIndentedString(exitStatus)).append("\n");
+ sb.append(" cpuTime: ").append(toIndentedString(cpuTime)).append("\n");
+ sb.append(" wallclockTime: ").append(toIndentedString(wallclockTime)).append("\n");
+ sb.append(" ramMemory: ").append(toIndentedString(ramMemory)).append("\n");
+ sb.append(" progressInfo: ").append(toIndentedString(progressInfo)).append("\n");
+ sb.append(" statusHistory: ").append(toIndentedString(statusHistory)).append("\n");
+ sb.append(" lastModifiedTime: ").append(toIndentedString(lastModifiedTime)).append("\n");
+ sb.append(" monitoredFiles: ").append(toIndentedString(monitoredFiles)).append("\n");
+ sb.append(" specificData: ").append(toIndentedString(specificData)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
}
+
diff --git a/src/main/java/Requests/Jobs/JobServices.java b/src/main/java/Requests/Jobs/JobServices.java
index a32526b52f40dcb387dfd856ccf767e0090b05bf..6850bdd7c8b4be81af7130d463863e1985604f06 100644
--- a/src/main/java/Requests/Jobs/JobServices.java
+++ b/src/main/java/Requests/Jobs/JobServices.java
@@ -19,7 +19,7 @@ public class JobServices {
public static String submitJob(String host, Token token, Project project, Algorithm algorithm,
AlgorithmVersion version, String description, int priority, boolean emailOnTerminated,
- String[] candidateMachines, Map args) {
+ String[] candidateMachines, Map args) {
Client client = ClientBuilder.newClient();
WebTarget webTarget = client.target(host).path("jobs");
@@ -30,6 +30,7 @@ public class JobServices {
postBody.put("args", args);
postBody.put("priority", Integer.toString(priority));
postBody.put("emailOnTerminated", Boolean.toString(emailOnTerminated));
+ postBody.put("numberOfJobs", new Integer(1));
Invocation.Builder invocationBuilder = webTarget.request("application/json;charset=UTF-8");
Response response = invocationBuilder
diff --git a/src/main/java/Requests/Jobs/MonitoredFile.java b/src/main/java/Requests/Jobs/MonitoredFile.java
new file mode 100644
index 0000000000000000000000000000000000000000..e7a35a065a54479b78096655df4b4dd93cd2130b
--- /dev/null
+++ b/src/main/java/Requests/Jobs/MonitoredFile.java
@@ -0,0 +1,117 @@
+package Requests.Jobs;
+
+import java.util.Objects;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * MonitoredFile
+ */
+public class MonitoredFile {
+ private String name = null;
+
+ private String id = null;
+
+ private List formats = new ArrayList();
+
+ public MonitoredFile name(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Get name
+ * @return name
+ **/
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public MonitoredFile id(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Get id
+ * @return id
+ **/
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public MonitoredFile formats(List formats) {
+ this.formats = formats;
+ return this;
+ }
+
+ public MonitoredFile addFormatsItem(String formatsItem) {
+ this.formats.add(formatsItem);
+ return this;
+ }
+
+ /**
+ * Get formats
+ * @return formats
+ **/
+ public List getFormats() {
+ return formats;
+ }
+
+ public void setFormats(List formats) {
+ this.formats = formats;
+ }
+
+
+ @Override
+ public boolean equals(java.lang.Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ MonitoredFile monitoredFile = (MonitoredFile) o;
+ return Objects.equals(this.name, monitoredFile.name) &&
+ Objects.equals(this.id, monitoredFile.id) &&
+ Objects.equals(this.formats, monitoredFile.formats);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, id, formats);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ sb.append("class MonitoredFile {\n");
+
+ sb.append(" name: ").append(toIndentedString(name)).append("\n");
+ sb.append(" id: ").append(toIndentedString(id)).append("\n");
+ sb.append(" formats: ").append(toIndentedString(formats)).append("\n");
+ sb.append("}");
+ return sb.toString();
+ }
+
+ /**
+ * Convert the given object to string with each line indented by 4 spaces
+ * (except the first line).
+ */
+ private String toIndentedString(java.lang.Object o) {
+ if (o == null) {
+ return "null";
+ }
+ return o.toString().replace("\n", "\n ");
+ }
+}
+
diff --git a/src/main/java/Requests/Projects/FileExplorer.java b/src/main/java/Requests/Projects/FileExplorer.java
index 08e01c5243c449cfdcf006022f84aaf0e0efe09c..4a581e74db31f5a18a94cee9b0f629a9ac97273f 100644
--- a/src/main/java/Requests/Projects/FileExplorer.java
+++ b/src/main/java/Requests/Projects/FileExplorer.java
@@ -16,6 +16,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.Channels;
@@ -76,7 +77,7 @@ public class FileExplorer {
return str;
}
- public static String downloadFile(String host, Token token, Project project, String projectFolderPath,
+ public static String downloadTextFile(String host, Token token, Project project, String projectFolderPath,
String fileName)
throws ProjectOrFileNotFoundException, PermissionException, InvalidLoginOrPasswordException {
Client client = ClientBuilder.newClient();
@@ -104,6 +105,34 @@ public class FileExplorer {
return null;
}
+ public static InputStream downloadBinaryFile(String host, Token token, Project project, String projectFolderPath,
+ String fileName)
+ throws ProjectOrFileNotFoundException, PermissionException, InvalidLoginOrPasswordException {
+ Client client = ClientBuilder.newClient();
+ WebTarget webTarget = client.target(host);
+ String fileId = Base64.getEncoder().encodeToString(projectFolderPath.equals("root") ? fileName.getBytes()
+ : (projectFolderPath + (fileName == null ? "" : "/" + fileName)).getBytes());
+ WebTarget uploadTarget = webTarget.path("projects").path(project.getId()).path("files").path(fileId);
+
+ Invocation.Builder invocationBuilder = uploadTarget.request();
+
+ Response response = invocationBuilder
+ .header(HttpHeaders.AUTHORIZATION, token.getTokenType() + token.getAccessToken()).get();
+
+ int status = response.getStatus();
+
+ if (status == Response.Status.OK.getStatusCode())
+ return response.readEntity(InputStream.class);
+ else if (status == Response.Status.BAD_REQUEST.getStatusCode())
+ throw new InvalidLoginOrPasswordException();
+ else if (status == Response.Status.FORBIDDEN.getStatusCode())
+ throw new PermissionException();
+ else if (status == Response.Status.NOT_FOUND.getStatusCode())
+ throw new ProjectOrFileNotFoundException();
+ client.close();
+ return null;
+ }
+
public static void downloadLargeFile(String host, Token token, Project project, String projectFolderPath,
String fileName, String destinFileName)
throws ProjectOrFileNotFoundException, PermissionException, InvalidLoginOrPasswordException {
@@ -125,7 +154,9 @@ public class FileExplorer {
URL website;
try {
File file = new File(destinFileName);
- file.getParentFile().mkdirs();
+ if (file.getParentFile() != null) {
+ file.getParentFile().mkdirs();
+ }
file.createNewFile();
website = new URL(link.getUrl());
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
diff --git a/src/main/resources/config.properties b/src/main/resources/config.properties
index b148dcd0863f0af084beb0debe5599d35ca65cb5..86e4dd39e9814c13e4fd82ec80409e08a6b696cb 100644
--- a/src/main/resources/config.properties
+++ b/src/main/resources/config.properties
@@ -2,8 +2,8 @@
#
# - usuário já cadastrado e com as perissões necessárias para execução
# - projeto previamente criado
-# - usuário é o dono do projeto
-# - algoritmo multmatrix cadastrado
+# - usuário é o dono do projeto ou tem permissão de escrita nele
+# - algoritmo zip cadastrado
# - arquivos de entrada disponiveis localmente
# - caminho válido para arquivo de saída a ser criado localmente
# - alguma maquina remota disponivel para executar
@@ -11,16 +11,16 @@
# Host do servidor CSGrid usado na demo
host http://localhost:8010/v1/
# Login de usuário existente
-username testerA
+username tester
# Senha do usuário
-password testerA
+password tester
# Projeto usado para execução remota
-project A1
+project teste
# Pasta do projeto onde os arquivos de entrada e saída serão gerados
projectFolderPath root
# Primeiro arquivo local que será transferido para o projeto e que é entrada do algoritmo
-input_file_1 /Users/mjulia/Documents/tmp/data1.in
+input_file_1 input1.txt
# Segundo arquivo local que será transferido para o projeto e que é entrada do algoritmo
-input_file_2 /Users/mjulia/Documents/tmp/data2.in
+input_file_2 input2.txt
# Arquivo local que será criado com o conteúdo lido do arquivo resultado da execução do algoritmo
-output_file /Users/mjulia/Documents/tmp/result.out
+output_file output.zip