use of org.alfresco.heartbeat.datasender.HBData in project alfresco-remote-api by Alfresco.
the class RenditionsDataCollectorTest method testCollectedDataInDetail.
@Test
public void testCollectedDataInDetail() {
// Record an initial batch of 4 renditions
renditionsDataCollector.recordRenditionRequest(doclib, "xls");
renditionsDataCollector.recordRenditionRequest(doclib, "xls");
renditionsDataCollector.recordRenditionRequest(preview, "docx");
renditionsDataCollector.recordRenditionRequest(doclib, "docx");
collectedData = renditionsDataCollector.collectData();
assertEquals("There should have been 3 data elements", 3, collectedData.size());
Date firstTimestamp = null;
for (HBData data : collectedData) {
if (firstTimestamp == null) {
firstTimestamp = data.getTimestamp();
} else {
assertEquals("All data in a batch should have the same timestamp", firstTimestamp, data.getTimestamp());
}
Map<String, Object> values = data.getData();
assertEquals("There should have been 4 mapped values", 4, values.size());
String rendition = (String) values.get("rendition");
String sourceMimetype = (String) values.get("sourceMimetype");
String targetMimetype = (String) values.get("targetMimetype");
Integer count = (Integer) values.get("count");
assertNotNull(rendition);
assertNotNull(sourceMimetype);
assertNotNull(targetMimetype);
assertNotNull(count);
}
assertHBDataContains("doclib", "xls", "png", 2);
assertHBDataContains("doclib", "docx", "png", 1);
assertHBDataContains("preview", "docx", "pdf", 1);
}
use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.
the class SessionsUsageDataCollector method collectData.
@Override
public List<HBData> collectData() {
Map<String, Object> sessionValues = new HashMap<>();
sessionValues.put("activeTickets", repoServerMgmt.getTicketCountNonExpired());
HBData sessionsData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), sessionValues);
return Arrays.asList(sessionsData);
}
use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.
the class SystemUsageDataCollector method collectData.
@Override
public List<HBData> collectData() {
logger.debug("Preparing repository usage (system) data...");
Runtime runtime = Runtime.getRuntime();
Map<String, Object> systemUsageValues = new HashMap<>();
// operating system MBean info
Map<String, Object> cpu = new HashMap<>();
OperatingSystemMXBean osMBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
if (osMBean != null) {
if (osMBean instanceof UnixOperatingSystemMXBean) {
long openFileDescriptorCount = ((UnixOperatingSystemMXBean) osMBean).getOpenFileDescriptorCount();
systemUsageValues.put("openFileDescriptorCount", new Long(openFileDescriptorCount));
}
// processor info
double processCpuLoad = osMBean.getProcessCpuLoad() * 100;
double systemCpuLoad = osMBean.getSystemCpuLoad() * 100;
int intProcessCpuLoad = (int) Math.round(processCpuLoad);
int intSystemCpuLoad = (int) Math.round(systemCpuLoad);
cpu.put("percentageProcessLoad", new Integer(intProcessCpuLoad));
cpu.put("percentageSystemLoad", new Integer(intSystemCpuLoad));
cpu.put("systemLoadAverage", new Double(osMBean.getSystemLoadAverage()));
}
cpu.put("availableProcessors", new Integer(runtime.availableProcessors()));
systemUsageValues.put("cpu", cpu);
// database connections info
if (dataSource instanceof BasicDataSource) {
Map<String, Object> db = new HashMap<>();
int idleConnections = ((BasicDataSource) dataSource).getNumIdle();
int activeConnections = ((BasicDataSource) dataSource).getNumActive();
db.put("idleConnections", new Integer(idleConnections));
db.put("activeConnections", new Integer(activeConnections));
systemUsageValues.put("db", db);
}
// memory info
Map<String, Object> mem = new HashMap<>();
mem.put("free", runtime.freeMemory());
mem.put("max", runtime.maxMemory());
mem.put("total", runtime.totalMemory());
systemUsageValues.put("mem", mem);
HBData systemUsageData = new HBData(this.currentRepoDescriptorDAO.getDescriptor().getId(), this.getCollectorId(), this.getCollectorVersion(), new Date(), systemUsageValues);
return Arrays.asList(systemUsageData);
}
use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.
the class ConfigurationDataCollectorTest method testHBDataFields.
@Test
public void testHBDataFields() {
for (HBData data : this.collectedData) {
assertNotNull(data.getCollectorId());
assertNotNull(data.getCollectorVersion());
assertNotNull(data.getSchemaVersion());
assertNotNull(data.getSystemId());
assertNotNull(data.getTimestamp());
assertNotNull(data.getData());
}
}
use of org.alfresco.heartbeat.datasender.HBData in project alfresco-repository by Alfresco.
the class InfoDataCollectorTest method testHBDataFields.
@Test
public void testHBDataFields() {
mockVersionDetails("6", "0", "0", "");
collectedData = infoCollector.collectData();
HBData repoInfo = grabDataByCollectorId(infoCollector.getCollectorId());
assertNotNull("Repository info data missing.", repoInfo);
for (HBData data : this.collectedData) {
assertNotNull(data.getCollectorId());
assertNotNull(data.getCollectorVersion());
assertNotNull(data.getSchemaVersion());
assertNotNull(data.getSystemId());
assertNotNull(data.getTimestamp());
assertNotNull(data.getData());
}
}
Aggregations