[Swift-commit] r7069 - in trunk/src/org/griphyn/vdl/karajan/monitor: . items monitors/ansi monitors/ansi/tui processors/swift
hategan at ci.uchicago.edu
hategan at ci.uchicago.edu
Mon Sep 16 02:06:34 CDT 2013
Author: hategan
Date: 2013-09-16 02:06:34 -0500 (Mon, 16 Sep 2013)
New Revision: 7069
Modified:
trunk/src/org/griphyn/vdl/karajan/monitor/SystemState.java
trunk/src/org/griphyn/vdl/karajan/monitor/items/ApplicationState.java
trunk/src/org/griphyn/vdl/karajan/monitor/items/SummaryItem.java
trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/SummaryPane.java
trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBar.java
trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBars.java
trunk/src/org/griphyn/vdl/karajan/monitor/processors/swift/SummaryProcessor.java
Log:
show "completed in previous run" jobs as part of "Finished successfully" using a different color bar; show elapsed and estimated times in minute precision to reduce the wildly fluctuating numbers; properly take finished in previous run jobs into account (i.e. ignore them instead of expecting all jobs to finish in a second) when estimating time left
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/SystemState.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/SystemState.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/SystemState.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -34,10 +34,12 @@
import org.griphyn.vdl.karajan.monitor.items.SummaryItem;
public class SystemState {
+ public static final boolean SHOW_SECONDS = false;
+
private Map<StatefulItemClass, StatefulItemClassSet<? extends StatefulItem>> classes;
private Set<SystemStateListener> listeners;
private Map<String, Stats> stats;
- private int total, completed;
+ private int total, completed, completedPreviously;
private long start, currentTime;
private Stack stack;
private String projectName;
@@ -146,6 +148,14 @@
return completed;
}
+ public int getCompletedPreviously() {
+ return completedPreviously;
+ }
+
+ public void setCompletedPreviously(int completedPreviously) {
+ this.completedPreviously = completedPreviously;
+ }
+
public long getStart() {
return start;
}
@@ -175,12 +185,16 @@
}
public String getEstimatedTimeLeftFormatted() {
- if (completed == 0) {
+ // don't use previously completed jobs to estimate remaining time
+ // since they "finish" pretty quickly
+ int c = completed - completedPreviously;
+ int t = total - completedPreviously;
+ if (c == 0) {
return "N/A";
}
else {
long time = System.currentTimeMillis() - start;
- long et = (time * total / completed) - time;
+ long et = (time * t / c) - time;
return format(et);
}
}
@@ -221,12 +235,14 @@
sb.append('0');
}
sb.append(m);
- sb.append(':');
- int s = (int) (v % 60);
- if (s < 10) {
- sb.append('0');
+ if (SHOW_SECONDS) {
+ sb.append(':');
+ int s = (int) (v % 60);
+ if (s < 10) {
+ sb.append('0');
+ }
+ sb.append(s);
}
- sb.append(s);
return sb.toString();
}
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/items/ApplicationState.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/items/ApplicationState.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/items/ApplicationState.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -9,21 +9,30 @@
*/
package org.griphyn.vdl.karajan.monitor.items;
+import java.util.ArrayList;
+import java.util.List;
+
public enum ApplicationState {
INITIALIZING("Initializing"), SELECTING_SITE("Selecting site", "Sel. site"), STAGE_IN("Stage in"),
SUBMITTING("Submitting"), SUBMITTED("Submitted"), ACTIVE("Active"), STAGE_OUT("Stage out"),
- FAILED("Failed"), REPLICATING("Replicating"), FINISHED_SUCCESSFULLY("Finished successfully", "Finished");
+ FAILED("Failed"), REPLICATING("Replicating"), FINISHED_IN_PREVIOUS_RUN("Finished in previous run", "Finished in prev. run", false),
+ FINISHED_SUCCESSFULLY("Finished successfully");
private String name, shortName;
+ private boolean enabled;
private ApplicationState(String name) {
- this.name = name;
- this.shortName = name;
+ this(name, name);
}
private ApplicationState(String name, String shortName) {
+ this(name, name, true);
+ }
+
+ private ApplicationState(String name, String shortName, boolean enabled) {
this.name = name;
this.shortName = shortName;
+ this.enabled = enabled;
}
public String getName() {
@@ -37,8 +46,29 @@
public void setShortName(String shortName) {
this.shortName = shortName;
}
+
+ public boolean isEnabled() {
+ return enabled;
+ }
public String toString() {
return name;
}
+
+ private static ApplicationState[] enabledValues;
+
+ public synchronized static ApplicationState[] enabledValues() {
+ if (enabledValues == null) {
+ List<ApplicationState> l = new ArrayList<ApplicationState>();
+ for (ApplicationState s : values()) {
+ if (s.isEnabled()) {
+ l.add(s);
+ }
+ }
+ enabledValues = new ApplicationState[l.size()];
+ l.toArray(enabledValues);
+ }
+
+ return enabledValues;
+ }
}
\ No newline at end of file
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/items/SummaryItem.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/items/SummaryItem.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/items/SummaryItem.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -27,7 +27,7 @@
import org.griphyn.vdl.karajan.monitor.SystemState;
public class SummaryItem extends AbstractStatefulItem {
- public static final ApplicationState[] STATES = ApplicationState.values();
+ public static final ApplicationState[] STATES = ApplicationState.enabledValues();
public static ApplicationState getStateByKey(String key) {
for (ApplicationState s : STATES) {
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/SummaryPane.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/SummaryPane.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/SummaryPane.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -22,6 +22,7 @@
import org.griphyn.vdl.karajan.monitor.SystemState;
import org.griphyn.vdl.karajan.monitor.common.GlobalTimer;
+import org.griphyn.vdl.karajan.monitor.items.ApplicationState;
import org.griphyn.vdl.karajan.monitor.items.StatefulItemClass;
import org.griphyn.vdl.karajan.monitor.items.SummaryItem;
import org.griphyn.vdl.karajan.monitor.monitors.ansi.tui.ANSI;
@@ -66,15 +67,30 @@
if (summary != null) {
Map<String, Integer> counts = summary.getCounts(state);
for (int i = 0; i < SummaryItem.STATES.length; i++) {
- Integer v = counts.get(SummaryItem.STATES[i].getName());
- if (v != null) {
- bars.setValue(i, v);
- bars.setText(i, v.toString());
+ if (SummaryItem.STATES[i].isEnabled()) {
+ Integer v = counts.get(SummaryItem.STATES[i].getName());
+ int iv = 0, prev = 0;
+ if (v != null) {
+ iv = v.intValue();
+ }
+
+ if (SummaryItem.STATES[i] == ApplicationState.FINISHED_SUCCESSFULLY) {
+ v = counts.get(ApplicationState.FINISHED_IN_PREVIOUS_RUN.getName());
+ if (v != null) {
+ prev = v.intValue();
+ }
+ }
+
+ if (prev == 0) {
+ bars.setValue(i, iv);
+ bars.setText(i, String.valueOf(iv));
+ }
+ else {
+ bars.setValue(i, iv + prev);
+ bars.setOtherValue(i, prev);
+ bars.setText(i, String.valueOf(iv + prev) + " (" + String.valueOf(prev) + ")");
+ }
}
- else {
- bars.setValue(i, 0);
- bars.setText(i, "0");
- }
}
}
// mem
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBar.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBar.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBar.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -20,14 +20,15 @@
import java.io.IOException;
public class LevelBar extends Component {
- private float value;
+ private float value, other;
private String text;
- private int textColor;
+ private int textColor, otherColor;
public LevelBar() {
bgColor = ANSI.BLACK;
fgColor = ANSI.RED;
textColor = ANSI.WHITE;
+ otherColor = ANSI.MAGENTA;
}
public float getValue() {
@@ -37,6 +38,10 @@
public void setValue(float value) {
this.value = value;
}
+
+ public void setOtherValue(float ov) {
+ this.other = ov;
+ }
protected void draw(ANSIContext context) throws IOException {
if (text == null) {
@@ -49,13 +54,19 @@
private void drawWithoutText(ANSIContext context) throws IOException {
context.moveTo(sx, sy);
- context.bgColor(fgColor);
- int c = (int) (value * width);
- context.spaces(c);
- context.bgColor(bgColor);
- context.spaces(width - c);
+ int crt;
+ crt = spaces(context, 0, other * width, otherColor);
+ crt = spaces(context, crt, (value - other) * width, fgColor);
+ crt = spaces(context, crt, width, bgColor);
}
+ private int spaces(ANSIContext context, int pos, float count, int color) throws IOException {
+ int c = (int) count;
+ context.bgColor(color);
+ context.spaces(Math.min(c, width - pos));
+ return pos + c;
+ }
+
private void drawWithText(ANSIContext context) throws IOException {
int textPos = (width - text.length()) / 2;
StringBuilder sb = new StringBuilder();
@@ -65,14 +76,23 @@
String s = sb.toString();
context.moveTo(sx, sy);
- context.bgColor(fgColor);
context.fgColor(textColor);
- int c = (int) (value * width);
- context.text(s.substring(0, c));
- context.bgColor(bgColor);
- context.text(s.substring(c));
+
+ int crt;
+ crt = text(context, s, 0, other * width, otherColor);
+ crt = text(context, s, crt, (value - other) * width, fgColor);
+ crt = text(context, s, crt, width, bgColor);
}
+ private int text(ANSIContext context, String str, int pos, float count, int color) throws IOException {
+ int c = (int) count;
+ context.bgColor(color);
+ for (int i = 0; i < c && pos + i < str.length(); i++) {
+ context.putChar(str.charAt(pos + i));
+ }
+ return pos + c;
+ }
+
private void spaces(StringBuilder sb, int count) {
for(int i = 0; i < count; i++) {
sb.append(' ');
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBars.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBars.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/monitors/ansi/tui/LevelBars.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -40,10 +40,24 @@
}
}
for (int i = 0; i < values.length; i++) {
- getBar(i).setValue((float) values[i] / range);
+ if (range > 0) {
+ getBar(i).setValue((float) values[i] / range);
+ }
+ else {
+ getBar(i).setValue(0);
+ }
}
}
+ public void setOtherValue(int i, int ov) {
+ if (range != 0) {
+ getBar(i).setOtherValue((float) ov / range);
+ }
+ else {
+ getBar(i).setOtherValue(0);
+ }
+ }
+
public void setText(int index, String text) {
getBar(index).setText(text);
}
@@ -60,6 +74,4 @@
}
super.validate();
}
-
-
}
Modified: trunk/src/org/griphyn/vdl/karajan/monitor/processors/swift/SummaryProcessor.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/monitor/processors/swift/SummaryProcessor.java 2013-09-16 07:03:25 UTC (rev 7068)
+++ trunk/src/org/griphyn/vdl/karajan/monitor/processors/swift/SummaryProcessor.java 2013-09-16 07:06:34 UTC (rev 7069)
@@ -50,7 +50,12 @@
continue;
}
String[] v = pair.split(":");
- s.setCount(v[0].trim(), Integer.parseInt(v[1]));
+ String key = v[0].trim();
+ int value = Integer.parseInt(v[1]);
+ if (key.equals(ApplicationState.FINISHED_IN_PREVIOUS_RUN.getName())) {
+ state.setCompletedPreviously(value);
+ }
+ s.setCount(key, value);
}
state.itemUpdated(s);
}
More information about the Swift-commit
mailing list