Skip to content

Commit

Permalink
Merge pull request #15 from BiBiServ/feature/running-docker-containers
Browse files Browse the repository at this point in the history
Feature running docker containers
  • Loading branch information
jkrue authored Nov 8, 2016
2 parents e8c0b00 + f05067a commit 6817a55
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -932,8 +926,8 @@ public File getTmpDir() throws FileNotFoundException {
*
* @return
*/
public Element getToolDescription() {
return (Element) runnableitem;
public TrunnableItem getToolDescription() {
return runnableitem;
}

/**
Expand Down Expand Up @@ -2285,7 +2279,7 @@ public String generateCmdLineString(String id, Map<String, String> 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())) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.*;

Expand Down Expand Up @@ -77,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) {
Expand All @@ -88,7 +95,6 @@ public JobProxyCall(BiBiTools wsstools) {
// should not occure
}
}

}

public JobProxyCall(BiBiTools submitted_wsstools, Status submitted_status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions libs/ontoaccess/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
<dependency>
<groupId>org.apache.jena</groupId>
<artifactId>jena-core</artifactId>
<version>2.10.1</version>
<version>2.7.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.github.ansell.pellet/pellet-jena -->
<dependency>
<groupId>com.github.ansell.pellet</groupId>
<artifactId>pellet-jena</artifactId>
<version>2.3.6-ansell</version>
<version>2.3.2</version>
</dependency>

</dependencies>
Expand Down

0 comments on commit 6817a55

Please sign in to comment.