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 com.iplanet.dpro.session.monitoring;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport javax.inject.Inject;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunaimport org.forgerock.openam.shared.monitoring.AbstractTimingStore;
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna/**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * An implementation of a timing store specific to the needs of the session monitoring component.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Added values are wrapped in a {@link SessionTimingEntry}.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Lunapublic class SessionMonitoringTimingStore extends AbstractTimingStore {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna @Inject
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public SessionMonitoringTimingStore(SessionMonitoringService monitoringService) {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna this(monitoringService.getSessionWindowSize());
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Constructs a SessionMonitoringTimingStore with the provided maximum number of entries in its sample window.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna *
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * @param maxEntries the maximum number of samples to consider when performing oeprations on the store
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public SessionMonitoringTimingStore(int maxEntries) {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna super(maxEntries);
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna /**
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * Adds an entry to the timing store, having wrapped the supplied long duration in a
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * {@link SessionTimingEntry}.
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna *
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna * @param duration the length of time the operation took
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna */
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna public void addTimingEntry(long duration) {
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna durationStore.add(new SessionTimingEntry(duration));
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna }
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna
0f7c5b88fd04e25bea6113dfc783a05e4e2045f8David Luna}