From: <jsa...@us...> - 2009-06-07 12:01:45
|
Revision: 165 http://flexotask.svn.sourceforge.net/flexotask/?rev=165&view=rev Author: jsauerbach Date: 2009-06-07 12:01:37 +0000 (Sun, 07 Jun 2009) Log Message: ----------- More release prep: scheduler diagnostic test only runs when the underlying VM supports the functionality; change some test output to clarify that some "abnormal" results are not errors; fix some javadoc glitches. Modified Paths: -------------- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java trunk/flexotask-functiontest/src/badscheduler/Main.java trunk/flexotask-functiontest/src/highfreqread/Main.java trunk/flexotask-functiontest/src/nativeio/Main.java Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/scheduling/reactive/ReactiveRunnableElement.java 2009-06-07 12:01:37 UTC (rev 165) @@ -77,7 +77,7 @@ /** * Add a predecessor, which is always a connection feeding one of this task's input ports. * Connections don't have predecessors - * @param taskElement the task element + * @param connectionElement the task element */ public void addPredecessor(ReactiveRunnableElement connectionElement) { if (predecessors == null) { Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/system/FlexotaskSystemSupport.java 2009-06-07 12:01:37 UTC (rev 165) @@ -156,6 +156,15 @@ } /** + * Test whether running in an flexotask-enabled VM at at least level 1 + * @return true if running in an flexotask-enabled VM at at least level 1 + */ + public static boolean isFlexotaskVM1() + { + return vmBridge1 != null; + } + + /** * Perform an accurate nanotime sleep to the next deadline * @param nextDeadline the time, in nanoseconds, at which to wake up, using the same scale that * nanoTime uses. Modified: trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java =================================================================== --- trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask/src/com/ibm/realtime/flexotask/vm/FlexotaskVMBridge1.java 2009-06-07 12:01:37 UTC (rev 165) @@ -13,12 +13,14 @@ */ package com.ibm.realtime.flexotask.vm; +import com.ibm.realtime.flexotask.system.FlexotaskSystemSupport; + /** * Functions added to FlexotaskVMBridge after the release of Flexotask 2.0.0 and before the next release thereafter. */ public interface FlexotaskVMBridge1 extends FlexotaskVMBridge { - /** @see FlexotaskSystemSupport#adoptPriority */ + /** @see FlexotaskSystemSupport#adoptPriority(int) */ public boolean adoptPriority(int newPriority); - /** @see FlexotaskSystemSupport#getIllegalAllocationClass */ + /** @see FlexotaskSystemSupport#getIllegalAllocationClass() */ public Class getIllegalAllocationClass(); } Modified: trunk/flexotask-functiontest/src/badscheduler/Main.java =================================================================== --- trunk/flexotask-functiontest/src/badscheduler/Main.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask-functiontest/src/badscheduler/Main.java 2009-06-07 12:01:37 UTC (rev 165) @@ -24,10 +24,10 @@ import com.ibm.realtime.flexotask.scheduling.FlexotaskScheduler; import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerFactory; import com.ibm.realtime.flexotask.scheduling.FlexotaskSchedulerRegistry; +import com.ibm.realtime.flexotask.system.FlexotaskSystemSupport; import com.ibm.realtime.flexotask.template.FlexotaskTaskTemplate; import com.ibm.realtime.flexotask.template.FlexotaskTemplate; import com.ibm.realtime.flexotask.template.FlexotaskValidationException; -import com.ibm.realtime.flexotask.util.SimulationSupport; /** * Tests latest support for diagnosing schedulers that fail. @@ -35,6 +35,14 @@ public class Main { public static void main(String[] args) throws FlexotaskValidationException { + /* Test whether support is present */ + if (!FlexotaskSystemSupport.isFlexotaskVM1()) { + String reason = FlexotaskSystemSupport.isFlexotaskVM() ? "older" : "simulated"; + /* No point in running this test */ + System.out.println("Skipping scheduler diagnostic test since running on " + reason + " Flexotask VM"); + return; + } + /* Set up bad scheduler factory */ FlexotaskSchedulerRegistry.registerScheduler(new FlexotaskSchedulerFactory(){ public String getName() { @@ -44,18 +52,21 @@ return new BadScheduler(); } }); + /* Make single task template for testing */ FlexotaskTemplate template = new FlexotaskTemplate(); FlexotaskTaskTemplate task = new FlexotaskTaskTemplate(); task.setName("only"); task.setImplementationClass(NullFlexotask.class.getName()); template.getTasks().add(task); + /* Set up to run the same template successively in different failure modes. The mode is indicated to the scheduler * via the parameter passed to the only task */ int[] mode = new int[1]; Map<String,Object> parameters = new HashMap<String,Object>(); parameters.put("only", mode); + /* In mode 0, the scheduler runs the task for a few seconds but doesn't fail */ FlexotaskGraph graph = template.validate("bad", parameters); graph.getRunner().start(); @@ -67,9 +78,11 @@ if (graph.getException() != null) { throw new IllegalStateException("Unexpected exception in mode 0", graph.getException()); } + /* In mode 1, the scheduler fails with a NullPointerException, simulating some programming mistake */ mode[0] = 1; graph = template.validate("bad", parameters); + System.out.println("A NullPointerException is expected here:"); graph.getRunner().start(); try { Thread.sleep(2000); } catch(InterruptedException e) {} runner = graph.getRunner(); @@ -83,10 +96,12 @@ if (!(ex instanceof NullPointerException)) { throw new IllegalStateException("Unexpected exception type " + ex.getClass().getName() + " in mode 1"); } + /* In mode 2, the scheduler throws IllegalArgumentException with message "voila", simulating the scheduler finding some * terminal violation of its assumptions */ mode[0] = 2; graph = template.validate("bad", parameters); + System.out.println("An IllegalArgumentException is expected here:"); graph.getRunner().start(); try { Thread.sleep(2000); } catch(InterruptedException e) {} runner = graph.getRunner(); @@ -103,14 +118,12 @@ if (!"voila".equals(ex.getMessage())) { throw new IllegalStateException("Unexpected exception message '" + ex.getMessage() + "' in mode 2"); } + /* In mode 3, the scheduler "accidentally" allocates something, causing an IllegalStateException to be issued * from a controller or driver at the next memory switch. The bad class should be java.lang.Long. */ - if (SimulationSupport.isSimulating()) { - System.err.println("Skipping mode 3 test because not running in a real time VM"); - return; - } mode[0] = 3; graph = template.validate("bad", parameters); + System.out.println("An IllegalStateException is expected here:"); graph.getRunner().start(); try { Thread.sleep(2000); } catch(InterruptedException e) {} runner = graph.getRunner(); Modified: trunk/flexotask-functiontest/src/highfreqread/Main.java =================================================================== --- trunk/flexotask-functiontest/src/highfreqread/Main.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask-functiontest/src/highfreqread/Main.java 2009-06-07 12:01:37 UTC (rev 165) @@ -102,7 +102,7 @@ graph.getRunner().start(); HighFreqReaderIntf guard = (HighFreqReaderIntf) graph.getGuardObject("Test"); - System.err.println("Graph started"); + System.out.println("Graph started."); int sleepsPerSecond = 1000 / oThreadSleep; for (int i = 0; i < runlength * 1000 / oThreadSleep; i++) { Thread.sleep(oThreadSleep); @@ -110,17 +110,17 @@ try { guard.update((short) i); } catch (AtomicException e) { - System.err.println("Transaction " + i + " aborted"); + System.out.println("Transaction " + i + " aborted (expected)"); } catch (Exception e) { e.printStackTrace(); } } if (i % sleepsPerSecond == 0) { - System.err.println(i + (communicate ? " updates" : " waits")); + System.out.println(i + (communicate ? " updates" : " waits")); } } - System.err.println("Destroying graph"); + System.out.println("Destroying graph"); graph.destroy(); - System.err.println("Done"); + System.out.println("Done"); } } Modified: trunk/flexotask-functiontest/src/nativeio/Main.java =================================================================== --- trunk/flexotask-functiontest/src/nativeio/Main.java 2009-06-06 19:24:28 UTC (rev 164) +++ trunk/flexotask-functiontest/src/nativeio/Main.java 2009-06-07 12:01:37 UTC (rev 165) @@ -45,7 +45,7 @@ { /* Check environment ... no point in running when only simulating */ if (NativeIO.isSimulated()) { - System.err.println("NativeIO test not run since native support not present"); + System.out.println("Skipping NativeIO test since not on a real Flexotask VM"); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |