From 4299c8c37993ca97f28b2e731f6fd5ba1fb53943 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Mon, 07 Nov 2016 15:05:30 +0000
Subject: [PATCH] OPENDJ-3417 Move methods down to LocalBackend class and rename BackendMonitor to LocalBackendMonitor
---
opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java | 57 ++++++++++++++++++++--------
opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/server/monitors/LocalBackendMonitor.java | 4 +-
opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java | 55 +++------------------------
4 files changed, 50 insertions(+), 68 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
index 11a145c..034ffa6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/Backend.java
@@ -22,7 +22,6 @@
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.DN;
import org.opends.server.core.ServerContext;
-import org.opends.server.monitors.BackendMonitor;
import org.opends.server.types.InitializationException;
/**
@@ -36,9 +35,6 @@
//implements ReactiveHandler<LdapClientConnection, Request, Response>
{
- /** The backend monitor associated with this backend. */
- private BackendMonitor backendMonitor;
-
/** The unique identifier for this backend. */
private String backendID;
@@ -100,18 +96,6 @@
}
/**
- * Retrieves the backend monitor that is associated with this
- * backend.
- *
- * @return The backend monitor that is associated with this
- * backend, or {@code null} if none has been assigned.
- */
- public final BackendMonitor getBackendMonitor()
- {
- return backendMonitor;
- }
-
- /**
* Retrieves the set of base-level DNs that may be used within this
* backend.
*
@@ -121,6 +105,13 @@
public abstract Set<DN> getBaseDNs();
/**
+ * Indicates whether this backend should be considered a default (wild-card) route.
+ *
+ * @return {@code true} if the backend should be considered as the default route, {@code false} otherwise
+ */
+ public abstract boolean isDefaultRoute();
+
+ /**
* Retrieves the password storage schemes defined for this backend.
*
* @return the set of supported password storage schemes
@@ -175,13 +166,6 @@
}
/**
- * Indicates whether this backend should be considered a default (wild-card) route.
- *
- * @return {@code true} if the backend should be considered as the default route, {@code false} otherwise
- */
- public abstract boolean isDefaultRoute();
-
- /**
* Indicates whether this backend holds private data or user data.
*
* @return {@code true} if this backend holds private data, or
@@ -190,21 +174,6 @@
public abstract boolean isPrivateBackend();
/**
- * Indicates whether this backend supports the specified control.
- *
- * @param controlOID The OID of the control for which to make the
- * determination.
- *
- * @return {@code true} if this backends supports the control with
- * the specified OID, or {@code false} if it does not.
- */
- public final boolean supportsControl(String controlOID)
- {
- Set<String> supportedControls = getSupportedControls();
- return supportedControls != null && supportedControls.contains(controlOID);
- }
-
- /**
* Specifies the unique identifier for this backend.
*
* @param backendID The unique identifier for this backend.
@@ -214,14 +183,4 @@
this.backendID = backendID;
}
- /**
- * Sets the backend monitor for this backend.
- *
- * @param backendMonitor The backend monitor for this backend.
- */
- public final void setBackendMonitor(BackendMonitor backendMonitor)
- {
- this.backendMonitor = backendMonitor;
- }
-
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
index 9fc34f0..afe752c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/api/LocalBackend.java
@@ -46,6 +46,7 @@
import org.opends.server.core.PersistentSearch.CancellationCallback;
import org.opends.server.core.SearchOperation;
import org.opends.server.core.ServerContext;
+import org.opends.server.monitors.LocalBackendMonitor;
import org.opends.server.types.BackupConfig;
import org.opends.server.types.BackupDirectory;
import org.opends.server.types.CanceledOperationException;
@@ -95,23 +96,8 @@
/** The set of persistent searches registered with this backend. */
private final ConcurrentLinkedQueue<PersistentSearch> persistentSearches = new ConcurrentLinkedQueue<>();
- /**
- * Returns the provided backend instance as a LocalBackend.
- *
- * @param backend
- * A backend
- * @return a local backend
- * @throws IllegalArgumentException
- * If the provided backend is not a LocalBackend
- */
- public static LocalBackend<?> asLocalBackend(Backend<?> backend)
- {
- if (backend instanceof LocalBackend)
- {
- return (LocalBackend<?>) backend;
- }
- throw new IllegalArgumentException("Backend " + backend.getBackendID() + " is not a local backend");
- }
+ /** The backend monitor associated with this backend. */
+ private LocalBackendMonitor backendMonitor;
/**
* Opens this backend based on the information provided when the backend was configured.
@@ -848,6 +834,43 @@
}
/**
+ * Retrieves the backend monitor that is associated with this
+ * backend.
+ *
+ * @return The backend monitor that is associated with this
+ * backend, or {@code null} if none has been assigned.
+ */
+ public final LocalBackendMonitor getBackendMonitor()
+ {
+ return backendMonitor;
+ }
+
+ /**
+ * Sets the backend monitor for this backend.
+ *
+ * @param backendMonitor The backend monitor for this backend.
+ */
+ public final void setBackendMonitor(LocalBackendMonitor backendMonitor)
+ {
+ this.backendMonitor = backendMonitor;
+ }
+
+ /**
+ * Indicates whether this backend supports the specified control.
+ *
+ * @param controlOID The OID of the control for which to make the
+ * determination.
+ *
+ * @return {@code true} if this backends supports the control with
+ * the specified OID, or {@code false} if it does not.
+ */
+ public final boolean supportsControl(String controlOID)
+ {
+ Set<String> supportedControls = getSupportedControls();
+ return supportedControls != null && supportedControls.contains(controlOID);
+ }
+
+ /**
* Indicates whether a backend should be used to handle operations
* for the provided entry given the set of base DNs and exclude DNs.
*
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/monitors/BackendMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/monitors/LocalBackendMonitor.java
similarity index 97%
rename from opendj-server-legacy/src/main/java/org/opends/server/monitors/BackendMonitor.java
rename to opendj-server-legacy/src/main/java/org/opends/server/monitors/LocalBackendMonitor.java
index 10e0220..cbcc589 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/monitors/BackendMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/monitors/LocalBackendMonitor.java
@@ -36,7 +36,7 @@
* for an enabled Directory Server backend, including its backend ID, base DNs,
* writability mode, and the number of entries it contains.
*/
-public class BackendMonitor
+public class LocalBackendMonitor
extends MonitorProvider<MonitorProviderCfg>
{
/** The backend with which this monitor is associated. */
@@ -53,7 +53,7 @@
*
* @param backend The backend with which this monitor is associated.
*/
- public BackendMonitor(LocalBackend<?> backend)
+ public LocalBackendMonitor(LocalBackend<?> backend)
{
this.backend = backend;
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
index 47615d9..316a4db 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/monitors/BackendMonitorTestCase.java
@@ -20,7 +20,7 @@
import org.opends.server.core.DirectoryServer;
import org.testng.annotations.Test;
-/** This class defines a set of tests for the {@link BackendMonitor} class. */
+/** This class defines a set of tests for the {@link LocalBackendMonitor} class. */
@Test
public class BackendMonitorTestCase extends GenericMonitorTestCase
{
--
Gitblit v1.10.0