1 29 30 package hero.client.test.perf; 31 32 import javax.security.auth.login.LoginContext ; 33 import hero.client.test.SimpleCallbackHandler; 34 35 import hero.interfaces.BnProject; 36 import hero.interfaces.BnProjectHome; 37 import hero.interfaces.BnProjectPK; 38 import hero.interfaces.BnProjectValue; 39 import hero.interfaces.ProjectSession; 40 import hero.interfaces.ProjectSessionHome; 41 import hero.interfaces.ProjectSessionUtil; 42 import hero.interfaces.UserSession; 43 import hero.interfaces.UserSessionHome; 44 import hero.interfaces.UserSessionUtil; 45 import hero.interfaces.UserRegistration; 46 import hero.interfaces.UserRegistrationHome; 47 import hero.interfaces.UserRegistrationUtil; 48 import junit.framework.TestCase; 49 import junit.framework.TestSuite; 50 import hero.interfaces.Constants; 51 import hero.util.BonitaServiceException; 52 53 import java.util.Collection ; 54 import java.util.Iterator ; 55 56 public class ThreadInstancesPerfTest extends Thread { 57 58 private int userNb = 0; 59 private String uNb = "0" ; 60 private int instNb = 10 ; 61 private int tpsRunDbtInst = 3; 62 63 SimpleCallbackHandler handler = null; 64 LoginContext lc=null; 65 ProjectSessionHome pHome; 66 static int instRunEnCours = 0; 67 static int instTotales = 0; 68 static int userCrees = 0; 69 String uName=null; 70 71 public ThreadInstancesPerfTest(int user, int inst, int tpsdbtinst) 72 { 73 this.userNb = user ; 74 this.uNb = String.valueOf(user) ; 75 this.instNb = inst; 76 this.tpsRunDbtInst=tpsdbtinst; 77 78 uName = "user"+uNb; 79 char[] password=uName.toCharArray(); 80 try 81 { 82 handler = new SimpleCallbackHandler(uName,password); 83 lc = new LoginContext ("TestClient", handler); 84 lc.login(); 85 pHome = ProjectSessionUtil.getHome(); 86 } 87 catch (Exception e) 88 { 89 System.out.println("pffffffff....meme pas en reve "+e); 90 } 91 } 92 93 94 95 public void run() 96 { 97 98 String result=""; 100 long startTime = 0; 101 int instRunDebut = instRunEnCours; 102 int userCreesDbt = userCrees; 103 104 try 105 { 106 107 108 int i=0; 109 110 Thread.sleep(tpsRunDbtInst * 1000); 111 startTime = System.currentTimeMillis(); 112 ProjectSession ps = pHome.create(); 113 instRunEnCours +=1; 114 instTotales +=1; 115 ps.instantiateProject("Stress"); 118 120 122 ps.remove(); 123 149 } catch(Exception e){System.out.println(" --> " + e);} 150 151 long time = System.currentTimeMillis(); 152 long tmp = time - startTime; long h = tmp/3600000; 154 long m = (tmp-3600000*h)/60000; 155 long s = (tmp-3600000*h-60000*m)/1000; 156 long millis = tmp-3600000*h-60000*m-1000*s; 157 System.out.println( " --> "+ uName + " / ( "+userCreesDbt+" -> "+ userCrees +" ) " +" Stressed Model ( "+ instRunDebut+" -> "+instRunEnCours +" / " + instTotales +" ) : system time elapsed : " + h + ":"+ m + ":" + s + ":" + millis ); 158 instRunEnCours -=1; 159 160 } 161 162 public static void executeSubProcess(String subProcess) throws Exception 163 { 164 UserSessionHome uHome = UserSessionUtil.getHome(); 165 UserSession us = uHome.create(); 166 us.startActivity(subProcess,"subNode1"); 167 us.terminateActivity(subProcess,"subNode1"); 168 us.startActivity(subProcess,"subNode2"); 169 us.terminateActivity(subProcess,"subNode2"); 170 } 171 } 172 173 174 | Popular Tags |