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.ProjectSession; 36 import hero.interfaces.ProjectSessionHome; 37 import hero.interfaces.ProjectSessionUtil; 38 import hero.interfaces.UserSession; 39 import hero.interfaces.UserSessionHome; 40 import hero.interfaces.UserSessionUtil; 41 import hero.interfaces.UserRegistration; 42 import hero.interfaces.UserRegistrationHome; 43 import hero.interfaces.UserRegistrationUtil; 44 import junit.framework.TestCase; 45 import junit.framework.TestSuite; 46 import hero.interfaces.Constants; 47 48 import java.sql.Time ; 49 import java.util.Collection ; 50 import java.util.Iterator ; 51 52 public class ThreadLanceurPerfTest 53 { 54 public static int injectes = 0 ; 55 public static int userCreesEnCours = 0; 56 57 public static void main(String [] args) throws Exception 58 { 59 60 int argNb = 8; 61 int userNb = 0; 62 String uNb = "0"; 63 int instNb = 1; 64 int nbUsersParPallier = userNb; 65 int tpsPallier = 10; int tpsEntreUsers = 1 ; 67 int tpsEntreInjInst = 1 ; 68 int tpsEntreInst = 1 ; 69 int tpsRunDbtInst = 3 ; 70 71 if (args.length != argNb) 72 { 73 System.out.println("Number of arguments needed : "+argNb); 74 75 System.out.println("Args : -DuserId -DnbInst -Dnbuserspallier= -Dtpspallier= -DtpsEntreUsers= -DtpsEntreInjInst= -DtpsEtreInst -DtpsRunDbtInst"); 76 } 77 else 78 { 79 80 try 81 { 82 uNb = new String (args[0]); 83 userNb = Integer.valueOf(uNb).intValue() ; 84 } 85 catch(Exception e){System.out.println(" --> " + e);} 86 87 try 88 { 89 String instanceNum = new String (args[1]); 90 instNb = Integer.valueOf(instanceNum).intValue() ; 91 } 92 catch(Exception e){System.out.println(" --> " + e);} 93 94 try 95 { 96 String usersParPallier = new String (args[2]); 97 nbUsersParPallier = Integer.valueOf(usersParPallier).intValue() ; 98 } 99 catch(Exception e){System.out.println(" --> " + e);} 100 101 try 102 { 103 String tpsSecParPallier = new String (args[3]); 104 tpsPallier = Integer.valueOf(tpsSecParPallier).intValue() ; 105 } 106 catch(Exception e){System.out.println(" --> " + e);} 107 108 try 109 { 110 String tps_entre_users = new String (args[4]); 111 tpsEntreUsers = Integer.valueOf(tps_entre_users).intValue() ; 112 } 113 catch(Exception e){System.out.println(" --> " + e);} 114 115 try 116 { 117 String tps_entre_inj_inst = new String (args[5]); 118 tpsEntreInjInst = Integer.valueOf(tps_entre_inj_inst).intValue() ; 119 } 120 catch(Exception e){System.out.println(" --> " + e);} 121 122 try 123 { 124 String tps_entre_inst = new String (args[6]); 125 tpsEntreInst = Integer.valueOf(tps_entre_inst).intValue() ; 126 } 127 catch(Exception e){System.out.println(" --> " + e);} 128 129 try 130 { 131 String tps_run_dbt_inst = new String (args[7]); 132 tpsRunDbtInst = Integer.valueOf(tps_run_dbt_inst).intValue() ; 133 } 134 catch(Exception e){System.out.println(" --> " + e);} 135 } 136 137 139 UserRegistrationHome urHome = UserRegistrationUtil.getHome(); 140 UserRegistration userReg=urHome.create(); 141 142 143 int userRestant = userNb; 144 int userInj = 0; 145 int maxInj = 0; 146 147 while(userRestant > 0) 148 { 149 try 150 { 151 maxInj = Math.min( nbUsersParPallier , userRestant ) ; 152 153 for (userInj=injectes ; userInj < injectes+maxInj ; userInj++) 154 { 155 userCreesEnCours +=1; 156 try 158 { 159 userReg.userCreate("user"+userInj,"user"+userInj,"Anne.Geron@bull.net"); 160 ThreadInstancesPerfTest.userCrees = userCreesEnCours ; 161 Thread.sleep(tpsEntreUsers * 1000); 162 } 164 catch (Exception e) 165 { 166 System.out.println(" --> " + e); 167 } 168 } 169 170 Thread.sleep(tpsEntreInjInst * 1000); 171 172 for (int userInst=injectes ; userInst < injectes+maxInj ; userInst++) 173 { 174 try 176 { 177 for(int i=0;i<instNb;i++) 178 { 179 181 ThreadInstancesPerfTest thisInst = new ThreadInstancesPerfTest(userInst,i,tpsRunDbtInst); 182 thisInst.start(); 184 Thread.sleep(tpsEntreInst * 1000); 185 } 186 } 187 catch (Exception e) 188 { 189 System.out.println(" --> " + e); 190 } 191 } 192 193 } 194 catch (Exception se) 195 { 196 System.out.println(" // " + se); 197 } 198 finally 199 { 200 System.out.println(" ///////// ATTENTE ( " + tpsPallier +" sec) " ); 201 Thread.sleep(tpsPallier * 1000); 202 System.out.println(" ///////// NOUVELLE INJECTION "); 203 injectes += maxInj ; 204 userRestant = userNb - injectes; 205 } 206 207 } 209 } 210 211 private void mode1() 212 { 213 214 } 215 216 private void mode2() 217 { 218 219 } 220 221 private void regUser() 222 { 223 224 } 225 226 private void creaInst() 227 { 228 229 } 230 } 231 232 233 | Popular Tags |