1 23 package org.objectweb.clif.scenario.util.isac.engine; 24 25 import java.io.Serializable ; 26 27 import org.objectweb.clif.scenario.util.isac.engine.loadprofile.GroupExecutionWithPoolThread; 28 import org.objectweb.clif.scenario.util.isac.exception.IsacRuntimeException; 29 import org.objectweb.clif.scenario.util.isac.util.BooleanHolder; 30 import org.objectweb.util.monolog.api.BasicLevel; 31 32 38 public class IsacWithPoolEngine extends IsacScenarioEngine { 39 private Object suspendLock = new Object (); 41 42 private Object componentLock = new Object (); 43 44 private Object timerLock = new Object (); 45 46 private Object surplusLock = new Object (); 47 48 private volatile BooleanHolder started = new BooleanHolder(false); 49 50 private volatile BooleanHolder suspended = new BooleanHolder(false); 51 52 private volatile BooleanHolder stopped = new BooleanHolder(false); 53 54 private GroupExecutionWithPoolThread groupExecutionWithPoolThread; 55 56 59 public IsacWithPoolEngine() { 60 } 61 62 68 public void init(Serializable arg) { 69 super.init(arg); 70 this.stopped.setBooleanValue(false); 72 this.suspended.setBooleanValue(false); 73 this.groupExecutionWithPoolThread = new GroupExecutionWithPoolThread( 75 scenarioId, 76 super.groupDescriptionManager, super.behaviorManager, 77 super.sessionObjectManager, suspendLock, timerLock, 78 componentLock, surplusLock, super.dataCollectorWrite, 79 super.dataCollectorWrite_lock, super.bladeInsertResponse, 80 super.bladeInsertResponse_lock, this.stopped, this.suspended); 81 } 82 83 86 public void join() { 87 } 88 89 92 public void resume() { 93 suspended.setBooleanValue(false); 94 synchronized (this.suspendLock) { 95 suspendLock.notifyAll(); 96 } 97 synchronized (this.componentLock) { 102 while (this.groupExecutionWithPoolThread.isLocalSuspended()) { 103 try { 104 this.componentLock.wait(); 105 } catch (InterruptedException ex) { 106 throw new IsacRuntimeException( 107 "Unable to wait the resumed mode of the group execution thread -> " 108 + ex.toString()); 109 } 110 } 111 } 112 } 113 114 117 public void start() { 118 super.log.log(BasicLevel.INFO, "Isac start !!!"); 119 this.started.setBooleanValue(true); 120 121 this.groupExecutionWithPoolThread.start(); 123 } 124 125 128 public void stop() { 129 stopped.setBooleanValue(true); 131 132 if (suspended.getBooleanValue()) { 134 resume(); 135 } 136 137 synchronized (this.componentLock) { 139 while (!this.groupExecutionWithPoolThread.isLocalStopped()) { 140 try { 141 this.componentLock.wait(); 142 } catch (InterruptedException ex) { 143 throw new IsacRuntimeException( 144 "Unable to wait the stopped mode of the group execution thread -> " 145 + ex.toString()); 146 } 147 } 148 } 149 } 150 151 154 public void suspend() { 155 suspended.setBooleanValue(true); 156 157 synchronized (this.componentLock) { 161 synchronized (this.surplusLock) { 162 this.surplusLock.notify(); 164 } 165 while (!this.groupExecutionWithPoolThread.isLocalSuspended()) { 166 try { 167 super.log 168 .log(BasicLevel.INFO, 169 "WAIT EVERY BODY SUSPENDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD"); 170 this.componentLock.wait(); 171 } catch (InterruptedException ex) { 172 throw new IsacRuntimeException( 173 "Unable to wait the suspended mode of the group execution thread -> " 174 + ex.toString()); 175 } 176 } 177 } 178 } 179 } | Popular Tags |