From eaa95348ed85ad3d9909e8e703bdeae31a48e0ab Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Wed, 17 Dec 2014 15:47:14 +0000
Subject: [PATCH] OPENDJ-1602 (CR-5566) New pluggable storage based backend
---
opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java | 53 +++++++++++++++++++++++------------------------------
1 files changed, 23 insertions(+), 30 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
index b726ef7..49bee84 100644
--- a/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
+++ b/opendj3-server-dev/src/server/org/opends/server/backends/pluggable/DatabaseContainer.java
@@ -83,7 +83,7 @@
txn.openTree(treeName);
if (logger.isTraceEnabled())
{
- logger.trace("JE database %s opened. txnid=%d", treeName, txn.getId());
+ logger.trace("JE database %s opened. txn=%s", treeName, txn);
}
}
@@ -105,11 +105,7 @@
@Override
public synchronized void close() throws StorageRuntimeException
{
- if(dbConfig.getDeferredWrite())
- {
- treeName.sync();
- }
- treeName.close();
+ storage.closeTree(treeName);
treeName = null;
if(logger.isTraceEnabled())
@@ -213,7 +209,7 @@
*/
public long getRecordCount(ReadableStorage txn) throws StorageRuntimeException
{
- long count = treeName.count();
+ long count = count(txn);
if (logger.isTraceEnabled())
{
logger.trace(messageToLog(true, treeName, null, null, null));
@@ -221,6 +217,24 @@
return count;
}
+ private long count(ReadableStorage txn)
+ {
+ final Cursor cursor = txn.openCursor(treeName);
+ try
+ {
+ long count = 0;
+ while (cursor.next())
+ {
+ count++;
+ }
+ return count;
+ }
+ finally
+ {
+ cursor.close();
+ }
+ }
+
/**
* Get a string representation of this object.
* @return return A string representation of this object.
@@ -242,20 +256,6 @@
}
/**
- * Preload the database into cache.
- *
- * @param config The preload configuration.
- * @return Statistics about the preload process.
- * @throws StorageRuntimeException If an JE database error occurs
- * during the preload.
- */
- public PreloadStats preload(PreloadConfig config)
- throws StorageRuntimeException
- {
- return treeName.preload(config);
- }
-
- /**
* Set the JE database name to use for this container.
*
* @param name The database name to use for this container.
@@ -277,15 +277,8 @@
builder.append(treeName);
if (txn != null)
{
- builder.append(" txnid=");
- try
- {
- builder.append(txn.getId());
- }
- catch (StorageRuntimeException de)
- {
- builder.append(de);
- }
+ builder.append(" txn=");
+ builder.append(txn);
}
else
{
--
Gitblit v1.10.0