From a4b40df77f7bde226616cd132a4e5a31d8983f82 Mon Sep 17 00:00:00 2001
From: boli <boli@localhost>
Date: Fri, 23 Feb 2007 19:22:39 +0000
Subject: [PATCH] Changed ID2Entry#getRecordCount to use the Database#count method in JE 3.1.0. The JE backend no longer keeps a count of entries in entry ID 0. Modified TestVerifyJob unit test to no longer simulate a incorrect entry count.
---
opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java | 62 +-----------------------------
1 files changed, 3 insertions(+), 59 deletions(-)
diff --git a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
index f2439af..5a9a956 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/backends/jeb/ID2Entry.java
@@ -22,7 +22,7 @@
* CDDL HEADER END
*
*
- * Portions Copyright 2006 Sun Microsystems, Inc.
+ * Portions Copyright 2006 - 2007 Sun Microsystems, Inc.
*/
package org.opends.server.backends.jeb;
@@ -296,70 +296,14 @@
/**
* Get the count of the number of entries stored.
*
- * @param txn A JE database transaction to be used for database access, or
- * null if none is required.
* @return The number of entries stored.
*
* @throws DatabaseException If an error occurs in the JE database.
*/
- public long getRecordCount(Transaction txn) throws DatabaseException
+ public long getRecordCount() throws DatabaseException
{
- DatabaseEntry key;
- DatabaseEntry data = new DatabaseEntry();
-
- // The count is stored in a special record whose key is entry ID zero.
- EntryID id = new EntryID(0);
- key = id.getDatabaseEntry();
-
// Read the current count, if any.
- OperationStatus status = EntryContainer.read(getDatabase(), txn,
- key, data, LockMode.DEFAULT);
-
- // Parse the current count.
- long count = 0;
- if (status == OperationStatus.SUCCESS)
- {
- count = JebFormat.entryIDFromDatabase(data.getData());
- }
-
- return count;
+ return EntryContainer.count(getDatabase());
}
- /**
- * Adjust the count of the number of entries stored.
- *
- * @param txn A database transaction, required to be non-null if multiple
- * threads are calling this method concurrently.
- * @param deltaCount Amount to increment (or decrement if negative).
- * @throws DatabaseException If an error occurs in the JE database.
- */
- public void adjustRecordCount(Transaction txn, long deltaCount)
- throws DatabaseException
- {
- DatabaseEntry key;
- DatabaseEntry data = new DatabaseEntry();
-
- // The count is stored in a special record whose key is entry ID zero.
- EntryID id = new EntryID(0);
- key = id.getDatabaseEntry();
-
- // Read the current count, if any.
- OperationStatus status = EntryContainer.read(getDatabase(), txn,
- key, data, LockMode.RMW);
-
- // Parse the current count.
- long count = 0;
- if (status == OperationStatus.SUCCESS)
- {
- count = JebFormat.entryIDFromDatabase(data.getData());
- }
-
- // Adjust the count.
- count += deltaCount;
-
- // Write it.
- byte[] bytes = JebFormat.entryIDToDatabase(count);
- data.setData(bytes);
- EntryContainer.put(getDatabase(), txn, key, data);
- }
}
--
Gitblit v1.10.0