From 7bcb81dd86201dc52b82ce18cfa00af463683a8f Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Tue, 11 Jun 2013 15:38:13 +0000
Subject: [PATCH] Partial fix for OPENDJ-885: Replication replay may lose changes if it can't acquire a writeLock
---
opends/src/server/org/opends/server/extensions/FIFOEntryCache.java | 25 +++++++++++--------------
1 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java b/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
index d23f0ea..c3e72af 100644
--- a/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
+++ b/opends/src/server/org/opends/server/extensions/FIFOEntryCache.java
@@ -23,7 +23,7 @@
*
*
* Copyright 2006-2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2012 ForgeRock AS
+ * Portions Copyright 2011-2013 ForgeRock AS
*/
package org.opends.server.extensions;
@@ -53,6 +53,7 @@
import org.opends.server.types.DN;
import org.opends.server.types.Entry;
import org.opends.server.types.InitializationException;
+import org.opends.server.types.LockManager;
import org.opends.server.types.SearchFilter;
import org.opends.server.types.Attribute;
import org.opends.server.util.ServerConstants;
@@ -126,6 +127,10 @@
// Currently registered configuration object.
private FIFOEntryCacheCfg registeredConfiguration;
+ // The maximum length of time to try to obtain a lock before giving
+ // up.
+ private long lockTimeout = LockManager.DEFAULT_TIMEOUT;
+
/**
@@ -320,7 +325,7 @@
// Obtain a lock on the cache. If this fails, then don't do anything.
try
{
- if (!cacheWriteLock.tryLock(getLockTimeout(), TimeUnit.MILLISECONDS))
+ if (!cacheWriteLock.tryLock(lockTimeout, TimeUnit.MILLISECONDS))
{
return;
}
@@ -450,7 +455,7 @@
// Obtain a lock on the cache. If this fails, then don't do anything.
try
{
- if (!cacheWriteLock.tryLock(getLockTimeout(), TimeUnit.MILLISECONDS))
+ if (!cacheWriteLock.tryLock(lockTimeout, TimeUnit.MILLISECONDS))
{
// We can't rule out the possibility of a conflict, so return false.
return false;
@@ -1026,11 +1031,9 @@
{
maxEntries = newMaxEntries;
maxAllowedMemory = newMaxAllowedMemory;
-
- setLockTimeout(newLockTimeout);
+ lockTimeout = newLockTimeout;
setIncludeFilters(newIncludeFilters);
setExcludeFilters(newExcludeFilters);
-
registeredConfiguration = configuration;
}
@@ -1083,15 +1086,9 @@
/**
- * Return a verbose string representation of the current cache maps.
- * This is useful primary for debugging and diagnostic purposes such
- * as in the entry cache unit tests.
- * @return String verbose string representation of the current cache
- * maps in the following format: dn:id:backend
- * one cache entry map representation per line
- * or <CODE>null</CODE> if all maps are empty.
+ * {@inheritDoc}
*/
- private String toVerboseString()
+ public String toVerboseString()
{
StringBuilder sb = new StringBuilder();
--
Gitblit v1.10.0