use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method getStartAndEndTime.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#getStartAndEndTime(java.util.List)
*/
@Override
public LongPair getStartAndEndTime(List<Integer> pointIds) {
LogStopWatch LogStopWatch = new LogStopWatch();
LongPair result = dao.getStartAndEndTime(pointIds);
String sqlIn = "[";
for (int i = 0; i < pointIds.size(); i++) {
sqlIn += pointIds.get(i);
if (i < pointIds.size())
sqlIn += ",";
}
sqlIn += "]";
LogStopWatch.stop("getStartAndEndTime(pointIds) + (" + sqlIn + ")", this.metricsThreshold);
return result;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method dateRangeCount.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#dateRangeCount(int, long, long)
*/
@Override
public long dateRangeCount(int pointId, long from, long to) {
LogStopWatch LogStopWatch = new LogStopWatch();
long value = dao.dateRangeCount(pointId, from, to);
LogStopWatch.stop("dateRangeCount(pointId,from,to) (" + pointId + ", " + from + ", " + to + ")", this.metricsThreshold);
return value;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class AbstractBasicDao method customizedQuery.
protected void customizedQuery(SelectJoinStep<Record> select, Condition condition, List<SortField<Object>> sort, Integer limit, Integer offset, MappedRowCallback<T> callback) {
SelectConnectByStep<Record> afterWhere = condition == null ? select : select.where(condition);
SelectLimitStep<Record> afterSort = sort == null ? afterWhere : afterWhere.orderBy(sort);
Select<Record> offsetStep = afterSort;
if (limit != null) {
if (offset != null) {
offsetStep = afterSort.limit(offset, limit);
} else {
offsetStep = afterSort.limit(limit);
}
}
String sql = offsetStep.getSQL();
List<Object> arguments = offsetStep.getBindValues();
Object[] argumentsArray = arguments.toArray(new Object[arguments.size()]);
LogStopWatch stopWatch = null;
if (useMetrics) {
stopWatch = new LogStopWatch();
}
// this.query(sql, argumentsArray, this.getRowMapper(), callback );
this.query(sql, argumentsArray, new ResultSetExtractor<Void>() {
@Override
public Void extractData(ResultSet rs) throws SQLException, DataAccessException {
RowMapper<T> rowMapper = getRowMapper();
int rowNum = 0;
while (rs.next()) {
try {
callback.row(rowMapper.mapRow(rs, rowNum), rowNum);
} catch (Exception e) {
if (e.getCause() instanceof ModuleNotLoadedException)
LOG.error(e.getCause().getMessage(), e.getCause());
else
LOG.error(e.getMessage(), e);
} finally {
rowNum++;
}
}
return null;
}
});
if (stopWatch != null) {
stopWatch.stop("customizedQuery(): " + this.create.renderInlined(offsetStep), metricsThreshold);
}
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method getPointValuesBetween.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#getPointValuesBetween(int, long, long)
*/
@Override
public List<PointValueTime> getPointValuesBetween(int pointId, long from, long to) {
LogStopWatch LogStopWatch = new LogStopWatch();
List<PointValueTime> values = dao.getPointValuesBetween(pointId, from, to);
LogStopWatch.stop("getPointValuesBetween(pointId, from, to) (" + pointId + ", " + from + ", " + to + "){" + values.size() + "}", this.metricsThreshold);
return values;
}
use of com.serotonin.log.LogStopWatch in project ma-core-public by infiniteautomation.
the class PointValueDaoMetrics method getPointValueAt.
/* (non-Javadoc)
* @see com.serotonin.m2m2.db.dao.PointValueDao#getPointValueAt(int, long)
*/
@Override
public PointValueTime getPointValueAt(int pointId, long time) {
LogStopWatch LogStopWatch = new LogStopWatch();
PointValueTime value = dao.getPointValueAt(pointId, time);
LogStopWatch.stop("getPointValueAt(pointId,time) (" + pointId + ", " + time + "){" + (value != null ? 1 : 0) + "}", this.metricsThreshold);
return value;
}
Aggregations