Search in sources :

Example 6 with TestCaseExecutionQueueToTreat

use of org.cerberus.engine.threadpool.entity.TestCaseExecutionQueueToTreat in project cerberus-source by cerberustesting.

the class ExecutionThreadPoolService method getCurrentlyPoolSizes.

@Override
public HashMap<String, Integer> getCurrentlyPoolSizes() throws CerberusException {
    AnswerList answer = new AnswerList();
    HashMap<String, Integer> constrains_current = new HashMap<String, Integer>();
    String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;
    int poolSizeGeneral = parameterService.getParameterIntegerByKey("cerberus_queueexecution_global_threadpoolsize", "", 12);
    int poolSizeRobot = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultrobothost_threadpoolsize", "", 10);
    constrains_current.put(const01_key, poolSizeGeneral);
    // Getting RobotHost PoolSize
    HashMap<String, Integer> robot_poolsize = new HashMap<String, Integer>();
    robot_poolsize = invariantService.readToHashMapGp1IntegerByIdname("ROBOTHOST", poolSizeRobot);
    // Getting all executions to be treated.
    answer = tceiqService.readQueueToTreat();
    List<TestCaseExecutionQueueToTreat> executionsToTreat = (List<TestCaseExecutionQueueToTreat>) answer.getDataList();
    // Calculate constrain values.
    for (TestCaseExecutionQueueToTreat exe : executionsToTreat) {
        String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLICATION + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();
        String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_ROBOT + CONST_SEPARATOR + exe.getRobotHost();
        constrains_current.put(const02_key, exe.getPoolSizeApplication());
        // Getting Robot Host PoolSize from invariant hashmap.
        int robot_poolsize_final = 0;
        if (robot_poolsize.containsKey(exe.getRobotHost())) {
            robot_poolsize_final = ParameterParserUtil.parseIntegerParam(robot_poolsize.get(exe.getRobotHost()), poolSizeRobot);
        } else {
            robot_poolsize_final = 0;
        }
        constrains_current.put(const03_key, robot_poolsize_final);
    }
    return constrains_current;
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) HashMap(java.util.HashMap) AnswerList(org.cerberus.util.answer.AnswerList) List(java.util.List) TestCaseExecutionQueueToTreat(org.cerberus.engine.threadpool.entity.TestCaseExecutionQueueToTreat)

Aggregations

TestCaseExecutionQueueToTreat (org.cerberus.engine.threadpool.entity.TestCaseExecutionQueueToTreat)6 AnswerList (org.cerberus.util.answer.AnswerList)5 HashMap (java.util.HashMap)4 List (java.util.List)4 SQLException (java.sql.SQLException)2 CerberusException (org.cerberus.exception.CerberusException)2 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 MessageEvent (org.cerberus.engine.entity.MessageEvent)1 FactoryCreationException (org.cerberus.exception.FactoryCreationException)1