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