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;
}
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;
}
Aggregations