Search in sources :

Example 1 with HBData

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);
}
Also used : HBData(org.alfresco.heartbeat.datasender.HBData) Date(java.util.Date) Test(org.junit.Test)

Example 2 with HBData

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);
}
Also used : HashMap(java.util.HashMap) HBData(org.alfresco.heartbeat.datasender.HBData) Date(java.util.Date)

Example 3 with HBData

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);
}
Also used : UnixOperatingSystemMXBean(com.sun.management.UnixOperatingSystemMXBean) HBData(org.alfresco.heartbeat.datasender.HBData) BasicDataSource(org.apache.commons.dbcp.BasicDataSource) OperatingSystemMXBean(com.sun.management.OperatingSystemMXBean) UnixOperatingSystemMXBean(com.sun.management.UnixOperatingSystemMXBean)

Example 4 with HBData

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());
    }
}
Also used : HBData(org.alfresco.heartbeat.datasender.HBData) Test(org.junit.Test)

Example 5 with HBData

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());
    }
}
Also used : HBData(org.alfresco.heartbeat.datasender.HBData) Test(org.junit.Test)

Aggregations

HBData (org.alfresco.heartbeat.datasender.HBData)24 Test (org.junit.Test)16 Map (java.util.Map)7 Date (java.util.Date)5 HashMap (java.util.HashMap)5 OperatingSystemMXBean (com.sun.management.OperatingSystemMXBean)2 UnixOperatingSystemMXBean (com.sun.management.UnixOperatingSystemMXBean)2 BasicDataSource (org.apache.commons.dbcp.BasicDataSource)2 Connection (java.sql.Connection)1 DatabaseMetaData (java.sql.DatabaseMetaData)1 SQLException (java.sql.SQLException)1 LinkedList (java.util.LinkedList)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HBBaseDataCollector (org.alfresco.heartbeat.HBBaseDataCollector)1 HBDataSenderService (org.alfresco.heartbeat.datasender.HBDataSenderService)1 CustomModelsInfo (org.alfresco.repo.dictionary.CustomModelsInfo)1 ThumbnailDefinition (org.alfresco.repo.thumbnail.ThumbnailDefinition)1 AuditService (org.alfresco.service.cmr.audit.AuditService)1 ModuleDetails (org.alfresco.service.cmr.module.ModuleDetails)1