This repository has been archived by the owner on May 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dxa-terminal: Adapt commands for task service to refactored service
- Loading branch information
Stefan Nothaas
committed
Feb 19, 2019
1 parent
94a7a7b
commit a88fbd7
Showing
2 changed files
with
47 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,25 @@ | |
|
||
package de.hhu.bsinfo.dxterm.server.cmd; | ||
|
||
import de.hhu.bsinfo.dxram.ms.*; | ||
import de.hhu.bsinfo.dxterm.*; | ||
import de.hhu.bsinfo.dxterm.server.AbstractTerminalCommand; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdin; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdout; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServiceAccessor; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.concurrent.Semaphore; | ||
|
||
import de.hhu.bsinfo.dxram.ms.MasterNodeEntry; | ||
import de.hhu.bsinfo.dxram.ms.MasterSlaveComputeService; | ||
import de.hhu.bsinfo.dxram.ms.TaskListener; | ||
import de.hhu.bsinfo.dxram.ms.TaskScriptState; | ||
import de.hhu.bsinfo.dxram.ms.script.TaskScript; | ||
import de.hhu.bsinfo.dxram.ms.script.TaskScriptNode; | ||
import de.hhu.bsinfo.dxterm.TerminalCommandString; | ||
import de.hhu.bsinfo.dxterm.server.AbstractTerminalCommand; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdin; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdout; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServiceAccessor; | ||
|
||
/** | ||
* Submit a task to a compute group | ||
* Submit a task to a compute group. | ||
* | ||
* @author Stefan Nothaas, [email protected], 03.04.2017 | ||
*/ | ||
|
@@ -41,17 +45,20 @@ public TcmdComptask() { | |
|
||
@Override | ||
public String getHelp() { | ||
return "Submit a task to a compute group\n" + "Usage: comptask <taskName> <cgid> [minSlaves] [maxSlaves] [wait] ...\n" + | ||
" taskName: String of the fully qualified class name of the task\n" + " cgid: Id of the compute group to submit the task to\n" + | ||
return "Submit a task to a compute group\n" + | ||
"Usage: comptask <taskName> <cgid> [minSlaves] [maxSlaves] [wait] ...\n" + | ||
" taskName: String of the fully qualified class name of the task\n" + | ||
" cgid: Id of the compute group to submit the task to\n" + | ||
" minSlaves: Minimum number of slaves required to start the task (default 0 = arbitrary)\n" + | ||
" maxSlaves: Maximum number of slaves for this task (default 0 = arbitrary)\n" + | ||
" wait: Wait/block until the task is completed (default true)\n" + | ||
" ...: Task arguments as further parameters depending on the task (default none)"; | ||
} | ||
|
||
@Override | ||
public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p_stdout, final TerminalServerStdin p_stdin, | ||
final TerminalServiceAccessor p_services) { | ||
public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p_stdout, | ||
final TerminalServerStdin p_stdin, | ||
final TerminalServiceAccessor p_services) { | ||
String taskName = p_cmd.getArgument(0, null); | ||
short cgid = p_cmd.getArgument(1, Short::valueOf, (short) -1); | ||
short minSlaves = p_cmd.getArgument(2, Short::valueOf, (short) 0); | ||
|
@@ -70,10 +77,12 @@ public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p | |
|
||
MasterSlaveComputeService mscomp = p_services.getService(MasterSlaveComputeService.class); | ||
TaskScriptNode task; | ||
|
||
if (p_cmd.getArgc() >= 5) { | ||
task = MasterSlaveComputeService.createTaskInstance(taskName, (Object[]) Arrays.copyOfRange(p_cmd.getArgs(), 5, p_cmd.getArgc())); | ||
task = mscomp.createTaskInstance(taskName, | ||
(Object[]) Arrays.copyOfRange(p_cmd.getArgs(), 5, p_cmd.getArgc())); | ||
} else { | ||
task = MasterSlaveComputeService.createTaskInstance(taskName); | ||
task = mscomp.createTaskInstance(taskName); | ||
} | ||
|
||
if (task == null) { | ||
|
@@ -147,7 +156,9 @@ public List<String> getArgumentCompletionSuggestions(final int p_argumentPos, fi | |
|
||
case 2: | ||
mscomp = p_services.getService(MasterSlaveComputeService.class); | ||
MasterSlaveComputeService.StatusMaster status = mscomp.getStatusMaster(p_cmdStr.getArgument(1, Short::valueOf, (short) 0)); | ||
MasterSlaveComputeService.StatusMaster status = mscomp.getStatusMaster( | ||
p_cmdStr.getArgument(1, Short::valueOf, (short) 0)); | ||
|
||
for (int i = 0; i <= status.getConnectedSlaves().size(); i++) { | ||
list.add(Integer.toString(i)); | ||
} | ||
|
@@ -158,6 +169,7 @@ public List<String> getArgumentCompletionSuggestions(final int p_argumentPos, fi | |
mscomp = p_services.getService(MasterSlaveComputeService.class); | ||
status = mscomp.getStatusMaster(p_cmdStr.getArgument(1, Short::valueOf, (short) 0)); | ||
int min = p_cmdStr.getArgument(2, Integer::valueOf, 0); | ||
|
||
for (int i = 0; i <= status.getConnectedSlaves().size(); i++) { | ||
if (i >= min) { | ||
list.add(Integer.toString(i)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,20 +16,23 @@ | |
|
||
package de.hhu.bsinfo.dxterm.server.cmd; | ||
|
||
import de.hhu.bsinfo.dxram.ms.*; | ||
import de.hhu.bsinfo.dxterm.*; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.Semaphore; | ||
|
||
import de.hhu.bsinfo.dxram.ms.MasterNodeEntry; | ||
import de.hhu.bsinfo.dxram.ms.MasterSlaveComputeService; | ||
import de.hhu.bsinfo.dxram.ms.TaskListener; | ||
import de.hhu.bsinfo.dxram.ms.TaskScriptState; | ||
import de.hhu.bsinfo.dxram.ms.script.TaskScript; | ||
import de.hhu.bsinfo.dxterm.TerminalCommandString; | ||
import de.hhu.bsinfo.dxterm.server.AbstractTerminalCommand; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdin; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServerStdout; | ||
import de.hhu.bsinfo.dxterm.server.TerminalServiceAccessor; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.concurrent.Semaphore; | ||
|
||
/** | ||
* Submit a list of tasks loaded from a file | ||
* Submit a list of tasks loaded from a file. | ||
* | ||
* @author Stefan Nothaas, [email protected], 03.04.2017 | ||
*/ | ||
|
@@ -40,13 +43,16 @@ public TcmdComptaskscript() { | |
|
||
@Override | ||
public String getHelp() { | ||
return "Submit a list of tasks loaded from a file\n" + "Usage: comptaskscript <fileName> <cgid> [wait]\n" + " fileName: Path to a task script file\n" + | ||
" cgid: Id of the compute group to submit the task script to\n" + " wait: Wait/block until script completed (default: true)"; | ||
return "Submit a list of tasks loaded from a file\n" + "Usage: comptaskscript <fileName> <cgid> [wait]\n" + | ||
" fileName: Path to a task script file\n" + | ||
" cgid: Id of the compute group to submit the task script to\n" + | ||
" wait: Wait/block until script completed (default: true)"; | ||
} | ||
|
||
@Override | ||
public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p_stdout, final TerminalServerStdin p_stdin, | ||
final TerminalServiceAccessor p_services) { | ||
public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p_stdout, | ||
final TerminalServerStdin p_stdin, | ||
final TerminalServiceAccessor p_services) { | ||
String fileName = p_cmd.getArgument(0, null); | ||
short cgid = p_cmd.getArgument(1, Short::valueOf, (short) -1); | ||
boolean wait = p_cmd.getArgument(2, Boolean::valueOf, true); | ||
|
@@ -62,7 +68,7 @@ public void exec(final TerminalCommandString p_cmd, final TerminalServerStdout p | |
} | ||
|
||
MasterSlaveComputeService mscomp = p_services.getService(MasterSlaveComputeService.class); | ||
TaskScript taskScript = MasterSlaveComputeService.readTaskScriptFromJsonFile(fileName); | ||
TaskScript taskScript = mscomp.readTaskScriptFromJsonFile(fileName); | ||
|
||
if (taskScript == null) { | ||
p_stdout.printflnErr("Reading task script from file '%s' failed", fileName); | ||
|