001: /**
002: *
003: * Bonita
004: * Copyright (C) 1999 Bull S.A.
005: * Bull 68 route de versailles 78434 Louveciennes Cedex France
006: * Further information: bonita@objectweb.org
007: *
008: * This library is free software; you can redistribute it and/or
009: * modify it under the terms of the GNU Lesser General Public
010: * License as published by the Free Software Foundation; either
011: * version 2.1 of the License, or any later version.
012: *
013: * This library is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * Lesser General Public License for more details.
017: *
018: * You should have received a copy of the GNU Lesser General Public
019: * License along with this library; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
021: * USA
022: *
023: *
024: --------------------------------------------------------------------------
025: * $Id: ThreadLanceurPerfTest.java,v 1.1 2005/03/18 14:51:23 mvaldes Exp $
026: *
027: --------------------------------------------------------------------------
028: */package hero.client.test.perf;
029:
030: import javax.security.auth.login.LoginContext;
031: import hero.client.test.SimpleCallbackHandler;
032:
033: import hero.interfaces.ProjectSession;
034: import hero.interfaces.ProjectSessionHome;
035: import hero.interfaces.ProjectSessionUtil;
036: import hero.interfaces.UserSession;
037: import hero.interfaces.UserSessionHome;
038: import hero.interfaces.UserSessionUtil;
039: import hero.interfaces.UserRegistration;
040: import hero.interfaces.UserRegistrationHome;
041: import hero.interfaces.UserRegistrationUtil;
042: import junit.framework.TestCase;
043: import junit.framework.TestSuite;
044: import hero.interfaces.Constants;
045:
046: import java.sql.Time;
047: import java.util.Collection;
048: import java.util.Iterator;
049:
050: public class ThreadLanceurPerfTest {
051: public static int injectes = 0;
052: public static int userCreesEnCours = 0;
053:
054: public static void main(String[] args) throws Exception {
055:
056: int argNb = 8;
057: int userNb = 0;
058: String uNb = "0";
059: int instNb = 1;
060: int nbUsersParPallier = userNb;
061: int tpsPallier = 10; // secondes
062: int tpsEntreUsers = 1;
063: int tpsEntreInjInst = 1;
064: int tpsEntreInst = 1;
065: int tpsRunDbtInst = 3;
066:
067: if (args.length != argNb) {
068: System.out.println("Number of arguments needed : " + argNb);
069:
070: System.out
071: .println("Args : -DuserId -DnbInst -Dnbuserspallier= -Dtpspallier= -DtpsEntreUsers= -DtpsEntreInjInst= -DtpsEtreInst -DtpsRunDbtInst");
072: } else {
073:
074: try {
075: uNb = new String(args[0]);
076: userNb = Integer.valueOf(uNb).intValue();
077: } catch (Exception e) {
078: System.out.println(" --> " + e);
079: }
080:
081: try {
082: String instanceNum = new String(args[1]);
083: instNb = Integer.valueOf(instanceNum).intValue();
084: } catch (Exception e) {
085: System.out.println(" --> " + e);
086: }
087:
088: try {
089: String usersParPallier = new String(args[2]);
090: nbUsersParPallier = Integer.valueOf(usersParPallier)
091: .intValue();
092: } catch (Exception e) {
093: System.out.println(" --> " + e);
094: }
095:
096: try {
097: String tpsSecParPallier = new String(args[3]);
098: tpsPallier = Integer.valueOf(tpsSecParPallier)
099: .intValue();
100: } catch (Exception e) {
101: System.out.println(" --> " + e);
102: }
103:
104: try {
105: String tps_entre_users = new String(args[4]);
106: tpsEntreUsers = Integer.valueOf(tps_entre_users)
107: .intValue();
108: } catch (Exception e) {
109: System.out.println(" --> " + e);
110: }
111:
112: try {
113: String tps_entre_inj_inst = new String(args[5]);
114: tpsEntreInjInst = Integer.valueOf(tps_entre_inj_inst)
115: .intValue();
116: } catch (Exception e) {
117: System.out.println(" --> " + e);
118: }
119:
120: try {
121: String tps_entre_inst = new String(args[6]);
122: tpsEntreInst = Integer.valueOf(tps_entre_inst)
123: .intValue();
124: } catch (Exception e) {
125: System.out.println(" --> " + e);
126: }
127:
128: try {
129: String tps_run_dbt_inst = new String(args[7]);
130: tpsRunDbtInst = Integer.valueOf(tps_run_dbt_inst)
131: .intValue();
132: } catch (Exception e) {
133: System.out.println(" --> " + e);
134: }
135: }
136:
137: ////////// TEST ////////////////////////////////////////////////
138:
139: UserRegistrationHome urHome = UserRegistrationUtil.getHome();
140: UserRegistration userReg = urHome.create();
141:
142: int userRestant = userNb;
143: int userInj = 0;
144: int maxInj = 0;
145:
146: while (userRestant > 0) {
147: try {
148: maxInj = Math.min(nbUsersParPallier, userRestant);
149:
150: for (userInj = injectes; userInj < injectes + maxInj; userInj++) {
151: userCreesEnCours += 1;
152: // user creation
153: try {
154: userReg.userCreate("user" + userInj, "user"
155: + userInj, "Anne.Geron@bull.net");
156: ThreadInstancesPerfTest.userCrees = userCreesEnCours;
157: Thread.sleep(tpsEntreUsers * 1000);
158: // System.out.println("---> Creation user "+ userInj) ;
159: } catch (Exception e) {
160: System.out.println(" --> " + e);
161: }
162: }
163:
164: Thread.sleep(tpsEntreInjInst * 1000);
165:
166: for (int userInst = injectes; userInst < injectes
167: + maxInj; userInst++) {
168: //System.out.println("Main : User : " + userInst + " - Instance : "+instNb);
169: try {
170: for (int i = 0; i < instNb; i++) {
171: // Creation du thread
172:
173: ThreadInstancesPerfTest this Inst = new ThreadInstancesPerfTest(
174: userInst, i, tpsRunDbtInst);
175: // Lancement du thread
176: this Inst.start();
177: Thread.sleep(tpsEntreInst * 1000);
178: }
179: } catch (Exception e) {
180: System.out.println(" --> " + e);
181: }
182: }
183:
184: } catch (Exception se) {
185: System.out.println(" // " + se);
186: } finally {
187: System.out.println(" ///////// ATTENTE ( " + tpsPallier
188: + " sec) ");
189: Thread.sleep(tpsPallier * 1000);
190: System.out.println(" ///////// NOUVELLE INJECTION ");
191: injectes += maxInj;
192: userRestant = userNb - injectes;
193: }
194:
195: } // fin boucle while
196:
197: }
198:
199: private void mode1() {
200:
201: }
202:
203: private void mode2() {
204:
205: }
206:
207: private void regUser() {
208:
209: }
210:
211: private void creaInst() {
212:
213: }
214: }
|