From 290993785f0c4cefdf048c5a116c0d318eb83fd2 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 08 Apr 2015 07:59:47 +0000
Subject: [PATCH] Minor code simplification and fix for incorrect trace logging.
---
opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java | 47 ++++++++++++++++++++---------------------------
1 files changed, 20 insertions(+), 27 deletions(-)
diff --git a/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java b/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
index 83bf6ec..001cf63 100644
--- a/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
+++ b/opendj-sdk/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/DefaultIndex.java
@@ -169,8 +169,8 @@
}
}
- public final void update(WriteableTransaction txn, ByteString key, EntryIDSet deletedIDs, EntryIDSet addedIDs)
- throws StorageRuntimeException
+ public final void update(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs,
+ final EntryIDSet addedIDs) throws StorageRuntimeException
{
/*
* Check the special condition where both deletedIDs and addedIDs are null. This is used when
@@ -180,7 +180,7 @@
if (deletedIDs == null && addedIDs == null)
{
boolean success = txn.delete(getName(), key);
- if (success && logger.isTraceEnabled())
+ if (!success && logger.isTraceEnabled())
{
StringBuilder builder = new StringBuilder();
StaticUtils.byteArrayToHexPlusAscii(builder, key.toByteArray(), 4);
@@ -195,33 +195,16 @@
return;
}
- if (maintainCount)
+ /*
+ * Avoid taking a write lock on a record which has hit all IDs because it is likely to be a
+ * point of contention.
+ */
+ if (!maintainCount && !get(txn, key).isDefined())
{
- update0(txn, key, deletedIDs, addedIDs);
+ return;
}
- else if (get(txn, key).isDefined())
- {
- /*
- * Avoid taking a write lock on a record which has hit all IDs because it is likely to be a
- * point of contention.
- */
- update0(txn, key, deletedIDs, addedIDs);
- } // else the record exists but we've hit all IDs.
- }
- private boolean isNullOrEmpty(EntryIDSet entryIDSet)
- {
- return entryIDSet == null || entryIDSet.size() == 0;
- }
-
- private boolean isNotEmpty(EntryIDSet entryIDSet)
- {
- return entryIDSet != null && entryIDSet.size() > 0;
- }
-
- private void update0(final WriteableTransaction txn, final ByteString key, final EntryIDSet deletedIDs,
- final EntryIDSet addedIDs) throws StorageRuntimeException
- {
+ // The record is going to be changed in some way.
txn.update(getName(), key, new UpdateFunction()
{
@Override
@@ -254,6 +237,16 @@
});
}
+ private boolean isNullOrEmpty(EntryIDSet entryIDSet)
+ {
+ return entryIDSet == null || entryIDSet.size() == 0;
+ }
+
+ private boolean isNotEmpty(EntryIDSet entryIDSet)
+ {
+ return entryIDSet != null && entryIDSet.size() > 0;
+ }
+
private EntryIDSet computeEntryIDSet(ByteString key, ByteString value, EntryIDSet deletedIDs, EntryIDSet addedIDs)
{
EntryIDSet entryIDSet = codec.decode(key, value);
--
Gitblit v1.10.0