Skip to content

Commit

Permalink
finish DRMAA framework (#49) and first adhoc solution for #56
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrue committed Jun 23, 2016
1 parent 57b0c39 commit 8cba477
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
import de.unibi.cebitec.bibiserv.jobproxy.model.exceptions.FrameworkException;
import de.unibi.cebitec.bibiserv.jobproxy.model.state.State;
import de.unibi.cebitec.bibiserv.jobproxy.model.state.States;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.TContainer;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.TMounts;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.TMounts.Mount;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.TPorts;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.TPorts.Port;
import de.unibi.cebitec.bibiserv.jobproxy.model.task.Task;
import java.io.File;
import java.util.ArrayList;
Expand Down Expand Up @@ -133,12 +138,62 @@ public String addTask(Task t) throws FrameworkException {

// set remote command
if (t.getContainer() == null) {
jobTemplate.setRemoteCommand(t.getCmd());
if (t.getCmd() != null && !t.getCmd().isEmpty()) {
jobTemplate.setRemoteCommand(t.getCmd());
} else {
throw new FrameworkException("CMD attribute must not be 'null' or empty!");
}
} else {
throw new UnsupportedOperationException("Docker container not supported yet.");
/*
build docker run cmd
${docker.bin} run [${docker.opt}] [PORTS{-p HOST:CONTAINER}] [MOUNTS{-v HOST:CONTAINER[:ro]}] $IMAGE $CMD
*/

StringBuilder dockercmd = new StringBuilder();

// docker bin + optional options
dockercmd.append(properties.getProperty("docker.bin", "/usr/bin/docker"))
.append(" run ").append(properties.getProperty("docker.opt",""))
.append(" ");



TContainer container = t.getContainer();


// ports
for (TPorts ps : container.getPorts()) {
Port p = ps.getPort();
dockercmd.append("-p ").append(p.getHost()).append(":").append(p.getContainer()).append(" ");
}
// volumes
for (TMounts ms : container.getMounts()) {
Mount m = ms.getMount();
dockercmd.append("-v ").append(m.getHost()).append(":").append(m.getContainer());
if (m.getMode() != null) {
if (m.getMode().equalsIgnoreCase("ro")) {
dockercmd.append(":ro");
} else {
LOGGER.info("unsupported mount mode : {} ",m.getMode());
}
}
dockercmd.append(" ");
}

dockercmd.append(container.getImage()).append(" ");
if (t.getCmd() != null && !t.getCmd().isEmpty()) {
dockercmd.append(t.getCmd());
}

// log dockercmd string
LOGGER.info(dockercmd.toString());

// set remote cmd
jobTemplate.setRemoteCommand(dockercmd.toString());
}

// set working dir from
// set working dir from properties or use default
jobTemplate.setWorkingDirectory(properties.getProperty("workingdir", System.getProperty("java.io.tmpdir")));

// submit jobTemplate
Expand Down Expand Up @@ -223,11 +278,14 @@ public String help() {
+ " not everything of the GridEngine features is supported by an API function. Special\n"
+ " GridEngine features are supported using the native option functions.\n\n"
+ " Supports the following properties :\n"
+ " KEY | DEFAULTVALUE\n"
+ "-----------------------------------------------------------------------------\n"
+ " serveruri | http://localhost:9999\n"
+ " workingdir | System.getProperty(\"java.io.tmpdir\")\n"
+ " nativeoptions | \n";
+ " KEY | DESCRIPTION | DEFAULTVALUE\n"
+ "------------------------------------------------------------------------------\n"
+ " serveruri | JobProxy Server URI | http://localhost:9999\n"
+ " workingdir | working dir | \"java.io.tmpdir\"\n"
+ " nativeoptions | general native options for DRMAA |\n"
+ " | scheduler. |\n"
+ " docker.bin | path to docker binary | /usr/bin/docker\n"
+ " docker.opt | general docker options |\n";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* <element name="image" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="ports" type="{}tPorts" maxOccurs="unbounded" minOccurs="0"/>
* <element name="mounts" type="{}tMounts" maxOccurs="unbounded" minOccurs="0"/>
* <element name="cmd" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@
* <element name="cputime" type="{http://www.w3.org/2001/XMLSchema}int" minOccurs="0"/>
* <element name="stdout" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="stderr" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <choice>
* <element name="cmd" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="container" type="{}tContainer"/>
* </choice>
* <element name="cmd" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="container" type="{}tContainer"/>
* </sequence>
* </restriction>
* </complexContent>
Expand Down Expand Up @@ -79,7 +77,7 @@ public class Task {

protected String stderr;

@NotEmpty
//@NotEmpty
protected String cmd;

@Valid
Expand Down
6 changes: 3 additions & 3 deletions JobProxyServerCLI/nbactions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA</exec.args>
<exec.args>-Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA -o /homes/jkrueger/tmp/jobproxy.drmaa.properties</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
Expand All @@ -24,7 +24,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA</exec.args>
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA -o /homes/jkrueger/tmp/jobproxy.drmaa.properties</exec.args>
<exec.executable>java</exec.executable>
<jpda.listen>true</jpda.listen>
</properties>
Expand All @@ -39,7 +39,7 @@
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
</goals>
<properties>
<exec.args>-Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA</exec.args>
<exec.args>-Djava.library.path=/vol/codine-8.3/lib/lx-amd64 -classpath %classpath de.unibi.cebitec.bibiserv.jobproxy.server.cli.CLI -f DRMAA -o /homes/jkrueger/tmp/jobproxy.drmaa.properties</exec.args>
<exec.executable>java</exec.executable>
</properties>
</action>
Expand Down

0 comments on commit 8cba477

Please sign in to comment.