Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.jmx;
import java.util.HashMap;
import java.util.Map;
import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.AttributeNotFoundException;
import javax.management.DynamicMBean;
import javax.management.InvalidAttributeValueException;
import javax.management.MBeanAttributeInfo;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.ReflectionException;
import org.glassfish.jersey.internal.util.collection.Value;
import org.glassfish.jersey.server.monitoring.ExecutionStatistics;
import org.glassfish.jersey.server.monitoring.TimeWindowStatistics;
/**
* Dynamic MBean that exposes information about execution statistics. The exposed information contains
* execution statistics for various time window sizes.
*
* @author Miroslav Fuksa
*/
public class ExecutionStatisticsDynamicBean implements DynamicMBean {
private volatile ExecutionStatistics executionStatistics;
private final Map> attributeValues = new HashMap<>();
private final MBeanInfo mBeanInfo;
private MBeanInfo initMBeanInfo(final ExecutionStatistics initialStatistics) {
final Map statsMap = initialStatistics.getTimeWindowStatistics();
MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[statsMap.size() * 5];
int i = 0;
for (final TimeWindowStatistics stats : statsMap.values()) {
final long interval = stats.getTimeWindow();
final String postfix = convertIntervalToString((int) interval);
String name = "MinTime[ms]_" + postfix;
attrs[i++] = new MBeanAttributeInfo(name, "long", "Minimum request processing time in milliseconds in last "
+ postfix + ".", true, false, false);
attributeValues.put(name, new Value