Search in sources :

Example 26 with LogStopWatch

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;
}
Also used : LongPair(com.serotonin.m2m2.vo.pair.LongPair) LogStopWatch(com.serotonin.log.LogStopWatch)

Example 27 with LogStopWatch

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;
}
Also used : LogStopWatch(com.serotonin.log.LogStopWatch)

Example 28 with LogStopWatch

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);
    }
}
Also used : SQLException(java.sql.SQLException) DataAccessException(org.springframework.dao.DataAccessException) ModuleNotLoadedException(com.serotonin.ModuleNotLoadedException) SQLException(java.sql.SQLException) ShouldNeverHappenException(com.serotonin.ShouldNeverHappenException) ModuleNotLoadedException(com.serotonin.ModuleNotLoadedException) ResultSet(java.sql.ResultSet) Record(org.jooq.Record) LogStopWatch(com.serotonin.log.LogStopWatch) DataAccessException(org.springframework.dao.DataAccessException) RowMapper(org.springframework.jdbc.core.RowMapper)

Example 29 with LogStopWatch

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;
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) LogStopWatch(com.serotonin.log.LogStopWatch)

Example 30 with LogStopWatch

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;
}
Also used : PointValueTime(com.serotonin.m2m2.rt.dataImage.PointValueTime) IdPointValueTime(com.serotonin.m2m2.rt.dataImage.IdPointValueTime) LogStopWatch(com.serotonin.log.LogStopWatch)

Aggregations

LogStopWatch (com.serotonin.log.LogStopWatch)45 IdPointValueTime (com.serotonin.m2m2.rt.dataImage.IdPointValueTime)9 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)9 ResultSet (java.sql.ResultSet)3 LogEvent (com.serotonin.m2m2.rt.console.LogEvent)2 IOException (java.io.IOException)2 PreparedStatement (java.sql.PreparedStatement)2 Simplify (com.goebl.simplify.Simplify)1 DataPointVOPointValueTimeBookend (com.infiniteautomation.mango.rest.v2.model.pointValue.DataPointVOPointValueTimeBookend)1 ModuleNotLoadedException (com.serotonin.ModuleNotLoadedException)1 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 UserEventCache (com.serotonin.m2m2.rt.event.UserEventCache)1 LongPair (com.serotonin.m2m2.vo.pair.LongPair)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Record (org.jooq.Record)1 Record1 (org.jooq.Record1)1 DataAccessException (org.springframework.dao.DataAccessException)1 RowMapper (org.springframework.jdbc.core.RowMapper)1