Search in sources :

Example 1 with PointHistoryCount

use of com.serotonin.m2m2.vo.bean.PointHistoryCount in project ma-core-public by infiniteautomation.

the class SystemSettingsDwr method getDatabaseSize.

@DwrPermission(admin = true)
public Map<String, Object> getDatabaseSize() {
    Map<String, Object> data = new HashMap<>();
    // Database size
    Long dbSize = Common.databaseProxy.getDatabaseSizeInBytes();
    if (dbSize != null) {
        data.put("databaseSize", DirectoryUtils.bytesDescription(dbSize));
    } else {
        data.put("databaseSize", "(" + translate("common.unknown") + ")");
        dbSize = 0L;
    }
    // Do we have any NoSQL Data
    long noSqlSize = 0L;
    if (Common.databaseProxy.getNoSQLProxy() != null) {
        String pointValueStoreName = Common.envProps.getString("db.nosql.pointValueStoreName", "mangoTSDB");
        noSqlSize = Common.databaseProxy.getNoSQLProxy().getDatabaseSizeInBytes(pointValueStoreName);
        data.put("noSqlDatabaseSize", DirectoryUtils.bytesDescription(noSqlSize));
    }
    // Filedata data
    DirectoryInfo fileDatainfo = DirectoryUtils.getSize(new File(Common.getFiledataPath()));
    long filedataSize = fileDatainfo.getSize();
    data.put("filedataCount", fileDatainfo.getCount());
    data.put("filedataSize", DirectoryUtils.bytesDescription(filedataSize));
    data.put("totalSize", DirectoryUtils.bytesDescription(dbSize + filedataSize + noSqlSize));
    // Point history counts.
    List<PointHistoryCount> counts = DataPointDao.instance.getTopPointHistoryCounts();
    int sum = 0;
    for (PointHistoryCount c : counts) sum += c.getCount();
    data.put("historyCount", sum);
    data.put("topPoints", counts);
    data.put("eventCount", EventDao.instance.getEventCount());
    return data;
}
Also used : PointHistoryCount(com.serotonin.m2m2.vo.bean.PointHistoryCount) HashMap(java.util.HashMap) DirectoryInfo(com.serotonin.util.DirectoryInfo) File(java.io.File) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 2 with PointHistoryCount

use of com.serotonin.m2m2.vo.bean.PointHistoryCount in project ma-core-public by infiniteautomation.

the class DataPointDao method getTopPointHistoryCountsNoSql.

private List<PointHistoryCount> getTopPointHistoryCountsNoSql() {
    PointValueDao dao = Common.databaseProxy.newPointValueDao();
    // For now we will do this the slow way
    List<DataPointVO> points = getDataPoints(DataPointExtendedNameComparator.instance, false);
    List<PointHistoryCount> counts = new ArrayList<>();
    for (DataPointVO point : points) {
        PointHistoryCount phc = new PointHistoryCount();
        long count = dao.dateRangeCount(point.getId(), 0L, Long.MAX_VALUE);
        phc.setCount((int) count);
        phc.setPointId(point.getId());
        phc.setPointName(point.getName());
        counts.add(phc);
    }
    Collections.sort(counts, new Comparator<PointHistoryCount>() {

        @Override
        public int compare(PointHistoryCount count1, PointHistoryCount count2) {
            return count2.getCount() - count1.getCount();
        }
    });
    return counts;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointHistoryCount(com.serotonin.m2m2.vo.bean.PointHistoryCount) ArrayList(java.util.ArrayList)

Example 3 with PointHistoryCount

use of com.serotonin.m2m2.vo.bean.PointHistoryCount in project ma-core-public by infiniteautomation.

the class DataPointDao method getTopPointHistoryCountsSql.

private List<PointHistoryCount> getTopPointHistoryCountsSql() {
    List<PointHistoryCount> counts = query("select dataPointId, count(*) from pointValues group by dataPointId order by 2 desc", new RowMapper<PointHistoryCount>() {

        @Override
        public PointHistoryCount mapRow(ResultSet rs, int rowNum) throws SQLException {
            PointHistoryCount c = new PointHistoryCount();
            c.setPointId(rs.getInt(1));
            c.setCount(rs.getInt(2));
            return c;
        }
    });
    List<DataPointVO> points = getDataPoints(DataPointExtendedNameComparator.instance, false);
    // Collate in the point names.
    for (PointHistoryCount c : counts) {
        for (DataPointVO point : points) {
            if (point.getId() == c.getPointId()) {
                c.setPointName(point.getExtendedName());
                break;
            }
        }
    }
    // Remove the counts for which there are no point, i.e. deleted.
    Iterator<PointHistoryCount> iter = counts.iterator();
    while (iter.hasNext()) {
        PointHistoryCount c = iter.next();
        if (c.getPointName() == null)
            iter.remove();
    }
    return counts;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PointHistoryCount(com.serotonin.m2m2.vo.bean.PointHistoryCount) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) IDataPoint(com.serotonin.m2m2.vo.IDataPoint)

Aggregations

PointHistoryCount (com.serotonin.m2m2.vo.bean.PointHistoryCount)3 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)2 IDataPoint (com.serotonin.m2m2.vo.IDataPoint)1 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)1 DirectoryInfo (com.serotonin.util.DirectoryInfo)1 File (java.io.File)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1