1 23 package org.objectweb.clif.scenario.util.isac.engine; 24 25 import org.objectweb.clif.scenario.util.isac.engine.loadprofile.GroupExecutionThread; 26 import org.objectweb.clif.scenario.util.isac.exception.IsacRuntimeException; 27 import org.objectweb.clif.scenario.util.isac.util.BooleanHolder; 28 import org.objectweb.util.monolog.api.BasicLevel; 29 30 36 public class IsacWithoutPoolEngine extends IsacScenarioEngine { 37 private Object scenarioLock = new Object (); 39 40 private Object activitiesLock = new Object (); 41 42 private Object surplusLock = new Object (); 45 46 private volatile BooleanHolder started = new BooleanHolder(false); 47 48 private volatile BooleanHolder suspended = new BooleanHolder(false); 49 50 private volatile BooleanHolder stopped = new BooleanHolder(false); 51 52 private GroupExecutionThread groupExecutionThread; 53 54 57 public IsacWithoutPoolEngine() { 58 } 59 60 63 public void join() { 64 } 65 66 69 public void resume() { 70 synchronized (scenarioLock) { 71 suspended.setBooleanValue(false); 72 scenarioLock.notifyAll(); 73 } 74 synchronized (this.activitiesLock) { 79 while (this.groupExecutionThread.isLocalSuspended()) { 80 try { 81 this.activitiesLock.wait(); 82 } catch (InterruptedException ex) { 83 throw new IsacRuntimeException( 84 "Unable to wait the resumed mode of the group execution thread",ex); 85 } 86 } 87 } 88 } 89 90 93 public void start() { 94 super.log.log(BasicLevel.INFO, "Isac start !!!"); 95 synchronized (this.scenarioLock) { 96 this.started.setBooleanValue(true); 97 this.stopped.setBooleanValue(false); 99 this.suspended.setBooleanValue(false); 100 } 101 this.groupExecutionThread = new GroupExecutionThread( 103 scenarioId, 104 super.groupDescriptionManager, super.behaviorManager, 105 super.sessionObjectManager, this.scenarioLock, 106 this.activitiesLock, super.dataCollectorWrite, 107 super.dataCollectorWrite_lock, super.bladeInsertResponse, 108 super.bladeInsertResponse_lock, this.started, this.stopped, 109 this.suspended, this.surplusLock); 110 111 this.groupExecutionThread.start(); 113 } 114 115 118 public void stop() { 119 synchronized (this.scenarioLock) { 121 stopped.setBooleanValue(true); 122 } 123 if (suspended.getBooleanValue()) { 125 resume(); 126 } 127 synchronized (this.surplusLock) { 129 this.surplusLock.notify(); 130 } 131 synchronized (this.activitiesLock) { 133 while (!this.groupExecutionThread.isLocalStopped()) { 134 try { 135 this.activitiesLock.wait(); 136 } catch (InterruptedException ex) { 137 throw new IsacRuntimeException( 138 "Unable to wait the stopped mode of the group execution thread",ex); 139 } 140 } 141 } 142 } 143 144 147 public void suspend() { 148 synchronized (scenarioLock) { 149 suspended.setBooleanValue(true); 150 } 151 synchronized (this.surplusLock) { 153 this.surplusLock.notify(); 154 } 155 synchronized (this.activitiesLock) { 159 while (!this.groupExecutionThread.isLocalSuspended()) { 160 try { 161 this.activitiesLock.wait(); 162 } catch (InterruptedException ex) { 163 throw new IsacRuntimeException( 164 "Unable to wait the suspended mode of the group execution thread",ex); 165 } 166 } 167 } 168 } 169 } | Popular Tags |