TraditionalWorkQueueMonitor.java revision 0841dd13681c9543b393a18487ef7f259859eaf1
/*
* 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 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2014-2015 ForgeRock AS
*/
/**
* This class defines a Directory Server monitor that can be used to provide
* information about the state of the work queue.
*/
public class TraditionalWorkQueueMonitor
extends MonitorProvider<MonitorProviderCfg>
implements Runnable
{
/** The name to use for the monitor attribute that provides the current request backlog. */
/** The name to use for the monitor attribute that provides the average request backlog. */
/**
* The name to use for the monitor attribute that provides the maximum
* observed request backlog.
*/
/**
* The name to use for the monitor attribute that provides the total number of
* operations submitted.
*/
/**
* The name to use for the monitor attribute that provides the total number of
* requests that have been rejected because the work queue was full.
*/
/** The maximum backlog observed by polling the queue. */
private int maxBacklog;
/** The total number of times the backlog has been polled. */
private long numPolls;
/** The total backlog observed from periodic polling. */
private long totalBacklog;
/** The traditional work queue instance with which this monitor is associated. */
private TraditionalWorkQueue workQueue;
/**
* Initializes this monitor provider. Note that no initialization should be
* done here, since it should be performed in the
* <CODE>initializeMonitorProvider</CODE> class.
*
* @param workQueue The work queue with which this monitor is associated.
*/
{
}
/** {@inheritDoc} */
{
maxBacklog = 0;
totalBacklog = 0;
numPolls = 0;
}
/**
* Retrieves the name of this monitor provider. It should be unique among all
* monitor providers, including all instances of the same monitor provider.
*
* @return The name of this monitor provider.
*/
public String getMonitorInstanceName()
{
return "Work Queue";
}
/** {@inheritDoc} */
public void run()
{
totalBacklog += backlog;
numPolls++;
if (backlog > maxBacklog)
{
}
}
/**
* Retrieves a set of attributes containing monitor data that should be
* returned to the client if the corresponding monitor entry is requested.
*
* @return A set of attributes containing monitor data that should be
* returned to the client if the corresponding monitor entry is
* requested.
*/
{
totalBacklog += backlog;
numPolls++;
if (backlog > maxBacklog)
{
}
// The total number of operations submitted.
// The total number of operations rejected due to a full work queue.
return monitorAttrs;
}
{
}
}