Skip to content

Commit

Permalink
fixed redistribute option
Browse files Browse the repository at this point in the history
  • Loading branch information
ddcap committed Apr 17, 2015
1 parent e82c955 commit 75854f6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
58 changes: 31 additions & 27 deletions halvade/src/be/ugent/intec/halvade/tools/AlignerInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ public abstract class AlignerInstance {
protected boolean keep = false;
protected ChromosomeSplitter splitter;
protected int containerMinusTasksLeft;
protected int containers;
protected boolean redistribute;


protected AlignerInstance(Mapper.Context context, String bin) throws IOException, URISyntaxException {
AlignerInstance.context = context;
header = null;
containers = HalvadeConf.getMapContainerCount(context.getConfiguration());
containerMinusTasksLeft = HalvadeConf.lessTasksLeftThanContainers(context.getConfiguration());
redistribute = HalvadeConf.getRedistribute(context.getConfiguration());
writableRecord = new SAMRecordWritable();
Expand All @@ -91,34 +93,36 @@ protected AlignerInstance(Mapper.Context context, String bin) throws IOException
}

protected void getIdleCores(Mapper.Context context) throws IOException {
int totalCores = HalvadeConf.getVcores(context.getConfiguration());
int usedCores = 0;
// run "ps -eo args" and search for any process with bwa aln
// count the -t options of all bwa aln instances this is used cores;
String line;
Process p = Runtime.getRuntime().exec("ps -eo args");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null) {
if(line.contains("bwa")) {
System.out.println(line); //<-- Parse data here.
if(line.contains("sampe") || line.contains("samse"))
usedCores++;
else if (line.contains("aln")) {
String[] cmd = line.split("\\s+");
int i = 0;
while (i < cmd.length && !cmd[i].equals("-t"))
i++;
int alnCores = 1;
if (i + 1 < cmd.length)
alnCores = Integer.parseInt(cmd[i+1]);
Logger.DEBUG("Aln used cores: " + alnCores);
usedCores += alnCores;
}
}
}
input.close();
// int totalCores = HalvadeConf.getVcores(context.getConfiguration());
// int usedCores = 0;
// // run "ps -eo args" and search for any process with bwa aln
// // count the -t options of all bwa aln instances this is used cores;
// String line;
// Process p = Runtime.getRuntime().exec("ps -eo args");
// BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
// while ((line = input.readLine()) != null) {
// if(line.contains("bwa")) {
// System.out.println(line); //<-- Parse data here.
// if(line.contains("sampe") || line.contains("samse"))
// usedCores++;
// else if (line.contains("aln")) {
// String[] cmd = line.split("\\s+");
// int i = 0;
// while (i < cmd.length && !cmd[i].equals("-t"))
// i++;
// int alnCores = 1;
// if (i + 1 < cmd.length)
// alnCores = Integer.parseInt(cmd[i+1]);
// Logger.DEBUG("Aln used cores: " + alnCores);
// usedCores += alnCores;
// }
// }
// }
// input.close();

threads = Math.max(threads, totalCores - usedCores);
// threads = Math.max(threads, totalCores - usedCores);
if (containerMinusTasksLeft > 0 ) threads = 6;
// if (containerMinusTasksLeft > containers/2) threads = 8;
}

protected int feedLine(String line, ProcessBuilderWrapper proc) throws IOException {
Expand Down
3 changes: 3 additions & 0 deletions halvade/src/be/ugent/intec/halvade/utils/HalvadeConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ public static boolean addTaskRunning(Configuration conf, String val) throws IOEx
public static void setMapContainerCount(Configuration conf, int val) {
conf.setInt(totalContainers, val);
}
public static int getMapContainerCount(Configuration conf) {
return conf.getInt(totalContainers, 1);
}
public static int lessTasksLeftThanContainers(Configuration conf) throws IOException, URISyntaxException {
int containers = conf.getInt(totalContainers, 1);
int tasks = 0;
Expand Down

0 comments on commit 75854f6

Please sign in to comment.