org.glassfish.jersey.server.internal.monitoring.MonitoringStatisticsImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jersey-server Show documentation
Show all versions of jersey-server Show documentation
Jersey core server implementation
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.jersey.server.internal.monitoring;
import java.util.Collections;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.function.Function;
import org.glassfish.jersey.internal.util.collection.Views;
import org.glassfish.jersey.server.model.Resource;
import org.glassfish.jersey.server.model.ResourceMethod;
import org.glassfish.jersey.server.model.ResourceModel;
import org.glassfish.jersey.server.monitoring.ExceptionMapperStatistics;
import org.glassfish.jersey.server.monitoring.ExecutionStatistics;
import org.glassfish.jersey.server.monitoring.MonitoringStatistics;
import org.glassfish.jersey.server.monitoring.ResourceStatistics;
import org.glassfish.jersey.server.monitoring.ResponseStatistics;
/**
* Monitoring statistics implementation.
*
* This object is loosely immutable (i.e., {@link #getResourceClassStatistics()} and {@link #getUriStatistics()} gets updated on
* access). As a result, it is unnecessary to call {@link #snapshot()}.
*
* @author Miroslav Fuksa
*/
final class MonitoringStatisticsImpl implements MonitoringStatistics {
/**
* Builder of monitoring statistics.
*
* This builder does not need to be threadsafe as it's only accessed by jersey-background-task-scheduler. However, {@link
* #BUILDING_FUNCTION} is triggered when it is accessed (e.g., by servlet-container thread-pool threads) which adds threadsafe
* constraint on some of the sub-builders.
*
* Sub-Builders that require thread-safety
*
* - {@link org.glassfish.jersey.server.internal.monitoring.ExecutionStatisticsImpl.Builder}
* - {@link org.glassfish.jersey.server.internal.monitoring.ResourceStatisticsImpl.Builder}
* - {@link org.glassfish.jersey.server.internal.monitoring.ResourceMethodStatisticsImpl.Builder}
* - {@link org.glassfish.jersey.server.internal.monitoring.TimeWindowStatisticsImpl.Builder}
*
* The rest does not need to be thread-safe
*
* - {@link org.glassfish.jersey.server.internal.monitoring.ExceptionMapperStatisticsImpl.Builder}
* - {@link org.glassfish.jersey.server.internal.monitoring.ResponseStatisticsImpl.Builder}
*
*/
static class Builder {
private static final Function