From a89f7014aeb71dba5c94404dfea7eb89e7eeee74 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 08 Jul 2015 06:48:02 +0000
Subject: [PATCH] AutoRefactor'ed Use Diamond Operator
---
opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java | 66 +++++++--------------------------
1 files changed, 14 insertions(+), 52 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
index 96cd9f2..e72e0a9 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/ParallelWorkQueueMonitor.java
@@ -26,25 +26,20 @@
*/
package org.opends.server.monitors;
-
+import static org.opends.server.core.DirectoryServer.*;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import org.opends.server.admin.std.server.MonitorProviderCfg;
-import org.forgerock.opendj.ldap.schema.Syntax;
import org.opends.server.api.MonitorProvider;
import org.forgerock.opendj.config.server.ConfigException;
-import org.opends.server.core.DirectoryServer;
import org.opends.server.extensions.ParallelWorkQueue;
import org.opends.server.types.Attribute;
import org.opends.server.types.AttributeType;
import org.opends.server.types.Attributes;
import org.opends.server.types.InitializationException;
-
-
-
/**
* This class defines a Directory Server monitor that can be used to provide
* information about the state of the work queue.
@@ -53,30 +48,15 @@
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 current request backlog. */
public static final String ATTR_CURRENT_BACKLOG = "currentRequestBacklog";
-
-
-
- /**
- * 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 average request backlog. */
public static final String ATTR_AVERAGE_BACKLOG = "averageRequestBacklog";
-
-
-
/**
* The name to use for the monitor attribute that provides the maximum
* observed request backlog.
*/
public static final String ATTR_MAX_BACKLOG = "maxRequestBacklog";
-
-
-
/**
* The name to use for the monitor attribute that provides the total number of
* operations submitted.
@@ -84,7 +64,6 @@
public static final String ATTR_OPS_SUBMITTED = "requestsSubmitted";
-
/** The maximum backlog observed by polling the queue. */
private int maxBacklog;
@@ -97,8 +76,6 @@
/** The parallel work queue instance with which this monitor is associated. */
private ParallelWorkQueue workQueue;
-
-
/**
* Initializes this monitor provider. Note that no initialization should be
* done here, since it should be performed in the
@@ -175,36 +152,21 @@
}
long averageBacklog = (long) (1.0 * totalBacklog / numPolls);
-
long opsSubmitted = workQueue.getOpsSubmitted();
- ArrayList<Attribute> monitorAttrs = new ArrayList<Attribute>();
- Syntax integerSyntax = DirectoryServer.getDefaultIntegerSyntax();
-
- // The current backlog.
- AttributeType attrType = DirectoryServer.getDefaultAttributeType(
- ATTR_CURRENT_BACKLOG, integerSyntax);
- monitorAttrs
- .add(Attributes.create(attrType, String.valueOf(backlog)));
-
- // The average backlog.
- attrType = DirectoryServer.getDefaultAttributeType(ATTR_AVERAGE_BACKLOG,
- integerSyntax);
- monitorAttrs.add(Attributes.create(attrType, String
- .valueOf(averageBacklog)));
-
- // The maximum backlog.
- attrType = DirectoryServer.getDefaultAttributeType(ATTR_MAX_BACKLOG,
- integerSyntax);
- monitorAttrs.add(Attributes.create(attrType, String
- .valueOf(maxBacklog)));
-
+ ArrayList<Attribute> monitorAttrs = new ArrayList<>();
+ putAttribute(monitorAttrs, ATTR_CURRENT_BACKLOG, backlog);
+ putAttribute(monitorAttrs, ATTR_AVERAGE_BACKLOG, averageBacklog);
+ putAttribute(monitorAttrs, ATTR_MAX_BACKLOG, maxBacklog);
// The total number of operations submitted.
- attrType = DirectoryServer.getDefaultAttributeType(ATTR_OPS_SUBMITTED,
- integerSyntax);
- monitorAttrs.add(Attributes.create(attrType, String
- .valueOf(opsSubmitted)));
+ putAttribute(monitorAttrs, ATTR_OPS_SUBMITTED, opsSubmitted);
return monitorAttrs;
}
+
+ private void putAttribute(ArrayList<Attribute> monitorAttrs, String attrName, Object value)
+ {
+ AttributeType attrType = getDefaultAttributeType(attrName, getDefaultIntegerSyntax());
+ monitorAttrs.add(Attributes.create(attrType, String.valueOf(value)));
+ }
}
--
Gitblit v1.10.0