From 3a589e281de37b02805fa5d42374b9683d66c7eb Mon Sep 17 00:00:00 2001 From: pbelmann Date: Wed, 2 Nov 2016 17:47:07 +0100 Subject: [PATCH 1/3] feat(docker):running tools as docker container #3 --- .../de/unibi/techfak/bibiserv/BiBiTools.java | 54 ++++++++----------- .../techfak/bibiserv/impl/JobProxyCall.java | 2 - .../techfak/bibiserv/impl/LocalCall.java | 1 - 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/BiBiTools.java b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/BiBiTools.java index edec154..f5f05a2 100644 --- a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/BiBiTools.java +++ b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/BiBiTools.java @@ -22,15 +22,9 @@ */ package de.unibi.techfak.bibiserv; -import de.unibi.techfak.bibiserv.cms.TenumParam; -import de.unibi.techfak.bibiserv.cms.TenumValue; -import de.unibi.techfak.bibiserv.cms.Tfunction; -import de.unibi.techfak.bibiserv.cms.TinputOutput; -import de.unibi.techfak.bibiserv.cms.Tparam; +import de.unibi.techfak.bibiserv.cms.*; import de.unibi.techfak.bibiserv.cms.Tparam.Max; import de.unibi.techfak.bibiserv.cms.Tparam.Min; -import de.unibi.techfak.bibiserv.cms.TparamGroup; -import de.unibi.techfak.bibiserv.cms.TrunnableItem; import de.unibi.techfak.bibiserv.debug.DDataSource; import de.unibi.techfak.bibiserv.exception.BiBiToolsException; import de.unibi.techfak.bibiserv.exception.DBConnectionException; @@ -932,8 +926,8 @@ public File getTmpDir() throws FileNotFoundException { * * @return */ - public Element getToolDescription() { - return (Element) runnableitem; + public TrunnableItem getToolDescription() { + return runnableitem; } /** @@ -2285,7 +2279,7 @@ public String generateCmdLineString(String id, Map hash, String StringBuffer cmdline = new StringBuffer(getExecCmd()); // test if cmdline describe a valid executable (only if 'UseDocker' is unset) - if (getProperty("UseDocker") == null || !getProperty("UseDocker").equalsIgnoreCase("true")) { + if (!getToolDescription().getExecutable().getExecInfo().getExecutableType().equalsIgnoreCase("docker")) { File test = new File(cmdline.toString()); if (testexec && !(test.exists() && test.isFile() && test.canExecute())) { @@ -2949,35 +2943,31 @@ private TinputOutput search_for_input(String id) { */ private String getExecCmd() { StringBuffer cmdbuf = new StringBuffer(); - if (getProperty("UseDocker") == null || !getProperty("UseDocker").equalsIgnoreCase("true")) { - if (getProperty("executable.rootpath") != null) { - cmdbuf.append(getProperty("executable.rootpath")); - if (!endWithFileSeparator(cmdbuf)) { - cmdbuf.append(this.separator); - } - if (getProperty("executable.path.isrelativ").equalsIgnoreCase("true")) { - cmdbuf.append(runnableitem.getExecutable().getExecInfo().getPath()); - if (!endWithFileSeparator(cmdbuf)) { - cmdbuf.append(this.separator); - } - } - } else { + + Texecutable executable = getToolDescription().getExecutable(); + boolean isDocker = getToolDescription().getExecutable().getExecInfo().getExecutableType().equalsIgnoreCase("docker"); + if (getProperty("executable.rootpath") != null && !isDocker) { + cmdbuf.append(getProperty("executable.rootpath")); + if (!endWithFileSeparator(cmdbuf)) { + cmdbuf.append(this.separator); + } + if (getProperty("executable.path.isrelativ").equalsIgnoreCase("true")) { cmdbuf.append(runnableitem.getExecutable().getExecInfo().getPath()); if (!endWithFileSeparator(cmdbuf)) { cmdbuf.append(this.separator); } } } else { - String orga = getProperty("DockerHubOrganization"); - if (orga != null) { - cmdbuf.append("docker run "); - cmdbuf.append(" --rm=true"); - cmdbuf.append(" -v ").append(getProperty("spooldir.base")).append(":").append(getProperty("spooldir.base")); - cmdbuf.append(" ").append(orga).append("/").append(runnableitem.getId()); - cmdbuf.append(" /usr/local/bin/"); - } else { - cmdbuf.append("# BiBiTool.properties doesn't contain a property named 'DockerHubOrganization'!"); + cmdbuf.append("docker "); + cmdbuf.append("run "); + cmdbuf.append("--entrypoint='" + runnableitem.getExecutable().getExecInfo().getPath() + "' "); + try { + cmdbuf.append("-v "); + cmdbuf.append(getSpoolDir().toString() + ":" + getSpoolDir().toString() + ":rw "); + } catch (FileNotFoundException e) { + e.printStackTrace(); } + cmdbuf.append(executable.getExecInfo().getImage() + " "); } cmdbuf.append(runnableitem.getExecutable().getExecInfo().getCallingInformation()); return cmdbuf.toString(); diff --git a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java index d1ce444..6a0fd9b 100644 --- a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java +++ b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java @@ -29,7 +29,6 @@ import de.unibi.techfak.bibiserv.exception.IdNotFoundException; import java.io.File; import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; @@ -39,7 +38,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.util.logging.Level; import org.apache.log4j.Logger; import org.json.*; diff --git a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/LocalCall.java b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/LocalCall.java index 4ff17a6..af8f0f7 100644 --- a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/LocalCall.java +++ b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/LocalCall.java @@ -29,7 +29,6 @@ import de.unibi.techfak.bibiserv.exception.DBConnectionException; import java.io.File; -import java.io.FileInputStream; /** * Implements the Call interface executing a program directly on the local From facd804b3bfd9e8a3b6c6852883803a89d1fab3f Mon Sep 17 00:00:00 2001 From: pbelmann Date: Sun, 6 Nov 2016 11:45:35 +0100 Subject: [PATCH 2/3] feat(docker):fix pellet version --- libs/ontoaccess/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/ontoaccess/pom.xml b/libs/ontoaccess/pom.xml index 525c373..daf16a1 100644 --- a/libs/ontoaccess/pom.xml +++ b/libs/ontoaccess/pom.xml @@ -34,13 +34,13 @@ org.apache.jena jena-core - 2.10.1 + 2.7.1 com.github.ansell.pellet pellet-jena - 2.3.6-ansell + 2.3.2 From f05067a9566b0017983cc17fc040fe66fd9e1ee3 Mon Sep 17 00:00:00 2001 From: pbelmann Date: Tue, 8 Nov 2016 10:00:25 +0100 Subject: [PATCH 3/3] fix(JobProxyCall): set uri when bibitools are set --- .../de/unibi/techfak/bibiserv/impl/JobProxyCall.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java index 6a0fd9b..a826e86 100644 --- a/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java +++ b/libs/bibitools/src/main/java/de/unibi/techfak/bibiserv/impl/JobProxyCall.java @@ -75,7 +75,16 @@ public JobProxyCall() { */ public JobProxyCall(BiBiTools wsstools) { this(wsstools, wsstools.getStatus()); - // get servr JobProxyServer from + setUri(wsstools); + } + + @Override + public void setBiBiTools(BiBiTools bibitools) { + super.setBiBiTools(bibitools); + setUri(bibitools); + } + + private void setUri(BiBiTools biBiTools){ try { uri = new URI(wsstools.getProperty("JobProxyServer.URI", "http://localhost:9999/")); } catch (URISyntaxException e) { @@ -86,7 +95,6 @@ public JobProxyCall(BiBiTools wsstools) { // should not occure } } - } public JobProxyCall(BiBiTools submitted_wsstools, Status submitted_status) {