[Swift-commit] r5146 - in trunk/src/org/griphyn/vdl: karajan/lib util

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Wed Sep 21 10:53:23 CDT 2011


Author: wozniak
Date: 2011-09-21 10:53:22 -0500 (Wed, 21 Sep 2011)
New Revision: 5146

Modified:
   trunk/src/org/griphyn/vdl/karajan/lib/RuntimeStats.java
   trunk/src/org/griphyn/vdl/util/VDL2Config.java
Log:
New VDL2Config settings ticker.prefix and ticker.date.format


Modified: trunk/src/org/griphyn/vdl/karajan/lib/RuntimeStats.java
===================================================================
--- trunk/src/org/griphyn/vdl/karajan/lib/RuntimeStats.java	2011-09-21 15:48:47 UTC (rev 5145)
+++ trunk/src/org/griphyn/vdl/karajan/lib/RuntimeStats.java	2011-09-21 15:53:22 UTC (rev 5146)
@@ -25,7 +25,8 @@
 
 	public static final Arg PA_STATE = new Arg.Positional("state");
     //formatter for timestamp against std.err lines
-	public static final SimpleDateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
+	public static SimpleDateFormat formatter = 
+		new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
 	public static final int MIN_PERIOD_MS=1000;
 	public static final int MAX_PERIOD_MS=30000;
 
@@ -74,10 +75,21 @@
 		t.setDaemon(true);
 		t.start();
 		setTicker(stack, t);
+		
+		// Allow user to reformat output date
+		String format;
+		try {
+			format = VDL2Config.getDefaultConfig().getTickerDateFormat();
+		} 
+		catch (IOException e) {
+			throw new ExecutionException(e);
+		}
+		if (format != null && format.length() > 0)
+			formatter = 
+				new SimpleDateFormat(format);
 		return null;
 	}
 
-
 	public Object vdl_setprogress(VariableStack stack) throws ExecutionException {
 		setProgress(stack, TypeUtil.toString(PA_STATE.getValue(stack)));
 		return null;
@@ -116,6 +128,8 @@
 		private boolean disabled;
 		private boolean shutdown;
 
+		String tickerPrefix;
+		
 		public ProgressTicker() {
 			super("Progress ticker");
 			try {
@@ -123,6 +137,8 @@
 					logger.info("Ticker disabled in configuration file");
 					disabled = true;
 				}
+				tickerPrefix = 
+					VDL2Config.getConfig().getTickerPrefix();
 			}
 			catch (IOException e) {
 				logger.debug("Could not read swift properties", e);
@@ -156,7 +172,7 @@
 			long now = System.currentTimeMillis();
 			if(lastDumpTime + MIN_PERIOD_MS > now) return;
 			lastDumpTime = now;
-			printStates("Progress:");
+			printStates(tickerPrefix);
 		}
 
 		void finalDumpState() {
@@ -190,16 +206,16 @@
 			return summary;
 		}
 
-		void printStates(String header) {
+		void printStates(String prefix) {
 			Map<String, Integer> summary = getSummary();
 		//	SimpleDateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss Z");
 
 			// output the results of summarization, in a relatively
 			// pretty form - first the preferred order listed elements,
 			// and then anything remaining
-			System.err.print(header);
+			System.err.print(prefix + " ");
 			//System.err.print("  time:" + (System.currentTimeMillis() - start));
-			System.err.print("  time: " + formatter.format(System.currentTimeMillis()));
+			System.err.print(formatter.format(System.currentTimeMillis()));
 
 			for (int pos = 0; pos < preferredOutputOrder.length; pos++) {
 				String key = preferredOutputOrder[pos];

Modified: trunk/src/org/griphyn/vdl/util/VDL2Config.java
===================================================================
--- trunk/src/org/griphyn/vdl/util/VDL2Config.java	2011-09-21 15:48:47 UTC (rev 5145)
+++ trunk/src/org/griphyn/vdl/util/VDL2Config.java	2011-09-21 15:53:22 UTC (rev 5146)
@@ -98,6 +98,8 @@
 		
 		put("cdm.broadcast.mode", "file");
 		put("use.provider.staging", "false");
+		put("ticker.date.format", "");
+		put("ticker.prefix", "Progress:  time:");
 	}
 
 	private VDL2Config(VDL2Config other) {
@@ -215,6 +217,14 @@
 		return Boolean.valueOf(getProperty(VDL2ConfigProperties.PROVENANCE_LOG, "false")).booleanValue();
 	}
 
+	public String getTickerDateFormat() { 
+		return getProperty("ticker.date.format");
+	}
+	
+	public String getTickerPrefix() { 
+		return getProperty("ticker.prefix");
+	}
+	
 	public String toString() {
 		return "Swift configuration " + files;
 	}




More information about the Swift-commit mailing list