From cf3a52a7591faffc24a890b5baebfd260b929fcd Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Fri, 08 Jun 2007 18:50:35 +0000
Subject: [PATCH] Fixed an issue where the error log doesn't actually log messages. Also improved the performance of the loggers when they are disabled.
---
opendj-sdk/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java | 16 +
opendj-sdk/opends/src/server/org/opends/server/api/AccessLogPublisher.java | 15
opendj-sdk/opends/src/server/org/opends/server/api/ErrorLogPublisher.java | 10
opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java | 12
opendj-sdk/opends/src/server/org/opends/server/api/DebugLogPublisher.java | 12
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml | 2
opendj-sdk/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java | 53 ++-
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml | 2
opendj-sdk/opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java | 11
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml | 2
opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java | 86 +++++--
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java | 9
opendj-sdk/opends/src/server/org/opends/server/util/ServerConstants.java | 76 +++---
opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java | 12
opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java | 8
opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java | 12
opendj-sdk/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java | 15 +
opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java | 143 +++++++----
opendj-sdk/opends/build.xml | 2
opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java | 54 +--
opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java | 12
opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java | 31 +-
opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java | 12
opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ErrorLogPublisherConfiguration.xml | 2
opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java | 12
opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java | 77 ++++-
opendj-sdk/opends/resource/schema/02-config.ldif | 6
opendj-sdk/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java | 15 +
28 files changed, 449 insertions(+), 270 deletions(-)
diff --git a/opendj-sdk/opends/build.xml b/opendj-sdk/opends/build.xml
index 8f60222..65f2afc 100644
--- a/opendj-sdk/opends/build.xml
+++ b/opendj-sdk/opends/build.xml
@@ -1250,7 +1250,7 @@
<!-- This sets org.opends.test.debug.target if and only if its's not
alreadly set. -->
<condition property="org.opends.test.debug.target"
- value="org.opends.server:level=warning,category=caught|data|database-access|message|protocol">
+ value="org.opends.server:level=warning,category=caught|data|database_access|message|protocol">
<not>
<isset property="org.opends.test.debug.target" />
</not>
diff --git a/opendj-sdk/opends/resource/schema/02-config.ldif b/opendj-sdk/opends/resource/schema/02-config.ldif
index 4cb3c58..21bb051 100644
--- a/opendj-sdk/opends/resource/schema/02-config.ldif
+++ b/opendj-sdk/opends/resource/schema/02-config.ldif
@@ -1417,7 +1417,7 @@
MAY ( ds-cfg-rotation-policy-dn $
ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $
ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $
- ds-cfg-writer-append )
+ ds-cfg-writer-append $ ds-cfg-log-queue-size )
X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.27
NAME 'ds-cfg-file-based-debug-logger' SUP ds-cfg-debug-logger STRUCTURAL
@@ -1425,7 +1425,7 @@
MAY ( ds-cfg-rotation-policy-dn $
ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $
ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $
- ds-cfg-writer-append )
+ ds-cfg-writer-append $ ds-cfg-log-queue-size )
X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.28
NAME 'ds-cfg-file-based-error-logger' SUP ds-cfg-error-logger STRUCTURAL
@@ -1433,7 +1433,7 @@
MAY ( ds-cfg-rotation-policy-dn $
ds-cfg-rotation-action $ ds-cfg-retention-policy-dn $
ds-cfg-thread-time-interval $ ds-cfg-buffer-size $ ds-cfg-writer-auto-flush $
- ds-cfg-writer-append )
+ ds-cfg-writer-append $ ds-cfg-log-queue-size )
X-ORIGIN 'OpenDS Directory Server' )
objectClasses: ( 1.3.6.1.4.1.26027.1.2.29 NAME 'ds-cfg-matching-rule'
SUP top STRUCTURAL MUST ( cn $ ds-cfg-matching-rule-class $
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ErrorLogPublisherConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ErrorLogPublisherConfiguration.xml
index 72dbd8b..e4548ec 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ErrorLogPublisherConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/ErrorLogPublisherConfiguration.xml
@@ -64,7 +64,7 @@
to shut down or operate in a significantly degraded state.
</adm:synopsis>
</adm:value>
- <adm:value name="informational">
+ <adm:value name="info">
<adm:synopsis>
The error log severity that will be used for messages that
provide information about significant events within the server
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml
index 0b550b5..6382aa7 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedAccessLogPublisherConfiguration.xml
@@ -58,7 +58,7 @@
<adm:profile name="ldap">
<ldap:attribute>
<ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid>
- <ldap:name>dscfg-log-queue-size</ldap:name>
+ <ldap:name>ds-cfg-log-queue-size</ldap:name>
</ldap:attribute>
</adm:profile>
</adm:property>
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml
index ffd3bbf..ec54cbf 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedDebugLogPublisherConfiguration.xml
@@ -58,7 +58,7 @@
<adm:profile name="ldap">
<ldap:attribute>
<ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid>
- <ldap:name>dscfg-log-queue-size</ldap:name>
+ <ldap:name>ds-cfg-log-queue-size</ldap:name>
</ldap:attribute>
</adm:profile>
</adm:property>
diff --git a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml
index 9f573c0..b4f720d 100644
--- a/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml
+++ b/opendj-sdk/opends/src/admin/defn/org/opends/server/admin/std/FileBasedErrorLogPublisherConfiguration.xml
@@ -58,7 +58,7 @@
<adm:profile name="ldap">
<ldap:attribute>
<ldap:oid>1.3.6.1.4.1.26027.1.1.378</ldap:oid>
- <ldap:name>dscfg-log-queue-size</ldap:name>
+ <ldap:name>ds-cfg-log-queue-size</ldap:name>
</ldap:attribute>
</adm:profile>
</adm:property>
diff --git a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
index 7bfe1c9..6863f20 100644
--- a/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
+++ b/opendj-sdk/opends/src/quicksetup/org/opends/quicksetup/util/InProcessServerController.java
@@ -36,7 +36,6 @@
import org.opends.server.loggers.ErrorLogger;
import org.opends.server.loggers.TextAccessLogPublisher;
import org.opends.server.loggers.AccessLogger;
-import org.opends.server.types.DN;
import org.opends.server.types.Modification;
import org.opends.server.types.ResultCode;
import org.opends.server.types.LDIFImportConfig;
@@ -83,6 +82,12 @@
*/
static private boolean serverHasBeenStarted = false;
+ static private ErrorLogPublisher startupErrorPublisher;
+
+ static private AccessLogPublisher startupAccessPublisher;
+
+ static private DebugLogPublisher startupDebugPublisher;
+
/**
* Pushes messages published by the server loggers into OperationOutput.
*/
@@ -486,24 +491,18 @@
static private void registerListenersForOuput() {
try {
- DebugLogPublisher startupDebugPublisher =
+ startupDebugPublisher =
TextDebugLogPublisher.getStartupTextDebugPublisher(debugWriter);
- DebugLogger.addDebugLogPublisher(
- DN.decode("cn=QuickSetup,cn=Loggers,cn=config"),
- startupDebugPublisher);
+ DebugLogger.addDebugLogPublisher(startupDebugPublisher);
- ErrorLogPublisher startupErrorPublisher =
+ startupErrorPublisher =
TextErrorLogPublisher.getStartupTextErrorPublisher(errorWriter);
- ErrorLogger.addErrorLogPublisher(
- DN.decode("cn=QuickSetup,cn=Loggers,cn=config"),
- startupErrorPublisher);
+ ErrorLogger.addErrorLogPublisher(startupErrorPublisher);
- AccessLogPublisher startupAccessPublisher =
+ startupAccessPublisher =
TextAccessLogPublisher.getStartupTextAccessPublisher(
accessWriter, true);
- AccessLogger.addAccessLogPublisher(
- DN.decode("cn=QuickSetup,cn=Loggers,cn=config"),
- startupAccessPublisher);
+ AccessLogger.addAccessLogPublisher(startupAccessPublisher);
} catch (Exception e) {
LOG.log(Level.INFO, "Error installing test log publishers: " +
@@ -511,6 +510,12 @@
}
}
+ static private void unregisterListenersForOutput() {
+ DebugLogger.removeDebugLogPublisher(startupDebugPublisher);
+ ErrorLogger.removeErrorLogPublisher(startupErrorPublisher);
+ AccessLogger.removeAccessLogPublisher(startupAccessPublisher);
+ }
+
static private String getMsg(String key, String... args) {
return ResourceProvider.getInstance().getMsg(key, args);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/AccessLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/api/AccessLogPublisher.java
index 3c52ed1..f5925b5 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/AccessLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/AccessLogPublisher.java
@@ -31,11 +31,7 @@
import org.opends.server.admin.std.server.AccessLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.core.*;
-import org.opends.server.types.InitializationException;
-import org.opends.server.types.DisconnectReason;
-import org.opends.server.types.SearchResultEntry;
-import org.opends.server.types.SearchResultReference;
-
+import org.opends.server.types.*;
/**
@@ -388,5 +384,14 @@
* request.
*/
public abstract void logUnbind(UnbindOperation unbindOperation);
+
+ /**
+ * Gets the DN of the configuration entry for this access log
+ * publisher.
+ *
+ * @return The configuration entry DN.
+ */
+ public abstract DN getDN();
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/DebugLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/api/DebugLogPublisher.java
index 13e1082..d544c95 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/DebugLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/DebugLogPublisher.java
@@ -43,7 +43,7 @@
import org.opends.server.loggers.debug.TraceSettings;
import org.opends.server.types.DebugLogLevel;
import org.opends.server.types.InitializationException;
-
+import org.opends.server.types.DN;
/**
@@ -564,11 +564,17 @@
ProtocolElement element,
StackTraceElement[] stackTrace);
-
-
/**
* Close this publisher.
*/
public abstract void close();
+
+ /**
+ * Gets the DN of the configuration entry for this debug log
+ * publisher.
+ *
+ * @return The configuration entry DN.
+ */
+ public abstract DN getDN();
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/api/ErrorLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/api/ErrorLogPublisher.java
index 0199a1f..17840df 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/api/ErrorLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/api/ErrorLogPublisher.java
@@ -36,7 +36,7 @@
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
-
+import org.opends.server.types.DN;
/**
@@ -114,5 +114,13 @@
ErrorLogSeverity severity,
String message, int errorID);
+ /**
+ * Gets the DN of the configuration entry for this error log
+ * publisher.
+ *
+ * @return The configuration entry DN.
+ */
+ public abstract DN getDN();
+
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
index ae89e98..79e378c 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -762,12 +762,12 @@
startupErrorLogPublisher =
TextErrorLogPublisher.getStartupTextErrorPublisher(
new TextWriter.STDOUT());
- addErrorLogPublisher(DN.NULL_DN, startupErrorLogPublisher);
+ addErrorLogPublisher(startupErrorLogPublisher);
startupDebugLogPublisher =
TextDebugLogPublisher.getStartupTextDebugPublisher(
new TextWriter.STDOUT());
- addDebugLogPublisher(DN.NULL_DN, startupDebugLogPublisher);
+ addDebugLogPublisher(startupDebugLogPublisher);
// Create the MBean server that we will use for JMX interaction.
initializeJMX();
@@ -1193,8 +1193,8 @@
sendAlertNotification(this, ALERT_TYPE_SERVER_STARTED, msgID, message);
- removeDebugLogPublisher(DN.NULL_DN);
- removeErrorLogPublisher(DN.NULL_DN);
+ removeDebugLogPublisher(startupDebugLogPublisher);
+ removeErrorLogPublisher(startupErrorLogPublisher);
// If a server.starting file exists, then remove it.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
index 4c33238..390d771 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/AccessLogger.java
@@ -28,7 +28,7 @@
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.List;
import java.util.ArrayList;
import java.lang.reflect.Method;
@@ -71,8 +71,8 @@
// The set of access loggers that have been registered with the server. It
// will initially be empty.
- static ConcurrentHashMap<DN, AccessLogPublisher> accessPublishers =
- new ConcurrentHashMap<DN, AccessLogPublisher>();
+ static CopyOnWriteArrayList<AccessLogPublisher> accessPublishers =
+ new CopyOnWriteArrayList<AccessLogPublisher>();
// The singleton instance of this class for configuration purposes.
static final AccessLogger instance = new AccessLogger();
@@ -91,30 +91,31 @@
/**
* Add an access log publisher to the access logger.
*
- * @param dn The DN of the configuration entry for the publisher.
* @param publisher The access log publisher to add.
*/
- public synchronized static void addAccessLogPublisher(DN dn,
- AccessLogPublisher publisher)
+ public synchronized static void addAccessLogPublisher(
+ AccessLogPublisher publisher)
{
- accessPublishers.put(dn, publisher);
+ accessPublishers.add(publisher);
}
/**
* Remove an access log publisher from the access logger.
*
- * @param dn The DN of the publisher to remove.
+ * @param publisher The access log publisher to remove.
* @return The publisher that was removed or null if it was not found.
*/
- public synchronized static AccessLogPublisher removeAccessLogPublisher(DN dn)
+ public synchronized static boolean removeAccessLogPublisher(
+ AccessLogPublisher publisher)
{
- AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn);
- if(AccessLogPublisher != null)
+ boolean removed = accessPublishers.remove(publisher);
+
+ if(removed)
{
- AccessLogPublisher.close();
+ publisher.close();
}
- return AccessLogPublisher;
+ return removed;
}
/**
@@ -122,7 +123,7 @@
*/
public synchronized static void removeAllAccessLogPublishers()
{
- for(AccessLogPublisher publisher : accessPublishers.values())
+ for(AccessLogPublisher publisher : accessPublishers)
{
publisher.close();
}
@@ -153,7 +154,7 @@
{
AccessLogPublisher AccessLogPublisher = getAccessPublisher(config);
- addAccessLogPublisher(config.dn(), AccessLogPublisher);
+ addAccessLogPublisher(AccessLogPublisher);
}
}
}
@@ -196,7 +197,7 @@
{
AccessLogPublisher AccessLogPublisher = getAccessPublisher(config);
- addAccessLogPublisher(config.dn(), AccessLogPublisher);
+ addAccessLogPublisher(AccessLogPublisher);
}
catch(ConfigException e)
{
@@ -234,9 +235,18 @@
ArrayList<String> messages = new ArrayList<String>();
DN dn = config.dn();
- AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn);
- if(AccessLogPublisher == null)
+ AccessLogPublisher accessLogPublisher = null;
+ for(AccessLogPublisher publisher : accessPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ accessLogPublisher = publisher;
+ break;
+ }
+ }
+
+ if(accessLogPublisher == null)
{
if(config.isEnabled())
{
@@ -254,7 +264,7 @@
// indicate that administrative action is required for that
// change to take effect.
String className = config.getJavaImplementationClass();
- if(!className.equals(AccessLogPublisher.getClass().getName()))
+ if(!className.equals(accessLogPublisher.getClass().getName()))
{
adminActionRequired = true;
}
@@ -262,7 +272,7 @@
else
{
// The publisher is being disabled so shut down and remove.
- removeAccessLogPublisher(config.dn());
+ removeAccessLogPublisher(accessLogPublisher);
}
}
@@ -276,8 +286,18 @@
List<String> unacceptableReasons)
{
DN dn = config.dn();
- AccessLogPublisher AccessLogPublisher = accessPublishers.get(dn);
- return AccessLogPublisher != null;
+
+ AccessLogPublisher accessLogPublisher = null;
+ for(AccessLogPublisher publisher : accessPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ accessLogPublisher = publisher;
+ break;
+ }
+ }
+
+ return accessLogPublisher != null;
}
@@ -285,16 +305,33 @@
* {@inheritDoc}
*/
public ConfigChangeResult applyConfigurationDelete(
- AccessLogPublisherCfg config)
- {
- // Default result code.
- ResultCode resultCode = ResultCode.SUCCESS;
- boolean adminActionRequired = false;
+ AccessLogPublisherCfg config)
+ {
+ // Default result code.
+ ResultCode resultCode = ResultCode.SUCCESS;
+ boolean adminActionRequired = false;
- removeAccessLogPublisher(config.dn());
+ AccessLogPublisher accessLogPublisher = null;
+ for(AccessLogPublisher publisher : accessPublishers)
+ {
+ if(publisher.getDN().equals(config.dn()))
+ {
+ accessLogPublisher = publisher;
+ break;
+ }
+ }
- return new ConfigChangeResult(resultCode, adminActionRequired);
- }
+ if(accessLogPublisher != null)
+ {
+ removeAccessLogPublisher(accessLogPublisher);
+ }
+ else
+ {
+ resultCode = ResultCode.NO_SUCH_OBJECT;
+ }
+
+ return new ConfigChangeResult(resultCode, adminActionRequired);
+ }
private boolean isJavaClassAcceptable(AccessLogPublisherCfg config,
List<String> unacceptableReasons)
@@ -390,7 +427,7 @@
*/
public static void logConnect(ClientConnection clientConnection)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logConnect(clientConnection);
}
@@ -412,7 +449,7 @@
DisconnectReason disconnectReason,
String message)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logDisconnect(clientConnection, disconnectReason, message);
}
@@ -428,7 +465,7 @@
*/
public static void logAbandonRequest(AbandonOperation abandonOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logAbandonRequest(abandonOperation);
}
@@ -445,7 +482,7 @@
*/
public static void logAbandonResult(AbandonOperation abandonOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logAbandonResult(abandonOperation);
}
@@ -462,7 +499,7 @@
*/
public static void logAddRequest(AddOperation addOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logAddRequest(addOperation);
}
@@ -479,7 +516,7 @@
*/
public static void logAddResponse(AddOperation addOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logAddResponse(addOperation);
}
@@ -496,7 +533,7 @@
*/
public static void logBindRequest(BindOperation bindOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logBindRequest(bindOperation);
}
@@ -513,7 +550,7 @@
*/
public static void logBindResponse(BindOperation bindOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logBindResponse(bindOperation);
}
@@ -530,7 +567,7 @@
*/
public static void logCompareRequest(CompareOperation compareOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logCompareRequest(compareOperation);
}
@@ -547,7 +584,7 @@
*/
public static void logCompareResponse(CompareOperation compareOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logCompareResponse(compareOperation);
}
@@ -564,7 +601,7 @@
*/
public static void logDeleteRequest(DeleteOperation deleteOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logDeleteRequest(deleteOperation);
}
@@ -581,7 +618,7 @@
*/
public static void logDeleteResponse(DeleteOperation deleteOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logDeleteResponse(deleteOperation);
}
@@ -598,7 +635,7 @@
*/
public static void logExtendedRequest(ExtendedOperation extendedOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logExtendedRequest(extendedOperation);
}
@@ -615,7 +652,7 @@
*/
public static void logExtendedResponse(ExtendedOperation extendedOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logExtendedResponse(extendedOperation);
}
@@ -632,7 +669,7 @@
*/
public static void logModifyRequest(ModifyOperation modifyOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logModifyRequest(modifyOperation);
}
@@ -649,7 +686,7 @@
*/
public static void logModifyResponse(ModifyOperation modifyOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logModifyResponse(modifyOperation);
}
@@ -666,7 +703,7 @@
*/
public static void logModifyDNRequest(ModifyDNOperation modifyDNOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logModifyDNRequest(modifyDNOperation);
}
@@ -684,7 +721,7 @@
*/
public static void logModifyDNResponse(ModifyDNOperation modifyDNOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logModifyDNResponse(modifyDNOperation);
}
@@ -701,7 +738,7 @@
*/
public static void logSearchRequest(SearchOperation searchOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logSearchRequest(searchOperation);
}
@@ -721,7 +758,7 @@
public static void logSearchResultEntry(SearchOperation searchOperation,
SearchResultEntry searchEntry)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logSearchResultEntry(searchOperation, searchEntry);
}
@@ -740,7 +777,7 @@
public static void logSearchResultReference(SearchOperation searchOperation,
SearchResultReference searchReference)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logSearchResultReference(searchOperation, searchReference);
}
@@ -757,7 +794,7 @@
*/
public static void logSearchResultDone(SearchOperation searchOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logSearchResultDone(searchOperation);
}
@@ -774,7 +811,7 @@
*/
public static void logUnbind(UnbindOperation unbindOperation)
{
- for (AccessLogPublisher publisher : accessPublishers.values())
+ for (AccessLogPublisher publisher : accessPublishers)
{
publisher.logUnbind(unbindOperation);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
index a294791..a0e4a5d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/AsyncronousTextWriter.java
@@ -32,6 +32,7 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
/**
* A Text Writer which writes log records asynchronously to
@@ -49,7 +50,7 @@
private final LinkedBlockingQueue<String> queue;
private String name;
- private boolean stopRequested;
+ private AtomicBoolean stopRequested;
private WriterThread writerThread;
private boolean autoFlush;
@@ -72,7 +73,7 @@
this.queue = new LinkedBlockingQueue<String>(capacity);
this.writerThread = null;
- this.stopRequested = false;
+ this.stopRequested = new AtomicBoolean(false);
writerThread = new WriterThread();
writerThread.start();
@@ -97,7 +98,7 @@
public void run()
{
String message = null;
- while (!isShuttingDown() || !queue.isEmpty()) {
+ while (!stopRequested.get() || !queue.isEmpty()) {
try
{
message = queue.poll(10, TimeUnit.SECONDS);
@@ -124,28 +125,6 @@
}
}
- // Method needs to be synchronized with _shutdown mutator, as we don't
- // want shutdown to start after we check for it, but before we queue
- // request.
- private synchronized void writeAsynchronously(String record)
- {
- // If shutting down reject, otherwise publish (if we have a publisher!)
- while (!isShuttingDown())
- {
- // Put request on queue for writer
- try
- {
- queue.put(record);
- break;
- }
- catch(InterruptedException e)
- {
- // We expect this to happen. Just ignore it and hopefully
- // drop out in the next try.
- }
- }
- }
-
/**
* Write the log record asyncronously.
*
@@ -155,7 +134,20 @@
{
// No writer? Off to the bit bucket.
if (writer != null) {
- writeAsynchronously(record);
+ while (!stopRequested.get())
+ {
+ // Put request on queue for writer
+ try
+ {
+ queue.put(record);
+ break;
+ }
+ catch(InterruptedException e)
+ {
+ // We expect this to happen. Just ignore it and hopefully
+ // drop out in the next try.
+ }
+ }
}
}
@@ -205,14 +197,6 @@
}
/**
- * Queries whether the publisher is in shutdown mode.
- */
- private boolean isShuttingDown()
- {
- return stopRequested;
- }
-
- /**
* {@inheritDoc}
*/
public void shutdown()
@@ -227,7 +211,7 @@
*/
public void shutdown(boolean shutdownWrapped)
{
- stopRequested = true;
+ stopRequested.set(true);
// Wait for publisher thread to terminate
while (writerThread != null && writerThread.isAlive()) {
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java
index 4d2fd39..78f0110 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/ErrorLogger.java
@@ -28,7 +28,7 @@
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.List;
import java.util.ArrayList;
import java.lang.reflect.Method;
@@ -69,8 +69,8 @@
// The set of error loggers that have been registered with the server. It
// will initially be empty.
- private static ConcurrentHashMap<DN, ErrorLogPublisher> errorPublishers =
- new ConcurrentHashMap<DN, ErrorLogPublisher>();
+ private static CopyOnWriteArrayList<ErrorLogPublisher> errorPublishers =
+ new CopyOnWriteArrayList<ErrorLogPublisher>();
// The singleton instance of this class for configuration purposes.
private static final ErrorLogger instance = new ErrorLogger();
@@ -88,30 +88,31 @@
/**
* Add an error log publisher to the error logger.
*
- * @param dn The DN of the configuration entry for the publisher.
* @param publisher The error log publisher to add.
*/
- public synchronized static void addErrorLogPublisher(DN dn,
- ErrorLogPublisher publisher)
+ public synchronized static void addErrorLogPublisher(
+ ErrorLogPublisher publisher)
{
- errorPublishers.put(dn, publisher);
+ errorPublishers.add(publisher);
}
/**
* Remove an error log publisher from the error logger.
*
- * @param dn The DN of the publisher to remove.
- * @return The publisher that was removed or null if it was not found.
+ * @param publisher The error log publisher to remove.
+ * @return True if the error log publisher is removed or false otherwise.
*/
- public synchronized static ErrorLogPublisher removeErrorLogPublisher(DN dn)
+ public synchronized static boolean removeErrorLogPublisher(
+ ErrorLogPublisher publisher)
{
- ErrorLogPublisher errorLogPublisher = errorPublishers.remove(dn);
- if(errorLogPublisher != null)
+ boolean removed = errorPublishers.remove(publisher);
+
+ if(removed)
{
- errorLogPublisher.close();
+ publisher.close();
}
- return errorLogPublisher;
+ return removed;
}
/**
@@ -119,7 +120,7 @@
*/
public synchronized static void removeAllErrorLogPublishers()
{
- for(ErrorLogPublisher publisher : errorPublishers.values())
+ for(ErrorLogPublisher publisher : errorPublishers)
{
publisher.close();
}
@@ -150,7 +151,7 @@
{
ErrorLogPublisher errorLogPublisher = getErrorPublisher(config);
- addErrorLogPublisher(config.dn(), errorLogPublisher);
+ addErrorLogPublisher(errorLogPublisher);
}
}
}
@@ -193,7 +194,7 @@
{
ErrorLogPublisher errorLogPublisher = getErrorPublisher(config);
- addErrorLogPublisher(config.dn(), errorLogPublisher);
+ addErrorLogPublisher(errorLogPublisher);
}
catch(ConfigException e)
{
@@ -231,7 +232,16 @@
ArrayList<String> messages = new ArrayList<String>();
DN dn = config.dn();
- ErrorLogPublisher errorLogPublisher = errorPublishers.get(dn);
+
+ ErrorLogPublisher errorLogPublisher = null;
+ for(ErrorLogPublisher publisher : errorPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ errorLogPublisher = publisher;
+ break;
+ }
+ }
if(errorLogPublisher == null)
{
@@ -259,7 +269,7 @@
else
{
// The publisher is being disabled so shut down and remove.
- removeErrorLogPublisher(config.dn());
+ removeErrorLogPublisher(errorLogPublisher);
}
}
@@ -273,9 +283,18 @@
List<String> unacceptableReasons)
{
DN dn = config.dn();
- ErrorLogPublisher errorLogPublisher = errorPublishers.get(dn);
- return errorLogPublisher != null;
+ ErrorLogPublisher errorLogPublisher = null;
+ for(ErrorLogPublisher publisher : errorPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ errorLogPublisher = publisher;
+ break;
+ }
+ }
+
+ return errorLogPublisher != null;
}
/**
@@ -288,7 +307,24 @@
ResultCode resultCode = ResultCode.SUCCESS;
boolean adminActionRequired = false;
- removeErrorLogPublisher(config.dn());
+ ErrorLogPublisher errorLogPublisher = null;
+ for(ErrorLogPublisher publisher : errorPublishers)
+ {
+ if(publisher.getDN().equals(config.dn()))
+ {
+ errorLogPublisher = publisher;
+ break;
+ }
+ }
+
+ if(errorLogPublisher != null)
+ {
+ removeErrorLogPublisher(errorLogPublisher);
+ }
+ else
+ {
+ resultCode = ResultCode.NO_SUCH_OBJECT;
+ }
return new ConfigChangeResult(resultCode, adminActionRequired);
}
@@ -392,7 +428,7 @@
{
String message = MessageHandler.getMessage(errorID);
- for (ErrorLogPublisher publisher : errorPublishers.values())
+ for (ErrorLogPublisher publisher : errorPublishers)
{
publisher.logError(category, severity, message, errorID);
}
@@ -418,7 +454,7 @@
{
String message = MessageHandler.getMessage(errorID, args);
- for (ErrorLogPublisher publisher : errorPublishers.values())
+ for (ErrorLogPublisher publisher : errorPublishers)
{
publisher.logError(category, severity, message, errorID);
}
@@ -441,7 +477,7 @@
ErrorLogSeverity severity, String message,
int errorID)
{
- for (ErrorLogPublisher publisher : errorPublishers.values())
+ for (ErrorLogPublisher publisher : errorPublishers)
{
publisher.logError(category, severity, message, errorID);
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
index 3169ae4..02e6295 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAccessLogPublisher.java
@@ -1400,5 +1400,20 @@
writer.writeRecord(buffer.toString());
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public DN getDN()
+ {
+ if(currentConfig != null)
+ {
+ return currentConfig.dn();
+ }
+ else
+ {
+ return null;
+ }
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
index 612944f..aa85bab 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextAuditLogPublisher.java
@@ -819,16 +819,16 @@
*/
private void encodeValue(ByteString str, StringBuilder buffer)
{
- byte[] byteVal = str.value();
- if(StaticUtils.needsBase64Encoding(byteVal))
- {
- buffer.append(": ");
- buffer.append(Base64.encode(byteVal));
- } else
- {
- buffer.append(" ");
- str.toString(buffer);
- }
+ byte[] byteVal = str.value();
+ if(StaticUtils.needsBase64Encoding(byteVal))
+ {
+ buffer.append(": ");
+ buffer.append(Base64.encode(byteVal));
+ } else
+ {
+ buffer.append(" ");
+ str.toString(buffer);
+ }
}
@@ -841,15 +841,30 @@
*/
private void encodeValue(String str, StringBuilder buffer)
{
- if(StaticUtils.needsBase64Encoding(str))
- {
- buffer.append(": ");
- buffer.append(Base64.encode(getBytes(str)));
- } else
- {
- buffer.append(" ");
- buffer.append(str);
- }
+ if(StaticUtils.needsBase64Encoding(str))
+ {
+ buffer.append(": ");
+ buffer.append(Base64.encode(getBytes(str)));
+ } else
+ {
+ buffer.append(" ");
+ buffer.append(str);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public DN getDN()
+ {
+ if(currentConfig != null)
+ {
+ return currentConfig.dn();
+ }
+ else
+ {
+ return null;
+ }
}
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
index 2680065..68ec379 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/TextErrorLogPublisher.java
@@ -640,9 +640,23 @@
append(" msgID=").append(String.valueOf(errorID)).
append(" msg=").append(message);
- // FIXME - lookup the level based on the severity
writer.writeRecord(sb.toString());
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public DN getDN()
+ {
+ if(currentConfig != null)
+ {
+ return currentConfig.dn();
+ }
+ else
+ {
+ return null;
+ }
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java
index 9b3ee28..0608ba2 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/ThreadFilterTextErrorLogPublisher.java
@@ -29,6 +29,7 @@
import org.opends.server.types.ErrorLogCategory;
import org.opends.server.types.ErrorLogSeverity;
import org.opends.server.types.InitializationException;
+import org.opends.server.types.DN;
import org.opends.server.admin.std.server.ErrorLogPublisherCfg;
import org.opends.server.config.ConfigException;
import org.opends.server.api.ErrorLogPublisher;
@@ -98,4 +99,14 @@
this.writer.writeRecord(sb.toString());
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public DN getDN()
+ {
+ // This class should only be used internally in the server and not be
+ // configurable via the admin framework.
+ return null;
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
index 4f1d514..1d45247 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/DebugLogger.java
@@ -28,6 +28,7 @@
package org.opends.server.loggers.debug;
import java.util.*;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ConcurrentHashMap;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
@@ -81,10 +82,8 @@
// The set of debug loggers that have been registered with the server. It
// will initially be empty.
- private static ConcurrentHashMap<DN,
- DebugLogPublisher> debugPublishers =
- new ConcurrentHashMap<DN,
- DebugLogPublisher>();
+ private static CopyOnWriteArrayList<DebugLogPublisher> debugPublishers =
+ new CopyOnWriteArrayList<DebugLogPublisher>();
// Trace methods will use this static boolean to determine if debug is
// enabled so to not incur the cost of calling debugPublishers.isEmtpty().
@@ -96,13 +95,12 @@
/**
* Add an debug log publisher to the debug logger.
*
- * @param dn The DN of the configuration entry for the publisher.
* @param publisher The error log publisher to add.
*/
- public synchronized static void addDebugLogPublisher(DN dn,
- DebugLogPublisher publisher)
+ public synchronized static void addDebugLogPublisher(
+ DebugLogPublisher publisher)
{
- debugPublishers.put(dn, publisher);
+ debugPublishers.add(publisher);
updateTracerSettings();
@@ -112,16 +110,17 @@
/**
* Remove an debug log publisher from the debug logger.
*
- * @param dn The DN of the publisher to remove.
+ * @param publisher The debug log publisher to remove.
* @return The publisher that was removed or null if it was not found.
*/
- public synchronized static DebugLogPublisher removeDebugLogPublisher(DN dn)
+ public synchronized static boolean removeDebugLogPublisher(
+ DebugLogPublisher publisher)
{
- DebugLogPublisher removed = debugPublishers.remove(dn);
+ boolean removed = debugPublishers.remove(publisher);
- if(removed != null)
+ if(removed)
{
- removed.close();
+ publisher.close();
}
updateTracerSettings();
@@ -139,7 +138,7 @@
*/
public synchronized static void removeAllDebugLogPublishers()
{
- for(DebugLogPublisher publisher : debugPublishers.values())
+ for(DebugLogPublisher publisher : debugPublishers)
{
publisher.close();
}
@@ -174,7 +173,7 @@
{
DebugLogPublisher debugLogPublisher = getDebugPublisher(config);
- addDebugLogPublisher(config.dn(), debugLogPublisher);
+ addDebugLogPublisher(debugLogPublisher);
}
}
}
@@ -218,7 +217,7 @@
DebugLogPublisher debugLogPublisher =
getDebugPublisher(config);
- addDebugLogPublisher(config.dn(), debugLogPublisher);
+ addDebugLogPublisher(debugLogPublisher);
}
catch(ConfigException e)
{
@@ -248,7 +247,15 @@
ArrayList<String> messages = new ArrayList<String>();
DN dn = config.dn();
- DebugLogPublisher debugLogPublisher = debugPublishers.get(dn);
+
+ DebugLogPublisher debugLogPublisher = null;
+ for(DebugLogPublisher publisher : debugPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ debugLogPublisher = publisher;
+ }
+ }
if(debugLogPublisher == null)
{
@@ -276,7 +283,7 @@
else
{
// The publisher is being disabled so shut down and remove.
- removeDebugLogPublisher(config.dn());
+ removeDebugLogPublisher(debugLogPublisher);
}
}
@@ -290,7 +297,16 @@
List<String> unacceptableReasons)
{
DN dn = config.dn();
- DebugLogPublisher debugLogPublisher = debugPublishers.get(dn);
+
+ DebugLogPublisher debugLogPublisher = null;
+ for(DebugLogPublisher publisher : debugPublishers)
+ {
+ if(publisher.getDN().equals(dn))
+ {
+ debugLogPublisher = publisher;
+ }
+ }
+
return debugLogPublisher != null;
}
@@ -305,7 +321,23 @@
ResultCode resultCode = ResultCode.SUCCESS;
boolean adminActionRequired = false;
- DebugLogPublisher publisher = removeDebugLogPublisher(config.dn());
+ DebugLogPublisher debugLogPublisher = null;
+ for(DebugLogPublisher publisher : debugPublishers)
+ {
+ if(publisher.getDN().equals(config.dn()))
+ {
+ debugLogPublisher = publisher;
+ }
+ }
+
+ if(debugLogPublisher != null)
+ {
+ removeDebugLogPublisher(debugLogPublisher);
+ }
+ else
+ {
+ resultCode = ResultCode.NO_SUCH_OBJECT;
+ }
return new ConfigChangeResult(resultCode, adminActionRequired);
}
@@ -399,7 +431,7 @@
static void updateTracerSettings()
{
DebugLogPublisher[] publishers =
- debugPublishers.values().toArray(new DebugLogPublisher[0]);
+ debugPublishers.toArray(new DebugLogPublisher[0]);
for(DebugTracer tracer : classTracers.values())
{
@@ -436,8 +468,7 @@
public static DebugTracer getTracer()
{
DebugTracer tracer =
- new DebugTracer(debugPublishers.values().
- toArray(new DebugLogPublisher[0]));
+ new DebugTracer(debugPublishers.toArray(new DebugLogPublisher[0]));
classTracers.put(tracer.getTracedClassName(), tracer);
return tracer;
diff --git a/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java b/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
index f0b6f46..4532629 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/loggers/debug/TextDebugLogPublisher.java
@@ -919,4 +919,19 @@
return DebugMessageFormatter.format(format.toString(), args);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public DN getDN()
+ {
+ if(currentConfig != null)
+ {
+ return currentConfig.dn();
+ }
+ else
+ {
+ return null;
+ }
+ }
}
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java b/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
index 042364a..7d08dcd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/BackUpDB.java
@@ -38,6 +38,7 @@
import java.util.TimeZone;
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -78,7 +79,7 @@
*/
public class BackUpDB
{
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
* The main method for BackUpDB tool.
*
@@ -88,9 +89,9 @@
{
int retCode = mainBackUpDB(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -488,11 +489,10 @@
// of the export.
try
{
- publisherDN = DN.decode("cn=Custom Logger for BackUpDB");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
index 4913bf3..44b7fb9 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ExportLDIF.java
@@ -33,6 +33,7 @@
import java.util.List;
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
@@ -75,7 +76,7 @@
*/
public class ExportLDIF
{
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
* The main method for ExportLDIF tool.
*
@@ -86,9 +87,9 @@
{
int retCode = mainExportLDIF(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -434,11 +435,10 @@
// of the export.
try
{
- publisherDN = DN.decode("cn=Custom Logger for ExportLDIF");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java b/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
index f84dabe..5f4f24d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/ImportLDIF.java
@@ -35,6 +35,7 @@
import java.util.Random;
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.api.plugin.PluginType;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
@@ -84,7 +85,7 @@
*/
public static final int LDIF_BUFFER_SIZE = 1048576;
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
@@ -96,9 +97,9 @@
{
int retCode = mainImportLDIF(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -500,11 +501,10 @@
// state of the import.
try
{
- publisherDN = DN.decode("cn=Custom Logger for ImportLDIF");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java b/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
index 5d27702..b08d2bc 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/RebuildIndex.java
@@ -48,6 +48,7 @@
import org.opends.server.core.LockFileManager;
import org.opends.server.types.*;
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.jeb.RebuildConfig;
import org.opends.server.admin.std.server.BackendCfg;
@@ -64,7 +65,7 @@
*/
public class RebuildIndex
{
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
* Processes the command-line arguments and invokes the rebuild process.
@@ -75,9 +76,9 @@
{
int retCode = mainRebuildIndex(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -336,11 +337,10 @@
// of the verify process.
try
{
- publisherDN = DN.decode("cn=Custom Logger for RebuildIndex");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java b/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
index a0d753e..8ce2e1d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/RestoreDB.java
@@ -36,6 +36,7 @@
import java.util.List;
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.config.ConfigException;
import org.opends.server.core.CoreConfigManager;
import org.opends.server.core.DirectoryServer;
@@ -75,7 +76,7 @@
*/
public class RestoreDB
{
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
* The main method for RestoreDB tool.
*
@@ -86,9 +87,9 @@
{
int retCode = mainRestoreDB(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -353,11 +354,10 @@
// of the export.
try
{
- publisherDN = DN.decode("cn=Custom Logger for RestoreDB");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java b/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
index b9511c8..919a1e4 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/VerifyIndex.java
@@ -29,6 +29,7 @@
import org.opends.server.api.Backend;
+import org.opends.server.api.ErrorLogPublisher;
import org.opends.server.backends.jeb.BackendImpl;
import org.opends.server.backends.jeb.VerifyConfig;
import org.opends.server.config.ConfigException;
@@ -70,7 +71,7 @@
*/
public class VerifyIndex
{
- private static DN publisherDN = null;
+ private static ErrorLogPublisher errorLogPublisher = null;
/**
* Processes the command-line arguments and invokes the verify process.
*
@@ -80,9 +81,9 @@
{
int retCode = mainVerifyIndex(args);
- if(publisherDN != null)
+ if(errorLogPublisher != null)
{
- ErrorLogger.removeErrorLogPublisher(publisherDN);
+ ErrorLogger.removeErrorLogPublisher(errorLogPublisher);
}
if(retCode != 0)
@@ -347,11 +348,10 @@
// of the verify process.
try
{
- publisherDN = DN.decode("cn=Custom Logger for VerifyIndex");
- ThreadFilterTextErrorLogPublisher publisher =
+ errorLogPublisher =
new ThreadFilterTextErrorLogPublisher(Thread.currentThread(),
new TextWriter.STDOUT());
- ErrorLogger.addErrorLogPublisher(publisherDN, publisher);
+ ErrorLogger.addErrorLogPublisher(errorLogPublisher);
}
catch(Exception e)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/ServerConstants.java b/opendj-sdk/opends/src/server/org/opends/server/util/ServerConstants.java
index c61045d..dba99aa 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/ServerConstants.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/ServerConstants.java
@@ -844,7 +844,7 @@
* The English name for the basic disabled log severity used for all
* log severities.
*/
- public static final String LOG_SEVERITY_DISABLED = "disabled";
+ public static final String LOG_SEVERITY_DISABLED = "DISABLED";
@@ -852,7 +852,7 @@
* The English name for the basic all log severity used for all log
* severities.
*/
- public static final String LOG_SEVERITY_ALL = "all";
+ public static final String LOG_SEVERITY_ALL = "ALL";
@@ -860,14 +860,14 @@
* The English name for the debug log category used for access control
* debugging.
*/
- public static final String DEBUG_CATEGORY_MESSAGE = "message";
+ public static final String DEBUG_CATEGORY_MESSAGE = "MESSAGE";
/**
* The English name for the debug log category used for constructor debugging.
*/
- public static final String DEBUG_CATEGORY_CONSTRUCTOR = "constructor";
+ public static final String DEBUG_CATEGORY_CONSTRUCTOR = "CONSTRUCTOR";
@@ -875,21 +875,21 @@
* The English name for the debug log category used for debugging raw data
* read.
*/
- public static final String DEBUG_CATEGORY_DATA = "data";
+ public static final String DEBUG_CATEGORY_DATA = "DATA";
/**
* The English name for the debug log category used for exception debugging.
*/
- public static final String DEBUG_CATEGORY_THROWN = "thrown";
+ public static final String DEBUG_CATEGORY_THROWN = "THROWN";
/**
* The English name for the debug log category used for exception debugging.
*/
- public static final String DEBUG_CATEGORY_CAUGHT = "caught";
+ public static final String DEBUG_CATEGORY_CAUGHT = "CAUGHT";
@@ -897,7 +897,7 @@
* The English name for the debug log category used for method entry
* debugging.
*/
- public static final String DEBUG_CATEGORY_ENTER = "enter";
+ public static final String DEBUG_CATEGORY_ENTER = "ENTER";
@@ -905,7 +905,7 @@
* The English name for the debug log category used for method exit
* debugging.
*/
- public static final String DEBUG_CATEGORY_EXIT = "exit";
+ public static final String DEBUG_CATEGORY_EXIT = "EXIT";
@@ -913,7 +913,7 @@
* The English name for the debug log category used for debugging protocol
* elements.
*/
- public static final String DEBUG_CATEGORY_PROTOCOL = "protocol";
+ public static final String DEBUG_CATEGORY_PROTOCOL = "PROTOCOL";
@@ -921,14 +921,14 @@
* The English name for the debug log category used for raw data access
* from the JE database.
*/
- public static final String DEBUG_CATEGORY_DATABASE_ACCESS = "database-access";
+ public static final String DEBUG_CATEGORY_DATABASE_ACCESS = "DATABASE_ACCESS";
/**
* The English name for the debug log severity used for verbose messages.
*/
- public static final String DEBUG_SEVERITY_VERBOSE = "verbose";
+ public static final String DEBUG_SEVERITY_VERBOSE = "VERBOSE";
@@ -936,21 +936,21 @@
* The English name for the debug log severity used for informational
* messages.
*/
- public static final String DEBUG_SEVERITY_INFO = "info";
+ public static final String DEBUG_SEVERITY_INFO = "INFO";
/**
* The English name for the debug log severity used for warning messages.
*/
- public static final String DEBUG_SEVERITY_WARNING = "warning";
+ public static final String DEBUG_SEVERITY_WARNING = "WARNING";
/**
* The English name for the debug log severity used for error messages.
*/
- public static final String DEBUG_SEVERITY_ERROR = "error";
+ public static final String DEBUG_SEVERITY_ERROR = "ERROR";
@@ -958,14 +958,14 @@
* The English name for the error log category used for access control
* processing.
*/
- public static final String ERROR_CATEGORY_ACCESS_CONTROL = "access-control";
+ public static final String ERROR_CATEGORY_ACCESS_CONTROL = "ACCESS_CONTROL";
/**
* The English name for the error log category used for backend processing.
*/
- public static final String ERROR_CATEGORY_BACKEND = "backend";
+ public static final String ERROR_CATEGORY_BACKEND = "BACKEND";
@@ -973,7 +973,7 @@
* The English name for the error log category used for configuration
* processing.
*/
- public static final String ERROR_CATEGORY_CONFIG = "config";
+ public static final String ERROR_CATEGORY_CONFIG = "CONFIG";
@@ -981,7 +981,7 @@
* The English name for the error log category used for client connection
* handling.
*/
- public static final String ERROR_CATEGORY_CONNECTION_HANDLING = "connection";
+ public static final String ERROR_CATEGORY_CONNECTION_HANDLING = "CONNECTION";
@@ -989,14 +989,14 @@
* The English name for the error log category used for core server
* processing.
*/
- public static final String ERROR_CATEGORY_CORE_SERVER = "core";
+ public static final String ERROR_CATEGORY_CORE_SERVER = "CORE";
/**
* The English name for the error log category used for extended operation
* processing.
*/
- public static final String ERROR_CATEGORY_EXTENDED_OPERATION = "extended-op";
+ public static final String ERROR_CATEGORY_EXTENDED_OPERATION = "EXTENDED_OP";
@@ -1004,7 +1004,7 @@
* The English name for the error log category used for server extension
* processing.
*/
- public static final String ERROR_CATEGORY_EXTENSIONS = "extentions";
+ public static final String ERROR_CATEGORY_EXTENSIONS = "EXTENTIONS";
@@ -1012,49 +1012,49 @@
* The English name for the error log category used for password policy
* processing.
*/
- public static final String ERROR_CATEGORY_PASSWORD_POLICY = "pw-policy";
+ public static final String ERROR_CATEGORY_PASSWORD_POLICY = "PW_POLICY";
/**
* The English name for the error log category used for plugin processing.
*/
- public static final String ERROR_CATEGORY_PLUGIN = "plugin";
+ public static final String ERROR_CATEGORY_PLUGIN = "PLUGIN";
/**
* The English name for the error log category used for request handling.
*/
- public static final String ERROR_CATEGORY_REQUEST = "request";
+ public static final String ERROR_CATEGORY_REQUEST = "REQUEST";
/**
* The English name for the error log category used for SASL processing.
*/
- public static final String ERROR_CATEGORY_SASL_MECHANISM = "sasl";
+ public static final String ERROR_CATEGORY_SASL_MECHANISM = "SASL";
/**
* The English name for the error log category used for schema processing.
*/
- public static final String ERROR_CATEGORY_SCHEMA = "schema";
+ public static final String ERROR_CATEGORY_SCHEMA = "SCHEMA";
/**
* The English name for the error log category used for shutdown processing.
*/
- public static final String ERROR_CATEGORY_SHUTDOWN = "shutdown";
+ public static final String ERROR_CATEGORY_SHUTDOWN = "SHUTDOWN";
/**
* The English name for the error log category used for startup processing.
*/
- public static final String ERROR_CATEGORY_STARTUP = "startup";
+ public static final String ERROR_CATEGORY_STARTUP = "STARTUP";
@@ -1062,21 +1062,21 @@
* The English name for the error log category used for synchronization
* processing.
*/
- public static final String ERROR_CATEGORY_SYNCHRONIZATION = "synch";
+ public static final String ERROR_CATEGORY_SYNCHRONIZATION = "SYNC";
/**
* The English name for the error log category used for task processing.
*/
- public static final String ERROR_CATEGORY_TASK = "task";
+ public static final String ERROR_CATEGORY_TASK = "TASK";
/**
* The English name for the error log severity used for fatal error messages.
*/
- public static final String ERROR_SEVERITY_FATAL = "fatal-error";
+ public static final String ERROR_SEVERITY_FATAL = "FATAL_ERROR";
@@ -1084,21 +1084,21 @@
* The English name for the error log severity used for informational
* messages.
*/
- public static final String ERROR_SEVERITY_INFORMATIONAL = "info";
+ public static final String ERROR_SEVERITY_INFORMATIONAL = "INFO";
/**
* The English name for the error log severity used for mild error messages.
*/
- public static final String ERROR_SEVERITY_MILD_ERROR = "mild-error";
+ public static final String ERROR_SEVERITY_MILD_ERROR = "MILD_ERROR";
/**
* The English name for the error log severity used for mild warning messages.
*/
- public static final String ERROR_SEVERITY_MILD_WARNING = "mild-warning";
+ public static final String ERROR_SEVERITY_MILD_WARNING = "MILD_WARNING";
@@ -1106,14 +1106,14 @@
* The English name for the error log severity used for important
* informational messages.
*/
- public static final String ERROR_SEVERITY_NOTICE = "notice";
+ public static final String ERROR_SEVERITY_NOTICE = "NOTICE";
/**
* The English name for the error log severity used for severe error messages.
*/
- public static final String ERROR_SEVERITY_SEVERE_ERROR = "severe-error";
+ public static final String ERROR_SEVERITY_SEVERE_ERROR = "SEVERE_ERROR";
@@ -1121,7 +1121,7 @@
* The English name for the error log severity used for severe warning
* messages.
*/
- public static final String ERROR_SEVERITY_SEVERE_WARNING = "severe-warning";
+ public static final String ERROR_SEVERITY_SEVERE_WARNING = "SEVERE_WARNING";
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
index cf90e5f..3b39dd5 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/TestCaseUtils.java
@@ -327,22 +327,19 @@
TextDebugLogPublisher.getStartupTextDebugPublisher(
TestListener.DEBUG_TEXT_WRITER);
DebugLogger.removeAllDebugLogPublishers();
- DebugLogger.addDebugLogPublisher(DN.decode("cn=Test Debug Publisher"),
- startupDebugPublisher);
+ DebugLogger.addDebugLogPublisher(startupDebugPublisher);
TextErrorLogPublisher startupErrorPublisher =
TextErrorLogPublisher.getStartupTextErrorPublisher(
TestListener.ERROR_TEXT_WRITER);
ErrorLogger.removeAllErrorLogPublishers();
- ErrorLogger.addErrorLogPublisher(DN.decode("cn=Test Error Publisher"),
- startupErrorPublisher);
+ ErrorLogger.addErrorLogPublisher(startupErrorPublisher);
TextAccessLogPublisher startupAccessPublisher =
TextAccessLogPublisher.getStartupTextAccessPublisher(
TestListener.ACCESS_TEXT_WRITER, false);
AccessLogger.removeAllAccessLogPublishers();
- AccessLogger.addAccessLogPublisher(DN.decode("cn=Test Access Publisher"),
- startupAccessPublisher);
+ AccessLogger.addAccessLogPublisher(startupAccessPublisher);
}
catch(Exception e)
{
--
Gitblit v1.10.0