Search in sources :

Example 1 with StatisticDescription

use of com.axway.ats.log.autodb.entities.StatisticDescription in project ats-framework by Axway.

the class DbReadAccess method getSystemStatisticDescriptions.

public List<StatisticDescription> getSystemStatisticDescriptions(float timeOffset, String testcaseIds, Map<String, String> testcaseAliases) throws DatabaseAccessException {
    List<StatisticDescription> statisticDescriptions = new ArrayList<StatisticDescription>();
    String sqlLog = new SqlRequestFormatter().add("fdate", formatDateFromEpoch(timeOffset)).add("testcase ids", testcaseIds).format();
    Connection connection = getConnection();
    CallableStatement callableStatement = null;
    ResultSet rs = null;
    try {
        callableStatement = connection.prepareCall("{ call sp_get_system_statistic_descriptions(?, ?) }");
        callableStatement.setString(1, formatDateFromEpoch(timeOffset));
        callableStatement.setString(2, testcaseIds);
        rs = callableStatement.executeQuery();
        int numberRecords = 0;
        while (rs.next()) {
            StatisticDescription statisticDescription = new StatisticDescription();
            statisticDescription.testcaseId = rs.getInt("testcaseId");
            // if user has provided testcase alias - use it instead the original testcase name
            if (testcaseAliases != null) {
                statisticDescription.testcaseName = testcaseAliases.get(String.valueOf(statisticDescription.testcaseId));
            }
            if (statisticDescription.testcaseName == null) {
                statisticDescription.testcaseName = rs.getString("testcaseName");
            }
            statisticDescription.testcaseStarttime = rs.getInt("testcaseStarttime");
            statisticDescription.machineId = rs.getInt("machineId");
            statisticDescription.machineName = rs.getString("machineName");
            statisticDescription.statisticTypeId = rs.getInt("statsTypeId");
            statisticDescription.statisticName = rs.getString("name");
            statisticDescription.unit = rs.getString("units");
            statisticDescription.params = rs.getString("params");
            statisticDescription.parent = rs.getString("parentName");
            statisticDescription.internalName = rs.getString("internalName");
            statisticDescription.numberMeasurements = rs.getInt("statsNumberMeasurements");
            statisticDescription.minValue = rs.getFloat("statsMinValue");
            statisticDescription.maxValue = rs.getFloat("statsMaxValue");
            statisticDescription.avgValue = rs.getFloat("statsAvgValue");
            statisticDescriptions.add(statisticDescription);
            numberRecords++;
        }
        logQuerySuccess(sqlLog, "system statistic descriptions", numberRecords);
    } catch (Exception e) {
        throw new DatabaseAccessException("Error when " + sqlLog, e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, callableStatement);
    }
    return statisticDescriptions;
}
Also used : StatisticDescription(com.axway.ats.log.autodb.entities.StatisticDescription) CallableStatement(java.sql.CallableStatement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DbConnection(com.axway.ats.core.dbaccess.DbConnection) ResultSet(java.sql.ResultSet) Checkpoint(com.axway.ats.log.autodb.entities.Checkpoint) SQLException(java.sql.SQLException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Example 2 with StatisticDescription

use of com.axway.ats.log.autodb.entities.StatisticDescription in project ats-framework by Axway.

the class DbReadAccess method getCheckpointStatisticDescriptions.

public List<StatisticDescription> getCheckpointStatisticDescriptions(float timeOffset, String testcaseIds, Map<String, String> testcaseAliases) throws DatabaseAccessException {
    List<StatisticDescription> statisticDescriptions = new ArrayList<StatisticDescription>();
    String sqlLog = new SqlRequestFormatter().add("fdate", formatDateFromEpoch(timeOffset)).add("testcase ids", testcaseIds).format();
    Connection connection = getConnection();
    CallableStatement callableStatement = null;
    ResultSet rs = null;
    try {
        callableStatement = connection.prepareCall("{ call sp_get_checkpoint_statistic_descriptions(?, ?) }");
        callableStatement.setString(1, formatDateFromEpoch(timeOffset));
        callableStatement.setString(2, testcaseIds);
        rs = callableStatement.executeQuery();
        int numberRecords = 0;
        while (rs.next()) {
            StatisticDescription statisticDescription = new StatisticDescription();
            statisticDescription.testcaseId = rs.getInt("testcaseId");
            // if user has provided testcase alias - use it instead the original testcase name
            if (testcaseAliases != null) {
                statisticDescription.testcaseName = testcaseAliases.get(String.valueOf(statisticDescription.testcaseId));
            }
            if (statisticDescription.testcaseName == null) {
                statisticDescription.testcaseName = rs.getString("testcaseName");
            }
            statisticDescription.testcaseStarttime = rs.getInt("testcaseStarttime");
            // Checkpoints will be collected and displayed for testcase
            statisticDescription.machineId = 0;
            statisticDescription.machineName = MACHINE_NAME_FOR_ATS_AGENTS;
            statisticDescription.queueName = rs.getString("queueName");
            statisticDescription.numberMeasurements = rs.getInt("statsNumberMeasurements");
            statisticDescription.statisticName = rs.getString("name");
            // "statsUnit" field is null for checkpoint statistics, because the action response times are always measured in "ms"
            statisticDescription.unit = "ms";
            statisticDescriptions.add(statisticDescription);
            numberRecords++;
        }
        logQuerySuccess(sqlLog, "system statistic descriptions", numberRecords);
    } catch (Exception e) {
        throw new DatabaseAccessException("Error when " + sqlLog, e);
    } finally {
        DbUtils.closeResultSet(rs);
        DbUtils.close(connection, callableStatement);
    }
    return statisticDescriptions;
}
Also used : StatisticDescription(com.axway.ats.log.autodb.entities.StatisticDescription) CallableStatement(java.sql.CallableStatement) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) DbConnection(com.axway.ats.core.dbaccess.DbConnection) ResultSet(java.sql.ResultSet) Checkpoint(com.axway.ats.log.autodb.entities.Checkpoint) SQLException(java.sql.SQLException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Aggregations

DbConnection (com.axway.ats.core.dbaccess.DbConnection)2 Checkpoint (com.axway.ats.log.autodb.entities.Checkpoint)2 StatisticDescription (com.axway.ats.log.autodb.entities.StatisticDescription)2 DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)2 CallableStatement (java.sql.CallableStatement)2 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 ArrayList (java.util.ArrayList)2