/*
* Speedo: an implementation of JDO compliant personality on top of JORM
* generic I/O sub-system. Copyright (C) 2001-2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Release: 1.0
*
* Created on 2004-03-04 @author fmillevi@yahoo.com
*
*/
package org.objectweb.speedo.j2eedo;
import java.io.BufferedReader;
import java.io.PrintWriter;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import javax.jdo.JDOException;
import javax.jdo.JDOFatalException;
import javax.jdo.PersistenceManager;
import org.objectweb.speedo.SpeedoTestHelper;
import org.objectweb.speedo.j2eedo.bo.DatabaseImpl;
import org.objectweb.speedo.j2eedo.common.PMHolder;
import org.objectweb.speedo.j2eedo.common.TraceTime;
import org.objectweb.util.monolog.Monolog;
import org.objectweb.util.monolog.api.BasicLevel;
/**
* This class implements Junit test case. All the defined tests are launched in
* a standalone mode (it means test performing without an J2EE deployement)
*
* @author fmillevi@yahoo.com
*/
public class TestJ2eedoApplication extends SpeedoTestHelper {
/**
* define the application prefix parameters <code>JEEDO_LOG_NAME</code>
*/
public final static String JEEDO_LOG_NAME =
org.objectweb.speedo.SpeedoTestHelper.LOG_NAME + ".j2eedo";
protected final String SIMPLETEST = getLoggerName() + ".simpleTest";
protected final String THREAD = getLoggerName() + ".thread";
protected final String LOOP = getLoggerName() + ".loop";
protected final String TIMEOUT = getLoggerName() + ".timeout";
protected final String NBOFREAD = getLoggerName() + ".read";
protected final String NBOFWRITE = getLoggerName() + ".write";
protected boolean simpleTestOnly = false;
protected int nbThread = -1;
protected int nbTx = -1;
protected long timeout = -1;
protected int nbOfRead = -1;
protected int nbOfWrite = -1;
protected List methodsList = null;
private static boolean dataReset = false;
/**
* Sets up the test fixture. (Called before every test case method.) This
* method
* <ul>
* <li>registers each action,</li>
* <li>Set the default action list method</li>
* <li>Initializes the database content.</li>
* </ul>
*
* @see org.objectweb.speedo.j2eedo.bo.DatabaseImpl
*/
protected void setUp() {
GenerateListOfActionToBeDone generateMethod =
new GenerateListOfActionToBeDone();
try {
for (int i = 0; i < DatabaseImpl.actionArray.length; i++) {
// register method doing something
generateMethod.registerMethod(
DatabaseImpl.actionArray[i],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.READ],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.WRITE]);
}
// set the action list
this.methodsList =
generateMethod.mergeWriteReadMethodList(
Integer.getInteger(NBOFWRITE, 1).intValue(),
Integer.getInteger(NBOFREAD, 3).intValue());
} catch (Exception e) {
e.printStackTrace();
}
PMHolder pmHolder = new PMHolder(getPMF());
try {
synchronized (JEEDO_LOG_NAME) {
if (!TestJ2eedoApplication.dataReset) {
TestJ2eedoApplication.dataReset = true;
logger.log(
BasicLevel.INFO,
"Resetting initial data for the new test...");
DatabaseImpl.initTestData(pmHolder);
logger.log(
BasicLevel.INFO,
"Initial test data have been created.");
}
}
} catch (JDOException e) {
e.printStackTrace(System.out);
fail("Setup of initial test data throws an JDO Exception" + e);
} catch (Exception e) {
e.printStackTrace(System.out);
fail("Setup of initial test data throws an Exception" + e);
}
}
/**
* Tears down the test fixture. (Called after every test case method.)
*/
protected void tearDown() {
//Nothing to do yet
}
/**
* This constructor gets the parameters and resets the default list of
* methods to be called
*
* @see org.objectweb.speedo.j2eedo.bo.DatabaseImpl
* @param s
* is the class name
*/
public TestJ2eedoApplication(String s) {
super(s);
this.simpleTestOnly = Boolean.getBoolean(SIMPLETEST);
this.nbThread = Integer.getInteger(THREAD, 1).intValue();
this.nbTx = Integer.getInteger(LOOP, 1).intValue();
this.timeout = Long.getLong(TIMEOUT, 3600000).longValue();
this.nbOfRead = Integer.getInteger(NBOFREAD, 3).intValue();
this.nbOfWrite = Integer.getInteger(NBOFWRITE, 1).intValue();
System.out.println(SIMPLETEST + "=" + simpleTestOnly);
System.out.println(THREAD + "=" + nbThread);
System.out.println(LOOP + "=" + nbTx);
System.out.println(TIMEOUT + "=" + timeout);
System.out.println(NBOFREAD + "=" + nbOfRead);
System.out.println(NBOFWRITE + "=" + nbOfWrite);
loggerFactory = Monolog.monologFactory;
logger = loggerFactory.getLogger(getLoggerName());
this.methodsList = null;
}
/**
* This sub class provides the list of the methods having to be called
* while taking regarding the rate between the reading and writing defined
* by the two parameters <br>- rankOfRead : number of read methods to be
* called <br>- rankOfWrite : number of write methods to be called <br>
*
* @author fmillevi@yahoo.com
*/
public class GenerateListOfActionToBeDone {
/**
* The constant <code>MAX_WEIGHT</code> defines relative maximum
* weight used by the methods registerMethodXXX . Its values is 5
*/
public final static int MAX_WEIGHT = 5;
/**
* The constant <code>MIN_WEIGHT</code> defines relative minimum
* weight used by the methods registerMethodXXX . Its values is -1
*/
public final static int MIN_WEIGHT = 1;
private int totalWriteWeight = 0;
private int totalReadWeight = 0;
private List readAndWriteActionList = null;
private List writeOnlyActionList = null;
private List readOnlyActionList = null;
HashMap readAndWriteAction4ReadMap = null;
HashMap readAndWriteAction4WriteMap = null;
HashMap readOnlyActionMap = null;
HashMap writeOnlyActionMap = null;
/**
* This method populates the list of action according the weight of
* each method : The less a method is weighted, the more frequent this
* method is in the list
*
* @param map
* is the current map storing the method names with the
* read/write weight
* @param list
* is the current list of method populated according the
* weight of each method
*/
private int computeList(HashMap map, List list) {
if (null == map || 0 == map.size())
return 0;
Iterator listOfMethod = map.keySet().iterator();
int totalWeight = 0;
int nbEntries = 0;
while (listOfMethod.hasNext()) {
String method = (String) listOfMethod.next();
int weight = ((Integer) map.get(method)).intValue();
int nbOfEntry = Math.round(MAX_WEIGHT * MAX_WEIGHT / weight);
for (int i = 0; i < nbOfEntry; i++) {
list.add(method);
nbEntries++;
totalWeight += weight;
}
}
logger.log(BasicLevel.DEBUG, nbEntries + " entries added");
return totalWeight;
}
/**
* generate the list of write taking care of the write weight
*
* @throws Exception
* when no method are register in the map
*/
private void computeReadMethodList() throws Exception {
try {
this.readOnlyActionList = new ArrayList();
this.totalReadWeight =
computeList(
this.readOnlyActionMap,
this.readOnlyActionList);
} catch (Exception e) {
throw new Exception("Can not compute Write Method List", e);
}
}
/**
* generate the list of write taking care of the write weight
*
* @throws Exception
* when no method are register in the map
*/
private void computeReadWriteMethodList() throws Exception {
try {
this.readAndWriteActionList = new ArrayList();
int nbRead =
computeList(
this.readAndWriteAction4ReadMap,
this.readAndWriteActionList);
int nbWrite =
computeList(
this.readAndWriteAction4WriteMap,
this.readAndWriteActionList);
this.totalWriteWeight = nbWrite;
this.totalReadWeight = nbRead;
} catch (Exception e) {
throw new Exception("Can not compute Write Method List", e);
}
}
/**
* generate the list of write taking care of the write weight
*
* @throws Exception
* when no method are register in the map
*/
private void computeWriteMethodList() throws Exception {
try {
this.writeOnlyActionList = new ArrayList();
this.totalWriteWeight =
computeList(
this.writeOnlyActionMap,
this.writeOnlyActionList);
} catch (Exception e) {
throw new Exception("Can not compute Write Method List", e);
}
}
/**
* This method populates the list Read/Write Methods according the Read
* methoded registered
*
* @param nbOfWrite
* @param nbOfRead
* @return the list of methods to be called
* @throws Exception
* when no method are register in the map and when
* parameters are null or <0
*/
public List mergeWriteReadMethodList(int nbOfWrite, int nbOfRead)
throws Exception {
if (0 >= (nbOfWrite + nbOfRead) || 0 > (nbOfWrite * nbOfRead))
throw new Exception(
"Parameters nbOfRead ("
+ nbOfRead
+ ") and nbOfWrite ("
+ nbOfWrite
+ ") are not correct.");
logger.log(
BasicLevel.DEBUG,
"Generate the actions list according registered actions read/write weight");
List list1 = new ArrayList();
this.computeReadWriteMethodList();
list1.addAll(this.readAndWriteActionList);
this.computeReadMethodList();
this.computeWriteMethodList();
list1.addAll(this.writeOnlyActionList);
if (logger.isLoggable(BasicLevel.DEBUG)) {
Iterator iter = null;
int nbActions = 0;
iter = this.readOnlyActionList.iterator();
for (nbActions = 0; iter.hasNext(); nbActions++)
iter.next();
logger.log(
BasicLevel.DEBUG,
nbActions
+ " read only actions (total weight:"
+ this.totalReadWeight
+ ")");
iter = this.writeOnlyActionList.iterator();
for (nbActions = 0; iter.hasNext(); nbActions++)
iter.next();
logger.log(
BasicLevel.DEBUG,
nbActions
+ " write only actions (total weight:"
+ this.totalWriteWeight
+ ")");
iter = this.readAndWriteActionList.iterator();
for (nbActions = 0; iter.hasNext(); nbActions++)
iter.next();
logger.log(
BasicLevel.DEBUG,
nbActions + " read & write only actions");
}
Iterator iter = list1.iterator();
int weightRead = 0;
int weightWrite = 0;
String method;
while (iter.hasNext()) {
method = (String) iter.next();
if (this.readOnlyActionMap.containsKey(method))
weightRead
+= ((Integer) this.readOnlyActionMap.get(method))
.intValue();
else if (this.writeOnlyActionMap.containsKey(method))
weightWrite
+= ((Integer) this.writeOnlyActionMap.get(method))
.intValue();
else {
weightRead
+= ((Integer) this.readAndWriteAction4ReadMap.get(method))
.intValue();
weightWrite
+= ((Integer) this
.readAndWriteAction4WriteMap
.get(method))
.intValue();
}
}
List list = new ArrayList();
if (0 == nbOfWrite) {
list.addAll(this.readOnlyActionList);
} else if (0 == nbOfRead) {
list.addAll(this.writeOnlyActionList);
} else {
int nbRead2BeAdd =
nbOfRead * weightWrite / nbOfWrite - weightRead;
if (0 >= nbRead2BeAdd)
nbRead2BeAdd = 1;
logger.log(
BasicLevel.DEBUG,
"Before merge Read only methods : \nnbRead "
+ weightRead
+ "\nnbWrite "
+ weightWrite
+ "\nnbRead2BeAdd "
+ nbRead2BeAdd
+ "\nAddList:"
+ (float) nbRead2BeAdd / (float) this.totalReadWeight
+ "\t#:"
+ Math.round(
(float) nbRead2BeAdd / (float) totalReadWeight)
+ " *("
+ this.totalReadWeight
+ ")");
if (nbRead2BeAdd < this.totalReadWeight) {
for (int j = 0;
j
< Math.round(
(float) totalReadWeight / (float) nbRead2BeAdd);
j++)
list.addAll(list1);
list.addAll(this.readOnlyActionList);
} else {
list.addAll(list1);
for (int j = 0;
j
< Math.round(
(float) nbRead2BeAdd / (float) totalReadWeight);
j++)
list.addAll(this.readOnlyActionList);
}
}
if (logger.isLoggable(BasicLevel.DEBUG)) {
weightRead = 0;
weightWrite = 0;
int nbCalls = 0;
iter = list.iterator();
while (iter.hasNext()) {
method = (String) iter.next();
nbCalls++;
if (this.readOnlyActionMap.containsKey(method))
weightRead
+= ((Integer) this.readOnlyActionMap.get(method))
.intValue();
else if (this.writeOnlyActionMap.containsKey(method))
weightWrite
+= ((Integer) this.writeOnlyActionMap.get(method))
.intValue();
else {
weightRead
+= ((Integer) this
.readAndWriteAction4ReadMap
.get(method))
.intValue();
weightWrite
+= ((Integer) this
.readAndWriteAction4WriteMap
.get(method))
.intValue();
}
}
logger.log(
BasicLevel.DEBUG,
"The action list is set : \nnbRead "
+ weightRead
+ "\nnbWrite "
+ weightWrite
+ "\n\tGoal rate : "
+ nbOfRead
+ "/"
+ nbOfWrite
+ "="
+ ((nbOfWrite != 0)
? Float.toString(
(float) nbOfRead / (float) nbOfWrite)
: "NaN")
+ "\n\tRate:"
+ ((weightWrite != 0)
? Float.toString(
(float) weightRead / (float) weightWrite)
: "NaN")
+ " in "
+ nbCalls
+ " calls");
}
return list;
}
/**
* Register a method having write an read job
*
* @param name
* is the action's name
* @param readWeight
* is the relative read weight defined between MIN_WEIGHT
* and MAX_WEIGHT or setted to 0 (zero)
* @param writeWeight
* is the relative write weight defined between MIN_WEIGHT
* and MAX_WEIGHT or setted to 0 (zero)
* @throws Exception
* when the weights are not defined between the max and the
* min value or setted to 0 (zero). Both weight parameters
* can not be setted to 0
* @see #MAX_WEIGHT
* @see #MIN_WEIGHT
*/
public void registerMethod(
String name,
int readWeight,
int writeWeight)
throws Exception {
if (name.equals(DatabaseImpl.PARAMETER_PING))
return;
if (0 == readWeight)
this.registerMethodWrite(name, writeWeight);
else if (0 == writeWeight)
this.registerMethodRead(name, readWeight);
else
registerMethodReadWrite(name, readWeight, writeWeight);
}
/**
* Register a method having write an read job
*
* @param name
* is the action's name
* @param readWeight
* is the relatif weight for read
* @param writeWeight
* is the relatif weight for write
* @throws Exception
* when the weights are not in the max and the min value
*/
private void registerMethodReadWrite(
String name,
int readWeight,
int writeWeight)
throws Exception {
if (null == this.readAndWriteAction4ReadMap)
this.readAndWriteAction4ReadMap = new HashMap();
if (null == this.readAndWriteAction4WriteMap)
this.readAndWriteAction4WriteMap = new HashMap();
if (readWeight > GenerateListOfActionToBeDone.MAX_WEIGHT
|| readWeight < GenerateListOfActionToBeDone.MIN_WEIGHT
|| writeWeight > GenerateListOfActionToBeDone.MAX_WEIGHT
|| writeWeight < GenerateListOfActionToBeDone.MIN_WEIGHT)
throw new Exception(
"Can not register this method : the weight must be defined between "
+ GenerateListOfActionToBeDone.MIN_WEIGHT
+ " and "
+ GenerateListOfActionToBeDone.MAX_WEIGHT);
this.readAndWriteAction4ReadMap.put(name, new Integer(readWeight));
this.readAndWriteAction4WriteMap.put(
name,
new Integer(writeWeight));
}
/**
* Register a method having read job
*
* @param name is the Method's name
* @param weight is relatif weight for read
* @throws Exception
* when the weights are not in the max and the min value
*/
private void registerMethodRead(String name, int weight)
throws Exception {
if (null == this.readOnlyActionMap)
this.readOnlyActionMap = new HashMap();
if (weight > GenerateListOfActionToBeDone.MAX_WEIGHT
|| weight < GenerateListOfActionToBeDone.MIN_WEIGHT)
throw new Exception(
"Can not register this method : the weight must be defined between "
+ GenerateListOfActionToBeDone.MIN_WEIGHT
+ " and "
+ GenerateListOfActionToBeDone.MAX_WEIGHT);
this.readOnlyActionMap.put(name, new Integer(weight));
}
/**
* Register a method having write job
*
* @param name is the Method's name
* @param weight is relatif weight for write
* @throws Exception
* when the weights are not in the max and the min value
*/
private void registerMethodWrite(String name, int weight)
throws Exception {
if (null == this.writeOnlyActionMap)
this.writeOnlyActionMap = new HashMap();
this.totalWriteWeight += weight;
if (weight > GenerateListOfActionToBeDone.MAX_WEIGHT
|| weight < GenerateListOfActionToBeDone.MIN_WEIGHT)
throw new Exception(
"Can not register this method : the weight must be defined between "
+ GenerateListOfActionToBeDone.MIN_WEIGHT
+ " and "
+ GenerateListOfActionToBeDone.MAX_WEIGHT);
this.writeOnlyActionMap.put(name, new Integer(weight));
}
/**
* Empty Constructor - reset all values
*/
public GenerateListOfActionToBeDone() {
this.readOnlyActionList = null;
this.writeOnlyActionList = null;
this.readAndWriteAction4ReadMap = null;
this.readAndWriteAction4WriteMap = null;
this.readOnlyActionMap = null;
this.writeOnlyActionMap = null;
this.totalWriteWeight = 0;
this.totalReadWeight = 0;
}
}
/**
* Returns the current log name
*
* @see org.objectweb.speedo.SpeedoTestHelper#getLoggerName()
*/
protected String getLoggerName() {
return JEEDO_LOG_NAME;
}
private final static Hashtable needTransactionArray = new Hashtable();
protected String performMethod(String action)
throws Exception, JDOException, JDOFatalException {
PMHolder pmHolder = new PMHolder(getPMF());
String returnStr = null;
boolean needTrans;
PersistenceManager pm = null;
if (!needTransactionArray.containsKey(action)) {
int k = 0;
for (;
!DatabaseImpl.actionArray[k].equals(action)
&& k < DatabaseImpl.actionWeightArray.length;
k++);
if (0 == DatabaseImpl.actionWeightArray[k][DatabaseImpl.WRITE])
needTransactionArray.put(action, new Boolean(false));
else
needTransactionArray.put(action, new Boolean(true));
}
needTrans = ((Boolean) needTransactionArray.get(action)).booleanValue();
needTrans = true;
if (needTrans) {
pm = pmHolder.getPersistenceManager();
pm.currentTransaction().begin();
}
try {
returnStr = DatabaseImpl.instance.doAction(action, false, pmHolder);
} catch (JDOFatalException e) {
if (pm != null && !pm.isClosed() && pm.currentTransaction().isActive()) {
pm.currentTransaction().rollback();
}
throw e;
} finally {
if (pm != null && !pm.isClosed() && pm.currentTransaction().isActive()) {
pm.currentTransaction().commit();
}
if (needTrans) {
pmHolder.closePersistenceManager();
}
}
return returnStr;
}
protected void perform() {
final int _nbTx = this.nbTx;
final List _methodsList = this.methodsList;
this.displayTestParameters();
//------------ Create thread for each tasks ------------//
Thread[] ts = new Thread[nbThread];
for (int thread = 0; thread < nbThread; thread++) {
ts[thread] = new Thread(new Runnable() {
public void run() {
TraceTime traceTime = new TraceTime();
String action = null;
Iterator iter = null;
for (int j = 0, i = 0; i < _nbTx; i++) {
traceTime.startTask(Thread.currentThread().getName() + ".loop." + i);
logger.log(BasicLevel.INFO, "Start loop " + i);
Collections.shuffle(_methodsList);
iter = _methodsList.iterator();
boolean deadLock = false;
String returnStr;
while (iter.hasNext()) {
if (0 == (j++ % 100.0)) {
logger.log(BasicLevel.INFO, j + " actions called...");
}
action = (String) iter.next();
// check if the action need to start a transaction
logger.log(BasicLevel.DEBUG, "Calls method:" + action);
deadLock = true;
while (deadLock) {
deadLock = false;
try {
returnStr = performMethod(action);
logger.log(BasicLevel.DEBUG,
"The method " + action + " returns:\n"
+ returnStr);
} catch (JDOFatalException e) {
logger.log( BasicLevel.INFO, "The method "
+ action
+ " throws a JDO Fatal Exception");
deadLock = true;
} catch (Exception e) {
logger.log(BasicLevel.ERROR,
"The method " + action
+ " throws an exception ", e);
fail("The method " + action
+ " throws JDO an exception "
+ e.getMessage());
}
}
}
}
traceTime.endTask();
logger.log(BasicLevel.INFO, "End of thread loops : " + traceTime.report());
}
});
}
//-------------- Launch all threads ------------//
for (int thread = 0; thread < nbThread; thread++) {
ts[thread].start();
}
try {
//------------ wait threads ------------//
for (int thread = 0; thread < nbThread; thread++) {
ts[thread].join(timeout);
if (ts[thread].isAlive()) {
logger.log(
BasicLevel.WARN,
"Thread "
+ ts[thread].getName()
+ " is not finished after the delay, it could be blocked");
ts[thread].interrupt();
fail("Thread " + ts[thread] + " is blocked!");
}
}
} catch (InterruptedException e) {
fail(e.getMessage());
}
// display the current status of data
try {
String str = DatabaseImpl.instance.doAction(
"", false, new PMHolder(getPMF()));
logger.log(BasicLevel.DEBUG, str);
} catch (Exception e) {
logger.log(BasicLevel.ERROR, "Error occurs : ", e);
}
}
/**
* this method logs the current test method called and the differents
* parameters values.
*/
protected void displayTestParameters() {
if (!logger.isLoggable(BasicLevel.INFO))
return;
// display the calling method
Throwable t = new Throwable();
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
t.printStackTrace(pw);
String input = sw.getBuffer().toString();
StringReader sr = new StringReader(input);
BufferedReader br = new BufferedReader(sr);
try {
String line;
br.readLine(); // Exception name
while (true) {
line = br.readLine();
int paren = line.indexOf('(');
line = line.substring(0, paren);
int period = line.lastIndexOf('.');
line = line.substring(period + 1);
if (line.indexOf("test") != 0)
continue;
break;
}
logger.log(BasicLevel.INFO, "The test is : " + line);
} catch (Exception e) {
}
logger.log(
BasicLevel.INFO,
"The test is launch with the parameters : \nNumber of threads: "
+ this.nbThread
+ "\nNumber of actions list loop: "
+ this.nbTx
+ "\ntime out (ms): "
+ this.timeout
+ "\nnb of read proportion: "
+ this.nbOfRead
+ "\nnb of write proportion: "
+ this.nbOfWrite);
int nbCalls = 0;
String method;
HashMap actionsWeight = new HashMap();
Iterator iter = this.methodsList.iterator();
int count = -1;
while (iter.hasNext()) {
method = (String) iter.next();
nbCalls++;
if (actionsWeight.containsKey(method)) {
count = ((Integer) actionsWeight.get(method)).intValue() + 1;
actionsWeight.remove(method);
actionsWeight.put(method, new Integer(count));
} else {
actionsWeight.put(method, new Integer(1));
}
}
logger.log(
BasicLevel.INFO,
"Action list {action1=count, action2=count ...}: "
+ actionsWeight
+ "\nTotal number of calls: "
+ nbCalls);
}
/**
* This method calls action of the DatabaseImpl class according the default
* parameters :
* <ul>
* <li>Default action list set by the setup method</li>
* <li>Test through J2EE calls</li>
* </ul>
*/
public void testSimple() {
this.perform();
}
/**
* This method calls none writing action of the DatabaseImpl class.
*/
public void _testReadOnly() {
if (this.simpleTestOnly)
return;
// Create a new list of methods
GenerateListOfActionToBeDone generateMethod =
new GenerateListOfActionToBeDone();
try {
for (int i = 0; i < DatabaseImpl.actionArray.length; i++) {
if (0 == DatabaseImpl.actionWeightArray[i][DatabaseImpl.WRITE])
generateMethod.registerMethod(
DatabaseImpl.actionArray[i],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.READ],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.WRITE]);
}
this.nbOfRead = 1;
this.nbOfWrite = 0;
this.methodsList =
generateMethod.mergeWriteReadMethodList(
this.nbOfWrite,
this.nbOfRead);
} catch (Exception e) {
e.printStackTrace();
}
this.perform();
}
/**
* This method calls none deleting action of the DatabaseImpl class.
*/
public void _testIncreaseDatabaseSize() {
if (this.simpleTestOnly)
return;
// Create a new list of methods
GenerateListOfActionToBeDone generateMethod =
new GenerateListOfActionToBeDone();
try {
for (int i = 0; i < DatabaseImpl.actionArray.length; i++) {
if (!(DatabaseImpl
.actionArray[i]
.equalsIgnoreCase(DatabaseImpl.PARAMETER_MERGE_DEPARTMENT))
&& !(DatabaseImpl
.actionArray[i]
.equalsIgnoreCase(DatabaseImpl.PARAMETER_REM_PROJECT))
&& !(DatabaseImpl
.actionArray[i]
.equalsIgnoreCase(DatabaseImpl.PARAMETER_REM_EMPLOYEE)))
generateMethod.registerMethod(
DatabaseImpl.actionArray[i],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.READ],
DatabaseImpl.actionWeightArray[i][DatabaseImpl.WRITE]);
}
this.methodsList =
generateMethod.mergeWriteReadMethodList(
this.nbOfWrite,
this.nbOfRead);
} catch (Exception e) {
e.printStackTrace();
}
this.perform();
}
}