use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class BaseSqlQuery method immediateQuery.
/**
* Execute the quer
* @return
*/
public List<T> immediateQuery() {
LogStopWatch stopWatch = null;
if (this.useMetrics)
stopWatch = new LogStopWatch();
List<T> list = this.dao.query(selectSql, selectArgs.toArray(), this.dao.getRowMapper());
if (this.useMetrics)
stopWatch.stop("Query: " + selectSql + " \nArgs: " + selectArgs.toString(), this.metricsThreshold);
return list;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class StreamableSqlQuery method count.
/**
* Execute the Count if there is one
*/
public void count() throws IOException {
if (countSql == null)
return;
LogStopWatch stopWatch = null;
if (this.useMetrics)
stopWatch = new LogStopWatch();
try {
PreparedStatement statement = this.dao.createPreparedStatement(countSql, countArgs, stream);
try {
ResultSet rs = statement.executeQuery();
RowMapper<Long> mapper = SingleColumnRowMapper.newInstance(Long.class);
int index = 0;
while (rs.next()) {
this.countCallback.row(mapper.mapRow(rs, index), index);
index++;
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
statement.cancel();
throw e;
} finally {
statement.getConnection().close();
statement.close();
}
} catch (Exception e) {
LOG.error(e.getMessage() + " For Query: " + countSql, e);
throw new IOException(e);
}
if (this.useMetrics)
stopWatch.stop("Count: " + countSql + " \nArgs: " + countArgs.toString(), this.metricsThreshold);
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class StreamableSqlQuery method query.
/**
* Execute the Query
*/
public void query() throws IOException {
LogStopWatch stopWatch = null;
if (this.useMetrics)
stopWatch = new LogStopWatch();
try {
PreparedStatement statement = this.dao.createPreparedStatement(selectSql, selectArgs, stream);
ResultSet rs = statement.executeQuery();
RowMapper<T> mapper = this.dao.getRowMapper();
int index = 0;
try {
while (rs.next()) {
this.selectCallback.row(mapper.mapRow(rs, index), index);
index++;
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
statement.cancel();
throw e;
} finally {
statement.getConnection().close();
statement.close();
}
} catch (Exception e) {
LOG.error(e.getMessage() + " For Query: " + selectSql, e);
throw new IOException(e);
}
if (this.useMetrics)
stopWatch.stop("Streamable Query: " + selectSql + " \nArgs: " + selectArgs.toString(), this.metricsThreshold);
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class AbstractBasicDao method customizedCount.
protected int customizedCount(SelectJoinStep<Record1<Integer>> input, Condition condition) {
Select<Record1<Integer>> select = input;
if (condition != null) {
select = input.where(condition);
}
String sql = select.getSQL();
List<Object> arguments = select.getBindValues();
Object[] argumentsArray = arguments.toArray(new Object[arguments.size()]);
LogStopWatch stopWatch = null;
if (useMetrics) {
stopWatch = new LogStopWatch();
}
int count = this.ejt.queryForInt(sql, argumentsArray, 0);
if (stopWatch != null) {
stopWatch.stop("customizedCount(): " + this.create.renderInlined(select), metricsThreshold);
}
return count;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method deleteOrphanedPointValueAnnotations.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#deleteOrphanedPointValueAnnotations()
*/
@Override
public void deleteOrphanedPointValueAnnotations() {
LogStopWatch LogStopWatch = new LogStopWatch();
dao.deleteOrphanedPointValueAnnotations();
LogStopWatch.stop("deleteOrphanedPointValueAnnotations()", this.metricsThreshold);
return;
}
Aggregations