Search in sources :

Example 1 with MangoSessionRegistry

use of com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry in project ma-core-public by infiniteautomation.

the class UserDao method expireSessionsForUser.

// TODO Mango 4.0 add event listener to MangoSessionRegistry
private void expireSessionsForUser(User user) {
    // web context may not be initialized, can't inject this context
    ApplicationContext context = Common.getRootWebContext();
    if (context != null) {
        MangoSessionRegistry sessionRegistry = context.getBean(MangoSessionRegistry.class);
        sessionRegistry.exireSessionsForUser(user);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) MangoSessionRegistry(com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry)

Example 2 with MangoSessionRegistry

use of com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry in project ma-core-public by infiniteautomation.

the class ServerMonitoringService method doPoll.

@Override
protected void doPoll() {
    ServerStatus status = lifecycle.getServerStatus();
    threads.setValue(status.getThreads());
    idleThreads.setValue(status.getIdleThreads());
    queueSize.setValue(status.getQueueSize());
    if (Common.backgroundProcessing != null) {
        highPriorityActive.setValue(Common.backgroundProcessing.getHighPriorityServiceActiveCount());
        highPriorityScheduled.setValue(Common.backgroundProcessing.getHighPriorityServiceScheduledTaskCount());
        highPriorityWaiting.setValue(Common.backgroundProcessing.getHighPriorityServiceQueueSize());
        mediumPriorityActive.setValue(Common.backgroundProcessing.getMediumPriorityServiceActiveCount());
        mediumPriorityWaiting.setValue(Common.backgroundProcessing.getMediumPriorityServiceQueueSize());
        lowPriorityActive.setValue(Common.backgroundProcessing.getLowPriorityServiceActiveCount());
        lowPriorityWaiting.setValue(Common.backgroundProcessing.getLowPriorityServiceQueueSize());
    }
    dbActiveConnections.setValue(databaseProxy.getActiveConnections());
    dbIdleConnections.setValue(databaseProxy.getIdleConnections());
    // In MiB
    javaMaxMemory.setValue((int) (runtime.maxMemory() / mib));
    javaUsedMemory.setValue((int) (runtime.totalMemory() / mib) - (int) (runtime.freeMemory() / mib));
    javaFreeMemory.setValue(javaMaxMemory.getValue() - javaUsedMemory.getValue());
    // Uptime in HRS
    long uptimeMs = runtimeBean.getUptime();
    Double uptimeHrs = uptimeMs / 3600000.0D;
    BigDecimal bd = new BigDecimal(uptimeHrs);
    bd = bd.setScale(2, RoundingMode.HALF_UP);
    uptime.setValue(bd.doubleValue());
    // Collect Active User Sessions
    ConfigurableApplicationContext context = (ConfigurableApplicationContext) Common.getRootWebContext();
    if (context != null && context.isActive()) {
        MangoSessionRegistry sessionRegistry = context.getBean(MangoSessionRegistry.class);
        userSessions.setValue(sessionRegistry.getActiveSessionCount());
    } else {
        userSessions.setValue(0);
    }
    long ts = System.currentTimeMillis();
    for (ValueMonitor<?> monitor : monitors) {
        try {
            if (monitor instanceof PollableMonitor) {
                ((PollableMonitor<?>) monitor).poll(ts);
            }
        } catch (Exception e) {
            log.warn("Failed to poll monitor {}", monitor.getId(), e);
        }
    }
}
Also used : ConfigurableApplicationContext(org.springframework.context.ConfigurableApplicationContext) MangoSessionRegistry(com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry) ServerStatus(com.serotonin.m2m2.ServerStatus) PollableMonitor(com.infiniteautomation.mango.monitor.PollableMonitor) BigDecimal(java.math.BigDecimal)

Aggregations

MangoSessionRegistry (com.serotonin.m2m2.web.mvc.spring.security.MangoSessionRegistry)2 PollableMonitor (com.infiniteautomation.mango.monitor.PollableMonitor)1 ServerStatus (com.serotonin.m2m2.ServerStatus)1 BigDecimal (java.math.BigDecimal)1 ApplicationContext (org.springframework.context.ApplicationContext)1 ConfigurableApplicationContext (org.springframework.context.ConfigurableApplicationContext)1