MemoryUsageMonitorProvider.java revision f15e69d46eb0444e28427f49fb519ea476c7feae
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class defines a monitor provider that reports information about
* Directory Server memory usage.
*/
public class MemoryUsageMonitorProvider
implements Runnable
{
/** A map of the last GC counts seen by this monitor for calculating recent stats. */
/** A map of the last GC times seen by this monitor for calculating recent stats. */
/** A map of the most recent GC durations seen by this monitor. */
/** A map of the memory manager names to names that are safe for use in attribute names. */
/** {@inheritDoc} */
public void initializeMonitorProvider(
{
}
/** {@inheritDoc} */
public String getMonitorInstanceName()
{
return "JVM Memory Usage";
}
/** {@inheritDoc} */
public void run()
{
for (GarbageCollectorMXBean gc :
{
long lastGCCount = 0L;
long lastGCTime = 0L;
long recentGCDuration = 0L;
{
}
if (gcCount > lastGCCount)
{
}
}
}
{
for (GarbageCollectorMXBean gc :
{
long avgGCDuration = 0L;
if (gcCount > 0)
{
}
long recentGCDuration = 0L;
{
}
{
}
}
{
{
}
}
return attrs;
}
{
}
/**
* Creates a "safe" version of the provided name, which is acceptable for
* use as part of an attribute name.
*
* @param name The name for which to obtain the safe name.
*
* @return The calculated safe name.
*/
{
boolean lastWasUppercase = false;
boolean lastWasDash = false;
{
{
if (Character.isUpperCase(c))
{
{
}
lastWasUppercase = true;
lastWasDash = false;
}
else
{
lastWasUppercase = false;
lastWasDash = false;
}
}
{
lastWasUppercase = false;
lastWasDash = false;
}
else if (c == ' ' || c == '_' || c == '-')
{
if (! lastWasDash)
{
}
lastWasUppercase = false;
lastWasDash = true;
}
}
}
}