0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna/*
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* The contents of this file are subject to the terms of the Common Development and
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* Distribution License (the License). You may not use this file except in compliance with the
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* License.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna*
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* specific language governing permission and limitations under the License.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna*
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* When distributing Covered Software, include this CDDL Header Notice in each file and include
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* Header, with the fields enclosed by brackets [] replaced by your own identifying
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* information: "Portions copyright [year] [name of copyright owner]".
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna*
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna* Copyright 2014 ForgeRock AS.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna*/
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunapackage org.forgerock.openam.monitoring.session;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport com.iplanet.dpro.session.monitoring.SessionMonitoringStore;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport com.iplanet.dpro.session.monitoring.SessionMonitorType;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport com.sun.management.snmp.SnmpStatusException;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport com.sun.management.snmp.agent.SnmpMib;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport org.forgerock.openam.cts.exceptions.CoreTokenException;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport org.forgerock.openam.cts.monitoring.impl.persistence.CtsPersistenceOperationsMonitor;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport org.forgerock.openam.monitoring.cts.InvalidSNMPQueryException;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna/**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Implementation for hooking the SNMP {@link CtsSessions} class in to OpenAM to report on our stats.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunapublic class CtsSessionsImpl extends CtsSessions {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna private final CtsPersistenceOperationsMonitor ctsMonitor;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna private final SessionMonitoringStore monitorStore;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public CtsSessionsImpl(CtsPersistenceOperationsMonitor ctsMonitor, SnmpMib myMib,
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna SessionMonitoringStore monitorStore) {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna super(myMib);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna this.ctsMonitor = ctsMonitor;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna this.monitorStore = monitorStore;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Getter for the "SumCTSSessions" variable.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public Long getSumCTSSessions() throws SnmpStatusException {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna try {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna return ctsMonitor.getTotalCount();
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna } catch (CoreTokenException e) {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna throw new InvalidSNMPQueryException("CTS Persistence did not return a valid result.", e);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Getter for the "AverageRemoteSetPropertyTime" variable.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public Long getAverageCTSSetPropertyTime() throws SnmpStatusException {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna return monitorStore.getAverageSetPropertyTime(SessionMonitorType.CTS);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Getter for the "AverageRemoteDestroyTime" variable.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public Long getAverageCTSDestroyTime() throws SnmpStatusException {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna return monitorStore.getAverageDestroyTime(SessionMonitorType.CTS);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Getter for the "AverageRemoteLogoutTime" variable.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public Long getAverageCTSLogoutTime() throws SnmpStatusException {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna return monitorStore.getAverageLogoutTime(SessionMonitorType.CTS);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Getter for the "AverageRemoteRefreshTime" variable.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public Long getAverageCTSRefreshTime() throws SnmpStatusException {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna return monitorStore.getAverageRefreshTime(SessionMonitorType.CTS);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna}