1 23 24 25 import org.objectweb.clif.scenario.util.multithread.MTScenario; 26 import org.objectweb.clif.scenario.util.multithread.MTScenarioSession; 27 import org.objectweb.clif.storage.api.ActionEvent; 28 import org.objectweb.clif.supervisor.api.ClifException; 29 30 import java.util.StringTokenizer ; 31 32 33 38 public class Autotest extends MTScenario 39 { 40 long arg_sleep_ms = 0; 41 42 43 48 public MTScenarioSession newSession(int sessionId, String arg) 49 throws ClifException 50 { 51 try 52 { 53 StringTokenizer parser = new StringTokenizer (arg); 54 arg_sleep_ms = Integer.parseInt(parser.nextToken()); 55 } 56 catch (Exception ex) 57 { 58 throw new ClifException( 59 "Autotest requires 4 arguments:\n\t<number of concurrent threads>\n\t<test duration in seconds>\n\t<ramp-up duration in seconds>\n\t<iteration sleep duration in ms>", 60 ex); 61 } 62 return new Session(); 63 } 64 65 66 class Session implements MTScenarioSession 67 { 68 public ActionEvent action(ActionEvent report) 69 { 70 try 71 { 72 Thread.sleep(arg_sleep_ms); 73 } 74 catch (InterruptedException ex) 75 { 76 ex.printStackTrace(System.err); 77 } 78 report.duration = (int) (System.currentTimeMillis() - report.getDate()); 79 report.type = "sleep action"; 80 return report; 81 } 82 } 83 } 84 | Popular Tags |