From 3e40406fe620ad576523d7039f3ee1b37499a462 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 03 Jan 2014 15:21:08 +0000
Subject: [PATCH] Code cleanup. Used EnvironmentConfig as a static import to configure JE.
---
opends/src/server/org/opends/server/backends/jeb/ConfigurableEnvironment.java | 82 +++-----
opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDbEnv.java | 28 +-
opends/src/server/org/opends/server/backends/jeb/BackendImpl.java | 431 +++++++++++-------------------------------
opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java | 37 +--
4 files changed, 177 insertions(+), 401 deletions(-)
diff --git a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
index 58b1b4e..d830d56 100644
--- a/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
+++ b/opends/src/server/org/opends/server/backends/jeb/BackendImpl.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2007-2010 Sun Microsystems, Inc.
- * Portions Copyright 2013 ForgeRock AS
+ * Portions Copyright 2013-2014 ForgeRock AS
*/
package org.opends.server.backends.jeb;
@@ -38,11 +38,6 @@
import java.util.zip.Adler32;
import java.util.zip.CheckedInputStream;
-import com.sleepycat.je.DatabaseException;
-import com.sleepycat.je.Durability;
-import com.sleepycat.je.EnvironmentConfig;
-import com.sleepycat.je.EnvironmentFailureException;
-
import org.opends.messages.Message;
import org.opends.server.admin.Configuration;
import org.opends.server.admin.server.ConfigurationChangeListener;
@@ -54,19 +49,20 @@
import org.opends.server.api.MonitorProvider;
import org.opends.server.backends.jeb.importLDIF.Importer;
import org.opends.server.config.ConfigException;
-import org.opends.server.core.AddOperation;
-import org.opends.server.core.DeleteOperation;
-import org.opends.server.core.DirectoryServer;
-import org.opends.server.core.ModifyOperation;
-import org.opends.server.core.ModifyDNOperation;
-import org.opends.server.core.SearchOperation;
+import org.opends.server.core.*;
import org.opends.server.extensions.DiskSpaceMonitor;
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.types.*;
-import org.opends.server.util.LDIFException;
import org.opends.server.util.RuntimeInformation;
import org.opends.server.util.Validator;
+import com.sleepycat.je.DatabaseException;
+import com.sleepycat.je.Durability;
+import com.sleepycat.je.EnvironmentConfig;
+import com.sleepycat.je.EnvironmentFailureException;
+
+import static com.sleepycat.je.EnvironmentConfig.*;
+
import static org.opends.messages.BackendMessages.*;
import static org.opends.messages.JebMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
@@ -143,16 +139,7 @@
/**
* The features supported by this backend.
*/
- private static HashSet<String> supportedFeatures;
-
- static {
- // Set our supported features.
- supportedFeatures = new HashSet<String>();
-
- //NYI
- }
-
-
+ private static HashSet<String> supportedFeatures = new HashSet<String>();
/**
* Begin a Backend API method that reads the database.
@@ -276,11 +263,7 @@
return 0;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void configureBackend(Configuration cfg)
throws ConfigException
@@ -295,11 +278,7 @@
dnSet.toArray(baseDNs);
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void initializeBackend()
throws ConfigException, InitializationException
@@ -376,11 +355,7 @@
cfg.addLocalDBChangeListener(this);
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void finalizeBackend()
{
@@ -443,11 +418,7 @@
logError(message);
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean isLocal()
{
@@ -456,9 +427,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean isIndexed(AttributeType attributeType, IndexType indexType)
{
@@ -509,44 +478,28 @@
}
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean supportsLDIFExport()
{
return true;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean supportsLDIFImport()
{
return true;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean supportsBackup()
{
return true;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean supportsBackup(BackupConfig backupConfig,
StringBuilder unsupportedReason)
@@ -554,55 +507,35 @@
return true;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean supportsRestore()
{
return true;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public HashSet<String> getSupportedFeatures()
{
return supportedFeatures;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public HashSet<String> getSupportedControls()
{
return supportedControls;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public DN[] getBaseDNs()
{
return baseDNs;
}
-
-
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public long getEntryCount()
{
@@ -626,9 +559,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public ConditionResult hasSubordinates(DN entryDN)
throws DirectoryException
@@ -650,9 +581,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public long numSubordinates(DN entryDN, boolean subtree)
throws DirectoryException
@@ -703,9 +632,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public Entry getEntry(DN entryDN) throws DirectoryException
{
@@ -748,9 +675,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void addEntry(Entry entry, AddOperation addOperation)
throws DirectoryException, CanceledOperationException
@@ -793,9 +718,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void deleteEntry(DN entryDN, DeleteOperation deleteOperation)
throws DirectoryException, CanceledOperationException
@@ -837,9 +760,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void replaceEntry(Entry oldEntry, Entry newEntry,
ModifyOperation modifyOperation) throws DirectoryException,
@@ -884,9 +805,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void renameEntry(DN currentDN, Entry entry,
ModifyDNOperation modifyDNOperation)
@@ -939,9 +858,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void search(SearchOperation searchOperation)
throws DirectoryException, CanceledOperationException
@@ -982,9 +899,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void exportLDIF(LDIFExportConfig exportConfig)
throws DirectoryException
@@ -992,24 +907,13 @@
// If the backend already has the root container open, we must use the same
// underlying root container
boolean openRootContainer = rootContainer == null;
-
try
{
- if(openRootContainer)
+ if (openRootContainer)
{
- EnvironmentConfig envConfig =
- ConfigurableEnvironment.parseConfigEntry(cfg);
-
- envConfig.setReadOnly(true);
- envConfig.setAllowCreate(false);
- envConfig.setTransactional(false);
- envConfig.setConfigParam("je.env.isLocking", "true");
- envConfig.setConfigParam("je.env.runCheckpointer", "true");
-
- rootContainer = initializeRootContainer(envConfig);
+ rootContainer = getReadOnlyRootContainer();
}
-
ExportJob exportJob = new ExportJob(exportConfig);
exportJob.exportLDIF(rootContainer);
}
@@ -1023,15 +927,6 @@
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
message);
}
- catch (JebException je)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, je);
- }
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- je.getMessageObject());
- }
catch (DatabaseException de)
{
if (debugEnabled())
@@ -1040,8 +935,12 @@
}
throw createDirectoryException(de);
}
- catch (LDIFException e)
+ catch (IdentifiedException e)
{
+ if (e instanceof DirectoryException)
+ {
+ throw (DirectoryException) e;
+ }
if (debugEnabled())
{
TRACER.debugCaught(DebugLogLevel.ERROR, e);
@@ -1049,51 +948,15 @@
throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
e.getMessageObject());
}
- catch (InitializationException ie)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, ie);
- }
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- ie.getMessageObject());
- }
- catch (ConfigException ce)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, ce);
- }
- throw new DirectoryException(DirectoryServer.getServerErrorResultCode(),
- ce.getMessageObject());
- }
finally
{
- //If a root container was opened in this method as read only, close it
- //to leave the backend in the same state.
- if (openRootContainer && rootContainer != null)
- {
- try
- {
- rootContainer.close();
- rootContainer = null;
- }
- catch (DatabaseException e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- }
+ closeTemporaryRootContainer(openRootContainer);
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public LDIFImportResult importLDIF(LDIFImportConfig importConfig)
throws DirectoryException
@@ -1116,30 +979,21 @@
try
{
- EnvironmentConfig envConfig = new EnvironmentConfig();
+ final EnvironmentConfig envConfig = getEnvConfigForImport();
- envConfig.setAllowCreate(true);
- envConfig.setTransactional(false);
- envConfig.setDurability(Durability.COMMIT_NO_SYNC);
- envConfig.setLockTimeout(0, TimeUnit.SECONDS);
- envConfig.setTxnTimeout(0, TimeUnit.SECONDS);
- envConfig.setConfigParam(EnvironmentConfig.CLEANER_MIN_FILE_UTILIZATION,
- String.valueOf(cfg.getDBCleanerMinUtilization()));
- envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, String
- .valueOf(cfg.getDBLogFileMax()));
-
- if(!importConfig.appendToExistingData()) {
- if(importConfig.clearBackend() || cfg.getBaseDN().size() <= 1) {
- // We have the writer lock on the environment, now delete the
- // environment and re-open it. Only do this when we are
- // importing to all the base DNs in the backend or if the backend only
- // have one base DN.
- File parentDirectory = getFileForPath(cfg.getDBDirectory());
- File backendDirectory = new File(parentDirectory, cfg.getBackendId());
- // If the backend does not exist the import will create it.
- if (backendDirectory.exists()) {
- EnvManager.removeFiles(backendDirectory.getPath());
- }
+ if (!importConfig.appendToExistingData()
+ && (importConfig.clearBackend() || cfg.getBaseDN().size() <= 1))
+ {
+ // We have the writer lock on the environment, now delete the
+ // environment and re-open it. Only do this when we are
+ // importing to all the base DNs in the backend or if the backend only
+ // have one base DN.
+ File parentDirectory = getFileForPath(cfg.getDBDirectory());
+ File backendDirectory = new File(parentDirectory, cfg.getBackendId());
+ // If the backend does not exist the import will create it.
+ if (backendDirectory.exists())
+ {
+ EnvManager.removeFiles(backendDirectory.getPath());
}
}
@@ -1235,7 +1089,20 @@
}
}
-
+ private EnvironmentConfig getEnvConfigForImport()
+ {
+ final EnvironmentConfig envConfig = new EnvironmentConfig();
+ envConfig.setAllowCreate(true);
+ envConfig.setTransactional(false);
+ envConfig.setDurability(Durability.COMMIT_NO_SYNC);
+ envConfig.setLockTimeout(0, TimeUnit.SECONDS);
+ envConfig.setTxnTimeout(0, TimeUnit.SECONDS);
+ envConfig.setConfigParam(CLEANER_MIN_FILE_UTILIZATION,
+ String.valueOf(cfg.getDBCleanerMinUtilization()));
+ envConfig.setConfigParam(LOG_FILE_MAX,
+ String.valueOf(cfg.getDBLogFileMax()));
+ return envConfig;
+ }
/**
* Verify the integrity of the backend instance.
@@ -1259,18 +1126,9 @@
try
{
- if(openRootContainer)
+ if (openRootContainer)
{
- EnvironmentConfig envConfig =
- ConfigurableEnvironment.parseConfigEntry(cfg);
-
- envConfig.setReadOnly(true);
- envConfig.setAllowCreate(false);
- envConfig.setTransactional(false);
- envConfig.setConfigParam("je.env.isLocking", "true");
- envConfig.setConfigParam("je.env.runCheckpointer", "true");
-
- rootContainer = initializeRootContainer(envConfig);
+ rootContainer = getReadOnlyRootContainer();
}
VerifyJob verifyJob = new VerifyJob(verifyConfig);
@@ -1295,23 +1153,7 @@
}
finally
{
- //If a root container was opened in this method as read only, close it
- //to leave the backend in the same state.
- if (openRootContainer && rootContainer != null)
- {
- try
- {
- rootContainer.close();
- rootContainer = null;
- }
- catch (DatabaseException e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
- }
- }
+ closeTemporaryRootContainer(openRootContainer);
}
return errorCount;
}
@@ -1349,20 +1191,10 @@
try
{
- EnvironmentConfig envConfig;
+ final EnvironmentConfig envConfig;
if (openRootContainer)
{
- envConfig = new EnvironmentConfig();
- envConfig.setAllowCreate(true);
- envConfig.setTransactional(false);
- envConfig.setDurability(Durability.COMMIT_NO_SYNC);
- envConfig.setLockTimeout(0, TimeUnit.SECONDS);
- envConfig.setTxnTimeout(0, TimeUnit.SECONDS);
- envConfig.setConfigParam(
- EnvironmentConfig.CLEANER_MIN_FILE_UTILIZATION, String.valueOf(cfg
- .getDBCleanerMinUtilization()));
- envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, String
- .valueOf(cfg.getDBLogFileMax()));
+ envConfig = getEnvConfigForImport();
Importer importer = new Importer(rebuildConfig, cfg, envConfig);
rootContainer = initializeRootContainer(envConfig);
@@ -1424,30 +1256,35 @@
}
finally
{
- //If a root container was opened in this method as read only, close it
- //to leave the backend in the same state.
- if (openRootContainer && rootContainer != null)
+ closeTemporaryRootContainer(openRootContainer);
+ }
+ }
+
+ /**
+ * If a root container was opened in the calling method method as read only,
+ * close it to leave the backend in the same state.
+ */
+ private void closeTemporaryRootContainer(boolean openRootContainer)
+ {
+ if (openRootContainer && rootContainer != null)
+ {
+ try
{
- try
+ rootContainer.close();
+ rootContainer = null;
+ }
+ catch (DatabaseException e)
+ {
+ if (debugEnabled())
{
- rootContainer.close();
- rootContainer = null;
- }
- catch (DatabaseException e)
- {
- if (debugEnabled())
- {
- TRACER.debugCaught(DebugLogLevel.ERROR, e);
- }
+ TRACER.debugCaught(DebugLogLevel.ERROR, e);
}
}
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void createBackup(BackupConfig backupConfig)
throws DirectoryException
@@ -1461,9 +1298,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void removeBackup(BackupDirectory backupDirectory, String backupID)
throws DirectoryException
@@ -1475,9 +1310,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public void restoreBackup(RestoreConfig restoreConfig)
throws DirectoryException
@@ -1491,9 +1324,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override()
public boolean isConfigurationAcceptable(Configuration configuration,
List<Message> unacceptableReasons)
@@ -1504,9 +1335,7 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public boolean isConfigurationChangeAcceptable(
LocalDBBackendCfg cfg,
@@ -1528,13 +1357,10 @@
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public ConfigChangeResult applyConfigurationChange(LocalDBBackendCfg newCfg)
{
- ConfigChangeResult ccr;
ResultCode resultCode = ResultCode.SUCCESS;
ArrayList<Message> messages = new ArrayList<Message>();
@@ -1593,8 +1419,7 @@
messages.add(ERR_BACKEND_CANNOT_REGISTER_BASEDN.get(
String.valueOf(baseDN),
String.valueOf(e)));
- ccr = new ConfigChangeResult(resultCode, false, messages);
- return ccr;
+ return new ConfigChangeResult(resultCode, false, messages);
}
}
}
@@ -1615,13 +1440,11 @@
catch (Exception e)
{
messages.add(Message.raw(stackTraceToSingleLineString(e)));
- ccr = new ConfigChangeResult(DirectoryServer.getServerErrorResultCode(),
- false, messages);
- return ccr;
+ return new ConfigChangeResult(
+ DirectoryServer.getServerErrorResultCode(), false, messages);
}
- ccr = new ConfigChangeResult(resultCode, false, messages);
- return ccr;
+ return new ConfigChangeResult(resultCode, false, messages);
}
/**
@@ -1656,8 +1479,8 @@
envConfig.setReadOnly(true);
envConfig.setAllowCreate(false);
envConfig.setTransactional(false);
- envConfig.setConfigParam("je.env.isLocking", "true");
- envConfig.setConfigParam("je.env.runCheckpointer", "true");
+ envConfig.setConfigParam(ENV_IS_LOCKING, "true");
+ envConfig.setConfigParam(ENV_RUN_CHECKPOINTER, "true");
return initializeRootContainer(envConfig);
}
@@ -1688,11 +1511,8 @@
* @return DirectoryException created from exception.
*/
DirectoryException createDirectoryException(DatabaseException e) {
- ResultCode resultCode = DirectoryServer.getServerErrorResultCode();
- Message message;
- if ((e instanceof EnvironmentFailureException) &&
- !rootContainer.isValid()) {
- message = NOTE_BACKEND_ENVIRONMENT_UNUSABLE.get(getBackendID());
+ if (e instanceof EnvironmentFailureException && !rootContainer.isValid()) {
+ Message message = NOTE_BACKEND_ENVIRONMENT_UNUSABLE.get(getBackendID());
logError(message);
DirectoryServer.sendAlertNotification(DirectoryServer.getInstance(),
ALERT_TYPE_BACKEND_ENVIRONMENT_UNUSABLE, message);
@@ -1702,21 +1522,18 @@
if (jeMessage == null) {
jeMessage = stackTraceToSingleLineString(e);
}
- message = ERR_JEB_DATABASE_EXCEPTION.get(jeMessage);
- return new DirectoryException(resultCode, message, e);
+ Message message = ERR_JEB_DATABASE_EXCEPTION.get(jeMessage);
+ return new DirectoryException(
+ DirectoryServer.getServerErrorResultCode(), message, e);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public String getClassName() {
return CLASS_NAME;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public Map<String, String> getAlerts()
{
@@ -1731,9 +1548,7 @@
return alerts;
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public DN getComponentEntryDN() {
return cfg.dn();
@@ -1756,9 +1571,7 @@
}
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void preloadEntryCache() throws
UnsupportedOperationException {
@@ -1767,9 +1580,7 @@
preloader.preload();
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void diskLowThresholdReached(DiskSpaceMonitor monitor) {
Message msg = ERR_JEB_DISK_LOW_THRESHOLD_REACHED.get(
@@ -1780,9 +1591,7 @@
ALERT_TYPE_DISK_SPACE_LOW, msg);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void diskFullThresholdReached(DiskSpaceMonitor monitor) {
Message msg = ERR_JEB_DISK_FULL_THRESHOLD_REACHED.get(
@@ -1793,9 +1602,7 @@
ALERT_TYPE_DISK_FULL, msg);
}
- /**
- * {@inheritDoc}
- */
+ /** {@inheritDoc} */
@Override
public void diskSpaceRestored(DiskSpaceMonitor monitor) {
Message msg = NOTE_JEB_DISK_SPACE_RESTORED.get(monitor.getFreeSpace(),
diff --git a/opends/src/server/org/opends/server/backends/jeb/ConfigurableEnvironment.java b/opends/src/server/org/opends/server/backends/jeb/ConfigurableEnvironment.java
index 0696420..5a234a7 100644
--- a/opends/src/server/org/opends/server/backends/jeb/ConfigurableEnvironment.java
+++ b/opends/src/server/org/opends/server/backends/jeb/ConfigurableEnvironment.java
@@ -22,45 +22,39 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions Copyright 2010-2011 ForgeRock AS.
+ * Portions Copyright 2010-2014 ForgeRock AS.
*/
package org.opends.server.backends.jeb;
-import com.sleepycat.je.Durability;
-import com.sleepycat.je.EnvironmentConfig;
-import com.sleepycat.je.dbi.MemoryBudget;
-
-import org.opends.server.config.ConfigConstants;
-import org.opends.server.config.ConfigException;
-import org.opends.server.types.DebugLogLevel;
-
-import java.util.HashMap;
-import java.util.Map;
import java.lang.reflect.Method;
import java.math.BigInteger;
-import java.util.HashSet;
-import java.util.SortedSet;
-import java.util.StringTokenizer;
-import java.util.List;
-import java.util.Arrays;
+import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.opends.messages.Message;
-import static org.opends.messages.JebMessages.*;
-
-import org.opends.server.loggers.debug.DebugTracer;
-import org.opends.server.admin.std.server.LocalDBBackendCfg;
-import org.opends.server.admin.std.meta.LocalDBBackendCfgDefn;
-import org.opends.server.admin.DurationPropertyDefinition;
import org.opends.server.admin.BooleanPropertyDefinition;
+import org.opends.server.admin.DurationPropertyDefinition;
import org.opends.server.admin.PropertyDefinition;
+import org.opends.server.admin.std.meta.LocalDBBackendCfgDefn;
+import org.opends.server.admin.std.server.LocalDBBackendCfg;
+import org.opends.server.config.ConfigConstants;
+import org.opends.server.config.ConfigException;
+import org.opends.server.loggers.debug.DebugTracer;
+import org.opends.server.types.DebugLogLevel;
+import com.sleepycat.je.Durability;
+import com.sleepycat.je.EnvironmentConfig;
+import com.sleepycat.je.dbi.MemoryBudget;
+
+import static com.sleepycat.je.EnvironmentConfig.*;
+
+import static org.opends.messages.BackendMessages.*;
+import static org.opends.messages.ConfigMessages.*;
+import static org.opends.messages.JebMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.*;
-import static org.opends.messages.ConfigMessages.*;
-import static org.opends.messages.BackendMessages.*;
/**
* This class maps JE properties to configuration attributes.
@@ -436,36 +430,30 @@
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
- // This property was introduced in JE 3.0. Shared latches are now used on
- // all internal nodes of the b-tree, which increases concurrency for many
- // operations.
- envConfig.setConfigParam("je.env.sharedLatches", "true");
+ // "je.env.sharedLatches" is "true" by default since JE #12136 (3.3.62?)
// This parameter was set to false while diagnosing a Berkeley DB JE bug.
// Normally cleansed log files are deleted, but if this is set false
// they are instead renamed from .jdb to .del.
- envConfig.setConfigParam("je.cleaner.expunge", "true");
+ envConfig.setConfigParam(CLEANER_EXPUNGE, "true");
// Under heavy write load the check point can fall behind causing
// uncontrolled DB growth over time. This parameter makes the out of
// the box configuration more robust at the cost of a slight
// reduction in maximum write throughput. Experiments have shown
// that response time predictability is not impacted negatively.
- envConfig.setConfigParam("je.checkpointer.highPriority", "true");
+ envConfig.setConfigParam(CHECKPOINTER_HIGH_PRIORITY, "true");
// If the JVM is reasonably large then we can safely default to
// bigger read buffers. This will result in more scalable checkpointer
// and cleaner performance.
if (Runtime.getRuntime().maxMemory() > 256 * 1024 * 1024)
{
- envConfig.setConfigParam("je.cleaner.lookAheadCacheSize", String
- .valueOf(2 * 1024 * 1024));
-
- envConfig.setConfigParam("je.log.iteratorReadSize", String
- .valueOf(2 * 1024 * 1024));
-
- envConfig.setConfigParam("je.log.faultReadSize", String
- .valueOf(4 * 1024));
+ envConfig.setConfigParam(CLEANER_LOOK_AHEAD_CACHE_SIZE,
+ String.valueOf(2 * 1024 * 1024));
+ envConfig.setConfigParam(LOG_ITERATOR_READ_SIZE,
+ String.valueOf(2 * 1024 * 1024));
+ envConfig.setConfigParam(LOG_FAULT_READ_SIZE, String.valueOf(4 * 1024));
}
// Disable lock timeouts, meaning that no lock wait
@@ -545,23 +533,13 @@
String.valueOf(cfg.getDBLoggingLevel()),
String.valueOf(cfg.dn())));
}
- if (cfg.isDBLoggingFileHandlerOn())
- {
- envConfig.setConfigParam(
- EnvironmentConfig.FILE_LOGGING_LEVEL,
- Level.ALL.getName());
- }
- else
- {
- envConfig.setConfigParam(
- EnvironmentConfig.FILE_LOGGING_LEVEL,
- Level.OFF.getName());
- }
+
+ final Level level = cfg.isDBLoggingFileHandlerOn() ? Level.ALL : Level.OFF;
+ envConfig.setConfigParam(FILE_LOGGING_LEVEL, level.getName());
// See if there are any native JE properties specified in the config
// and if so try to parse, evaluate and set them.
- SortedSet<String> jeProperties = cfg.getJEProperty();
- return setJEProperties(envConfig, jeProperties, attrMap);
+ return setJEProperties(envConfig, cfg.getJEProperty(), attrMap);
}
diff --git a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
index 96945b2..bcaab2d 100644
--- a/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
+++ b/opends/src/server/org/opends/server/backends/jeb/importLDIF/Importer.java
@@ -22,10 +22,12 @@
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
- * Portions Copyright 2011-2013 ForgeRock AS
+ * Portions Copyright 2011-2014 ForgeRock AS
*/
package org.opends.server.backends.jeb.importLDIF;
+import static com.sleepycat.je.EnvironmentConfig.*;
+
import static org.opends.messages.JebMessages.*;
import static org.opends.server.loggers.ErrorLogger.*;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
@@ -544,24 +546,18 @@
if (oldThreadCount != threadCount)
{
- Message message =
- NOTE_JEB_IMPORT_ADJUST_THREAD_COUNT.get(oldThreadCount, threadCount);
- logError(message);
+ logError(
+ NOTE_JEB_IMPORT_ADJUST_THREAD_COUNT.get(oldThreadCount, threadCount));
}
- Message message =
- NOTE_JEB_IMPORT_LDIF_TOT_MEM_BUF.get(availableMemory,
- phaseOneBufferCount);
- logError(message);
+ logError(NOTE_JEB_IMPORT_LDIF_TOT_MEM_BUF.get(
+ availableMemory, phaseOneBufferCount));
if (tmpEnvCacheSize > 0)
{
- message = NOTE_JEB_IMPORT_LDIF_TMP_ENV_MEM.get(tmpEnvCacheSize);
- logError(message);
+ logError(NOTE_JEB_IMPORT_LDIF_TMP_ENV_MEM.get(tmpEnvCacheSize));
}
- envConfig.setConfigParam(EnvironmentConfig.MAX_MEMORY, Long
- .toString(dbCacheSize));
- message = NOTE_JEB_IMPORT_LDIF_DB_MEM_BUF_INFO.get(dbCacheSize, bufferSize);
- logError(message);
+ envConfig.setConfigParam(MAX_MEMORY, Long.toString(dbCacheSize));
+ logError(NOTE_JEB_IMPORT_LDIF_DB_MEM_BUF_INFO.get(dbCacheSize, bufferSize));
}
/**
@@ -4688,16 +4684,15 @@
public TmpEnv(File envPath) throws DatabaseException
{
EnvironmentConfig envConfig = new EnvironmentConfig();
- envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, "true");
+ envConfig.setConfigParam(ENV_RUN_CLEANER, "true");
envConfig.setReadOnly(false);
envConfig.setAllowCreate(true);
envConfig.setTransactional(false);
- envConfig.setConfigParam(EnvironmentConfig.ENV_IS_LOCKING, "true");
- envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, "false");
- envConfig.setConfigParam(EnvironmentConfig.EVICTOR_LRU_ONLY, "false");
- envConfig.setConfigParam(EnvironmentConfig.EVICTOR_NODES_PER_SCAN, "128");
- envConfig.setConfigParam(EnvironmentConfig.MAX_MEMORY, Long
- .toString(tmpEnvCacheSize));
+ envConfig.setConfigParam(ENV_IS_LOCKING, "true");
+ envConfig.setConfigParam(ENV_RUN_CHECKPOINTER, "false");
+ envConfig.setConfigParam(EVICTOR_LRU_ONLY, "false");
+ envConfig.setConfigParam(EVICTOR_NODES_PER_SCAN, "128");
+ envConfig.setConfigParam(MAX_MEMORY, Long.toString(tmpEnvCacheSize));
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(false);
diff --git a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDbEnv.java b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDbEnv.java
index 885af0a..fb11b44 100644
--- a/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDbEnv.java
+++ b/opends/src/server/org/opends/server/replication/server/changelog/je/ReplicationDbEnv.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2006-2009 Sun Microsystems, Inc.
- * Portions Copyright 2011-2013 ForgeRock AS
+ * Portions Copyright 2011-2014 ForgeRock AS
*/
package org.opends.server.replication.server.changelog.je;
@@ -44,7 +44,7 @@
import com.sleepycat.je.*;
-import static com.sleepycat.je.LockMode.*;
+import static com.sleepycat.je.EnvironmentConfig.*;
import static com.sleepycat.je.OperationStatus.*;
import static org.opends.messages.JebMessages.*;
@@ -95,10 +95,9 @@
*/
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
- envConfig.setConfigParam(EnvironmentConfig.STATS_COLLECT, "false");
- envConfig.setConfigParam(EnvironmentConfig.CLEANER_THREADS, "2");
- envConfig.setConfigParam(
- EnvironmentConfig.CHECKPOINTER_HIGH_PRIORITY, "true");
+ envConfig.setConfigParam(STATS_COLLECT, "false");
+ envConfig.setConfigParam(CLEANER_THREADS, "2");
+ envConfig.setConfigParam(CHECKPOINTER_HIGH_PRIORITY, "true");
/*
* Tests have shown that since the parsing of the Replication log is
* always done sequentially, it is not necessary to use a large DB cache.
@@ -110,17 +109,15 @@
* read buffers. This will result in more scalable checkpointer and
* cleaner performance.
*/
- envConfig.setConfigParam(
- EnvironmentConfig.CLEANER_LOOK_AHEAD_CACHE_SIZE, mb(2));
- envConfig.setConfigParam(
- EnvironmentConfig.LOG_ITERATOR_READ_SIZE, mb(2));
- envConfig.setConfigParam(EnvironmentConfig.LOG_FAULT_READ_SIZE, kb(4));
+ envConfig.setConfigParam(CLEANER_LOOK_AHEAD_CACHE_SIZE, mb(2));
+ envConfig.setConfigParam(LOG_ITERATOR_READ_SIZE, mb(2));
+ envConfig.setConfigParam(LOG_FAULT_READ_SIZE, kb(4));
/*
* The cache size must be bigger in order to accommodate the larger
* buffers - see OPENDJ-943.
*/
- envConfig.setConfigParam(EnvironmentConfig.MAX_MEMORY, mb(16));
+ envConfig.setConfigParam(MAX_MEMORY, mb(16));
}
else
{
@@ -128,7 +125,7 @@
* Use 5M so that the replication can be used with 64M total for the
* JVM.
*/
- envConfig.setConfigParam(EnvironmentConfig.MAX_MEMORY, mb(5));
+ envConfig.setConfigParam(MAX_MEMORY, mb(5));
}
// Since records are always added at the end of the Replication log and
@@ -379,7 +376,7 @@
{
DatabaseEntry key = new DatabaseEntry(toBytes(keyString));
DatabaseEntry data = new DatabaseEntry();
- if (changelogStateDb.get(null, key, data, DEFAULT) == NOTFOUND)
+ if (changelogStateDb.get(null, key, data, LockMode.DEFAULT) == NOTFOUND)
{
Transaction txn = dbEnvironment.beginTransaction(null, null);
try
@@ -509,8 +506,7 @@
{
final DatabaseEntry key = new DatabaseEntry(toBytes(keyString));
final DatabaseEntry data = new DatabaseEntry();
- OperationStatus status = changelogStateDb.get(null, key, data, DEFAULT);
- if (status == SUCCESS)
+ if (changelogStateDb.get(null, key, data, LockMode.DEFAULT) == SUCCESS)
{
Transaction txn = dbEnvironment.beginTransaction(null, null);
try
--
Gitblit v1.10.0