You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2012/02/23 11:13:26 UTC
svn commit: r1292731 [1/2] - in /directory/jdbm/trunk: ./ jdbm2/
jdbm2/src/main/java/jdbm/ jdbm2/src/main/java/jdbm/btree/
jdbm2/src/main/java/jdbm/helper/ jdbm2/src/main/java/jdbm/htree/
jdbm2/src/main/java/jdbm/recman/ jdbm2/src/main/resources/ jdbm2...
Author: elecharny
Date: Thu Feb 23 10:13:25 2012
New Revision: 1292731
URL: http://svn.apache.org/viewvc?rev=1292731&view=rev
Log:
Added the jdbm2 module
Added:
directory/jdbm/trunk/jdbm2/
- copied from r1292561, directory/apacheds/trunk/jdbm2/
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/I18n.java
directory/jdbm/trunk/jdbm2/src/main/resources/
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/errors.properties
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/errors_de.properties
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/errors_fr.properties
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/messages.properties
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/messages_de.properties
directory/jdbm/trunk/jdbm2/src/main/resources/jdbm/messages_fr.properties
Modified:
directory/jdbm/trunk/jdbm2/pom.xml
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/RecordManagerFactory.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BPage.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BTree.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ByteArrayComparator.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/Conversion.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/IntegerComparator.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/LongComparator.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/MRU.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ObjectBAComparator.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/SoftCache.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/StringComparator.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashBucket.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashDirectory.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BaseRecordManager.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BlockIo.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/CacheRecordManager.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/DataPage.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/FileHeader.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/LogicalRowIdManager.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageHeader.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageManager.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/Provider.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordFile.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordHeader.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/SnapshotRecordManager.java
directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/TransactionManager.java
directory/jdbm/trunk/pom.xml
Modified: directory/jdbm/trunk/jdbm2/pom.xml
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/pom.xml?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/pom.xml (original)
+++ directory/jdbm/trunk/jdbm2/pom.xml Thu Feb 23 10:13:25 2012
@@ -20,16 +20,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-parent</artifactId>
- <version>2.0.0-M6-SNAPSHOT</version>
+ <groupId>org.apache.directory.jdbm</groupId>
+ <artifactId>apacheds-jdbm-parent</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>apacheds-jdbm2</artifactId>
- <name>ApacheDS JDBM implementation</name>
+ <name>ApacheDS JDBM implementation MVCC</name>
<packaging>bundle</packaging>
- <description>Specific JDBM Implementation</description>
+ <description>Specific JDBM Implementation with MVCC</description>
<dependencies>
<dependency>
@@ -37,11 +37,6 @@
<artifactId>junit-addons</artifactId>
<scope>test</scope>
</dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>apacheds-i18n</artifactId>
- </dependency>
</dependencies>
<build>
@@ -79,7 +74,7 @@
<configuration>
<manifestLocation>META-INF</manifestLocation>
<instructions>
- <Bundle-SymbolicName>${project.groupId}.jdbm2</Bundle-SymbolicName>
+ <Bundle-SymbolicName>${project.groupId}.jdbm</Bundle-SymbolicName>
<Export-Package>
{local-packages};version=${project.version};-noimport:=true
</Export-Package>
Added: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/I18n.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/I18n.java?rev=1292731&view=auto
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/I18n.java (added)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/I18n.java Thu Feb 23 10:13:25 2012
@@ -0,0 +1,203 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package jdbm;
+
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+
+/**
+ * Provides i18n handling of error codes.
+ * About formatting see also {@link MessageFormat}
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum I18n
+{
+ ERR_513("ERR_513"),
+ ERR_514("ERR_514"),
+ ERR_515("ERR_515"),
+ ERR_516("ERR_516"),
+ ERR_517("ERR_517"),
+ ERR_518("ERR_518"),
+ ERR_519("ERR_519"),
+ // ERR_520( "ERR_520" ),
+ // ERR_521( "ERR_521" ),
+ ERR_522("ERR_522"),
+ ERR_523("ERR_523"),
+ ERR_524("ERR_524"),
+ ERR_525("ERR_525"),
+ ERR_526("ERR_526"),
+ ERR_527("ERR_527"),
+ ERR_528("ERR_528"),
+ ERR_529("ERR_529"),
+ // ERR_530( "ERR_530" ),
+ ERR_531("ERR_531"),
+ ERR_532("ERR_532"),
+ ERR_533("ERR_533"),
+ ERR_534("ERR_534"),
+ ERR_535("ERR_535"),
+ ERR_536("ERR_536"),
+ ERR_537("ERR_537"),
+ ERR_538("ERR_538"),
+ ERR_539_BAD_BLOCK_ID("ERR_539_BAD_BLOCK_ID"),
+ ERR_540("ERR_540"),
+ ERR_541("ERR_541"),
+ ERR_542("ERR_542"),
+ ERR_543("ERR_543"),
+ ERR_544("ERR_544"),
+ ERR_545("ERR_545"),
+ ERR_546("ERR_546"),
+ ERR_547("ERR_547"),
+ ERR_548("ERR_548"),
+ ERR_549("ERR_549"),
+ ERR_550("ERR_550"),
+ ERR_551("ERR_551"),
+ ERR_552("ERR_552"),
+ ERR_553("ERR_553"),
+ ERR_554("ERR_554"),
+ ERR_555("ERR_555"),
+ ERR_556("ERR_556"),
+ ERR_557("ERR_557"),
+ ERR_558("ERR_558"),
+ ERR_559("ERR_559"),
+ ERR_560("ERR_560"),
+ ERR_561("ERR_561"),
+ ERR_562("ERR_562"),
+ ERR_563("ERR_563"),
+ ERR_564("ERR_564"),
+ ERR_565("ERR_565"),
+ ERR_566("ERR_566"),
+ ERR_567("ERR_567");
+
+ private static ResourceBundle errBundle = ResourceBundle
+ .getBundle( "jdbm.errors" );
+
+ private final static ResourceBundle msgBundle = ResourceBundle
+ .getBundle( "jdbm/messages" );
+
+ /** The error code */
+ private String errorCode;
+
+
+ /**
+ * Creates a new instance of I18n.
+ */
+ private I18n( String errorCode )
+ {
+ this.errorCode = errorCode;
+ }
+
+
+ /**
+ * @return the errorCode
+ */
+ public String getErrorCode()
+ {
+ return errorCode;
+ }
+
+
+ /**
+ *
+ * Translate an error code with argument(s)
+ *
+ * @param err The error code
+ * @param args The argument(s)
+ * @return The translate error code
+ */
+ public static String err( I18n err, Object... args )
+ {
+ try
+ {
+ return err + " " + MessageFormat.format( errBundle.getString( err.getErrorCode() ), args );
+ }
+ catch ( Exception e )
+ {
+ StringBuffer sb = new StringBuffer();
+ boolean comma = false;
+
+ for ( Object obj : args )
+ {
+ if ( comma )
+ {
+ sb.append( "," );
+ }
+ else
+ {
+ comma = true;
+ }
+
+ sb.append( obj );
+ }
+
+ return err + " (" + sb.toString() + ")";
+ }
+ }
+
+
+ /**
+ *
+ * Translate a message with argument(s)
+ *
+ * @param msg The message
+ * @param args The argument(s)
+ * @return The translated message
+ */
+ public static String msg( String msg, Object... args )
+ {
+ try
+ {
+ return MessageFormat.format( msgBundle.getString( msg ), args );
+ }
+ catch ( MissingResourceException mre )
+ {
+ try
+ {
+ return MessageFormat.format( msg, args );
+ }
+ catch ( Exception e )
+ {
+ StringBuffer sb = new StringBuffer();
+ boolean comma = false;
+
+ for ( Object obj : args )
+ {
+ if ( comma )
+ {
+ sb.append( "," );
+ }
+ else
+ {
+ comma = true;
+ }
+
+ sb.append( obj );
+ }
+
+ return msg + " (" + sb.toString() + ")";
+ }
+ }
+ }
+}
+
\ No newline at end of file
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/RecordManagerFactory.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/RecordManagerFactory.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/RecordManagerFactory.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/RecordManagerFactory.java Thu Feb 23 10:13:25 2012
@@ -51,8 +51,6 @@ package jdbm;
import java.io.IOException;
import java.util.Properties;
-import org.apache.directory.server.i18n.I18n;
-
/**
* This is the factory class to use for instantiating {@link RecordManager}
@@ -99,12 +97,12 @@ public final class RecordManagerFactory
provider = options.getProperty( RecordManagerOptions.PROVIDER_FACTORY, "jdbm.recman.Provider" );
- try
+ try
{
clazz = Thread.currentThread().getContextClassLoader().loadClass( provider );
factory = ( RecordManagerProvider ) clazz.newInstance();
- }
- catch ( Exception except )
+ }
+ catch ( Exception except )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_567, provider, except.getClass().getName(),
except.getLocalizedMessage() ) );
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BPage.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BPage.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BPage.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BPage.java Thu Feb 23 10:13:25 2012
@@ -61,7 +61,7 @@ import jdbm.helper.Serializer;
import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -82,7 +82,7 @@ import org.apache.directory.server.i18n.
* @author <a href="mailto:boisvert@intalio.com">Alex Boisvert</a>
*/
public class BPage<K, V> implements Serializer
-{
+{
private static final boolean DEBUG = false;
/** Version id for serialization. */
@@ -327,7 +327,7 @@ public class BPage<K, V> implements Seri
/**
* Find first entry and return a browser positioned before it.
- *@param context Action Context in case of
+ *@param context Action Context in case of
* @return TupleBrowser positionned just before the first entry.
*/
TupleBrowser<K, V> findFirst( ActionContext context ) throws IOException
@@ -391,7 +391,7 @@ public class BPage<K, V> implements Seri
}
// This is to deal with the special case where the key already exists.
- // In this case, the index will contain the key's position, but as a
+ // In this case, the index will contain the key's position, but as a
// negative number
if ( keyExists )
{
@@ -460,7 +460,7 @@ public class BPage<K, V> implements Seri
// if we get here, we need to insert a new entry on the BPage
// before children[ index ]
if ( !pageNewCopy.isFull() )
- {
+ {
if ( height == 0 )
{
insertEntry( pageNewCopy, index - 1, key, value );
@@ -857,7 +857,7 @@ public class BPage<K, V> implements Seri
* Find the first children node with a key equal or greater than the given
* key.
*
- * @return index of first children with equal or greater key. If the
+ * @return index of first children with equal or greater key. If the
* key already exists, the index value will be negative
*/
private int findChildren( K key )
@@ -1119,7 +1119,7 @@ public class BPage<K, V> implements Seri
for ( int i = first; i < btree.pageSize; i++ )
{
if ( keys[i] == null )
- {
+ {
break;
}
@@ -1279,7 +1279,7 @@ public class BPage<K, V> implements Seri
}
- /**
+ /**
* Serialize the content of an object into a byte array.
*
* @param obj Object to serialize
@@ -1413,7 +1413,7 @@ public class BPage<K, V> implements Seri
/**
* New version of the page doing the remove
*/
- BPage<K, V> pageNewCopy;
+ BPage<K, V> pageNewCopy;
}
@@ -1439,7 +1439,7 @@ public class BPage<K, V> implements Seri
* Create a browser.
*
* @param page Current page
- * @param context context in case of action capable record manager
+ * @param context context in case of action capable record manager
* @param index Position of the next tuple to return.
*/
Browser( BPage<K, V> page, int index, ActionContext context)
@@ -1462,24 +1462,24 @@ public class BPage<K, V> implements Seri
*/
public boolean getNext( Tuple<K, V> tuple ) throws IOException
{
- btree.setAsCurrentAction( context );
+ btree.setAsCurrentAction( context );
try
{
- // First, check that we are within a page
+ // First, check that we are within a page
if ( index < page.btree.pageSize )
{
- // We are. Now check that we have a Tuple
+ // We are. Now check that we have a Tuple
if ( page.keys[index] == null )
{
- // no : reached end of the tree.
+ // no : reached end of the tree.
return false;
}
}
- // all the tuple for this page has been read. Move to the
- // next page, if we have one.
+ // all the tuple for this page has been read. Move to the
+ // next page, if we have one.
else if ( page.next != 0 )
{
- // move to next page
+ // move to next page
page = page.loadBPage( page.next );
index = page.first;
}
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BTree.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BTree.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BTree.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/btree/BTree.java Thu Feb 23 10:13:25 2012
@@ -64,7 +64,7 @@ import jdbm.helper.Serializer;
import jdbm.helper.Tuple;
import jdbm.helper.TupleBrowser;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -140,7 +140,7 @@ public class BTree<K, V> implements Exte
/** Big lock snychronizing all actions */
- private transient Lock bigLock = new ReentrantLock();
+ private transient Lock bigLock = new ReentrantLock();
/** Meta root used to access versions of Btree root */
private transient MetaRoot metaRoot = new MetaRoot();
@@ -233,7 +233,7 @@ public class BTree<K, V> implements Exte
this.bpageSerializer.btree = this;
this.nbEntries = new AtomicInteger( 0 );
- this.isActionCapable = recordManager instanceof ActionRecordManager;
+ this.isActionCapable = recordManager instanceof ActionRecordManager;
boolean abortedAction = false;
ActionContext context = this.beginAction( false, "createInstance" );
@@ -542,7 +542,7 @@ public class BTree<K, V> implements Exte
}
try
- {
+ {
tuple = new Tuple<K, V>( null, null );
browser = browse( key );
@@ -602,7 +602,7 @@ public class BTree<K, V> implements Exte
}
if ( !isActionCapable )
- {
+ {
bigLock.lock();
}
@@ -739,7 +739,7 @@ public class BTree<K, V> implements Exte
* @return the root BPage<Object, Object>, or null if it doesn't exist.
*/
BPage<K, V> getRoot( ) throws IOException
- {
+ {
if ( rootId != metaRoot.rootID )
{
throw new IllegalStateException( "Stale root id " + this.rootId + " "+ metaRoot.rootID );
@@ -788,7 +788,7 @@ public class BTree<K, V> implements Exte
MetaRoot getMetaRoot() throws IOException
{
if ( isActionCapable )
- {
+ {
MetaRoot readRoot = ( MetaRoot )recordManager.fetch( -this.recordId );
if ( readRoot != null )
@@ -943,7 +943,7 @@ public class BTree<K, V> implements Exte
metaRoot.treeHeight = newTreeHeight;
if ( isActionCapable )
- {
+ {
recordManager.update( -this.recordId, metaRoot );
}
}
@@ -998,7 +998,7 @@ public class BTree<K, V> implements Exte
/**
* Used to point to the root page that the reader needs based on the reader's
- * read action context. ReadWrite actions always use the latest root.
+ * read action context. ReadWrite actions always use the latest root.
*/
class MetaRoot
{
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ByteArrayComparator.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ByteArrayComparator.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ByteArrayComparator.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ByteArrayComparator.java Thu Feb 23 10:13:25 2012
@@ -49,7 +49,7 @@ package jdbm.helper;
import java.util.Comparator;
import java.io.Serializable;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Comparator for byte arrays.
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/Conversion.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/Conversion.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/Conversion.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/Conversion.java Thu Feb 23 10:13:25 2012
@@ -46,7 +46,7 @@
package jdbm.helper;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -201,23 +201,23 @@ public class Conversion
{
byte[] buf;
- buf = convertToByteArray( (int) 5 );
+ buf = convertToByteArray( 5 );
System.out.println( "int value of 5 is: " + convertToInt( buf ) );
- buf = convertToByteArray( (int) -1 );
+ buf = convertToByteArray( -1 );
System.out.println( "int value of -1 is: " + convertToInt( buf ) );
- buf = convertToByteArray( (int) 22111000 );
+ buf = convertToByteArray( 22111000 );
System.out.println( "int value of 22111000 is: " + convertToInt( buf ) );
- buf = convertToByteArray( (long) 5L );
+ buf = convertToByteArray( 5L );
System.out.println( "long value of 5 is: " + convertToLong( buf ) );
- buf = convertToByteArray( (long) -1L );
+ buf = convertToByteArray( -1L );
System.out.println( "long value of -1 is: " + convertToLong( buf ) );
- buf = convertToByteArray( (long) 1112223334445556667L );
+ buf = convertToByteArray( 1112223334445556667L );
System.out.println( "long value of 1112223334445556667 is: " + convertToLong( buf ) );
}
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/IntegerComparator.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/IntegerComparator.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/IntegerComparator.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/IntegerComparator.java Thu Feb 23 10:13:25 2012
@@ -49,7 +49,7 @@ package jdbm.helper;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Comparator for Integer objects.
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/LongComparator.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/LongComparator.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/LongComparator.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/LongComparator.java Thu Feb 23 10:13:25 2012
@@ -49,7 +49,7 @@ package jdbm.helper;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Comparator for java.lang.Long objects.
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/MRU.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/MRU.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/MRU.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/MRU.java Thu Feb 23 10:13:25 2012
@@ -55,7 +55,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -244,7 +244,7 @@ public class MRU<K, V> implements CacheP
/**
- * Remove a CacheEntry from linked list, and relink the
+ * Remove a CacheEntry from linked list, and relink the
* remaining element sin the list.
*/
protected void removeEntry( CacheEntry entry )
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ObjectBAComparator.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ObjectBAComparator.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ObjectBAComparator.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/ObjectBAComparator.java Thu Feb 23 10:13:25 2012
@@ -50,7 +50,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Comparator for objects which have been serialized into byte arrays.
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/SoftCache.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/SoftCache.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/SoftCache.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/SoftCache.java Thu Feb 23 10:13:25 2012
@@ -54,7 +54,7 @@ import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/StringComparator.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/StringComparator.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/StringComparator.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/helper/StringComparator.java Thu Feb 23 10:13:25 2012
@@ -49,7 +49,7 @@ package jdbm.helper;
import java.io.Serializable;
import java.util.Comparator;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Comparator for String objects. Delegates to String.compareTo().
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashBucket.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashBucket.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashBucket.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashBucket.java Thu Feb 23 10:13:25 2012
@@ -53,7 +53,7 @@ import java.io.ObjectOutput;
import java.util.ArrayList;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* A bucket is a placeholder for multiple (key, value) pairs. Buckets
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashDirectory.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashDirectory.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashDirectory.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/htree/HashDirectory.java Thu Feb 23 10:13:25 2012
@@ -57,7 +57,7 @@ import jdbm.RecordManager;
import jdbm.helper.FastIterator;
import jdbm.helper.IterationException;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Hashtable directory page.
@@ -464,8 +464,8 @@ final class HashDirectory
* Returns the next object.
*/
public Object next()
- {
- Object next = null;
+ {
+ Object next = null;
if( _iter != null && _iter.hasNext() ) {
next = _iter.next();
} else {
@@ -478,7 +478,7 @@ final class HashDirectory
return next();
}
}
- return next;
+ return next;
}
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BaseRecordManager.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BaseRecordManager.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BaseRecordManager.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BaseRecordManager.java Thu Feb 23 10:13:25 2012
@@ -60,7 +60,7 @@ import jdbm.RecordManager;
import jdbm.helper.DefaultSerializer;
import jdbm.helper.Serializer;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -323,7 +323,7 @@ public final class BaseRecordManager imp
LockElement element;
checkIfClosed();
- if ( recid <= 0 )
+ if ( recid <= 0 )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
@@ -374,7 +374,7 @@ public final class BaseRecordManager imp
checkIfClosed();
- if ( recid <= 0 )
+ if ( recid <= 0 )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
@@ -392,7 +392,7 @@ public final class BaseRecordManager imp
Location newRecid = physMgr.update( physRecid, data, 0, data.length );
- if ( ! newRecid.equals( physRecid ) )
+ if ( ! newRecid.equals( physRecid ) )
{
logMgr.update( logRecid, newRecid );
}
@@ -400,7 +400,7 @@ public final class BaseRecordManager imp
finally
{
endIO( recid, element, IOType.WRITE_IO );
- }
+ }
}
@@ -432,7 +432,7 @@ public final class BaseRecordManager imp
checkIfClosed();
- if ( recid <= 0 )
+ if ( recid <= 0 )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
@@ -441,7 +441,7 @@ public final class BaseRecordManager imp
try
{
- byte[] data;
+ byte[] data;
Location location = logMgr.fetch( new Location( recid ) ) ;
data = physMgr.fetch( location );
@@ -508,7 +508,7 @@ public final class BaseRecordManager imp
Map<String,Long> nameDirectory = getNameDirectory();
Long recid = nameDirectory.get( name );
- if ( recid == null )
+ if ( recid == null )
{
return 0;
}
@@ -524,12 +524,12 @@ public final class BaseRecordManager imp
{
checkIfClosed();
- if ( recid == 0 )
+ if ( recid == 0 )
{
// remove from hashtable
getNameDirectory().remove( name );
- }
- else
+ }
+ else
{
getNameDirectory().put( name, recid );
}
@@ -569,13 +569,13 @@ public final class BaseRecordManager imp
// retrieve directory of named hashtable
long nameDirectory_recid = getRoot( NAME_DIRECTORY_ROOT );
- if ( nameDirectory_recid == 0 )
+ if ( nameDirectory_recid == 0 )
{
nameDirectory = new HashMap<String, Long>();
nameDirectory_recid = insert( nameDirectory );
setRoot( NAME_DIRECTORY_ROOT, nameDirectory_recid );
- }
- else
+ }
+ else
{
nameDirectory = ( Map<String, Long> ) fetch( nameDirectory_recid );
}
@@ -588,7 +588,7 @@ public final class BaseRecordManager imp
{
long recid = getRoot( NAME_DIRECTORY_ROOT );
- if ( recid == 0 )
+ if ( recid == 0 )
{
throw new IOException( I18n.err( I18n.ERR_537 ) );
}
@@ -602,7 +602,7 @@ public final class BaseRecordManager imp
*/
private void checkIfClosed() throws IllegalStateException
{
- if ( recordFile == null )
+ if ( recordFile == null )
{
throw new IllegalStateException( I18n.err( I18n.ERR_538 ) );
}
@@ -610,9 +610,9 @@ public final class BaseRecordManager imp
/**
- * Used to serialize reads/write on a given logical rowid. Checks if there is a
+ * Used to serialize reads/write on a given logical rowid. Checks if there is a
* ongoing conflicting IO to the same logical rowid and waits for the ongoing
- * write if there is one.
+ * write if there is one.
*
* @param recid the logical rowid for which the fetch will be done.
* @param io type of the IO
@@ -758,7 +758,7 @@ public final class BaseRecordManager imp
private boolean conflictingIOPredicate( IOType io, LockElement element )
{
if ( io == IOType.READ_IO )
- {
+ {
return element.beingWritten();
}
else
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BlockIo.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BlockIo.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BlockIo.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/BlockIo.java Thu Feb 23 10:13:25 2012
@@ -53,13 +53,13 @@ import java.io.ObjectOutput;
import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
- * This class wraps a page-sized byte array and provides methods to read and
- * write data to and from it. The readers and writers are just the ones that
- * the rest of the toolkit needs, nothing else. Values written are compatible
+ * This class wraps a page-sized byte array and provides methods to read and
+ * write data to and from it. The readers and writers are just the ones that
+ * the rest of the toolkit needs, nothing else. Values written are compatible
* with java.io routines.
*
* This block is never accessed directly, so it does not have to be thread-safe.
@@ -67,7 +67,7 @@ import org.apache.directory.server.i18n.
* @see java.io.DataInput
* @see java.io.DataOutput
*/
-public final class BlockIo implements java.io.Externalizable
+public final class BlockIo implements java.io.Externalizable
{
public final static long serialVersionUID = 2L;
@@ -90,7 +90,7 @@ public final class BlockIo implements ja
/**
* Default constructor for serialization
*/
- public BlockIo()
+ public BlockIo()
{
// empty
}
@@ -102,7 +102,7 @@ public final class BlockIo implements ja
* @param blockId The identifier for this block
* @param data The data to store
*/
- /*No qualifier*/ BlockIo( long blockId, byte[] data )
+ /*No qualifier*/ BlockIo( long blockId, byte[] data )
{
// remove me for production version
if ( blockId < 0 )
@@ -118,7 +118,7 @@ public final class BlockIo implements ja
/**
* @return the underlying array
*/
- /*No qualifier*/ byte[] getData()
+ /*No qualifier*/ byte[] getData()
{
return data;
}
@@ -129,7 +129,7 @@ public final class BlockIo implements ja
*
* @param The block identifier
*/
- /*No qualifier*/ void setBlockId( long blockId )
+ /*No qualifier*/ void setBlockId( long blockId )
{
if ( isInTransaction() )
{
@@ -148,7 +148,7 @@ public final class BlockIo implements ja
/**
* @return the block number.
*/
- /*No qualifier*/ long getBlockId()
+ /*No qualifier*/ long getBlockId()
{
return blockId;
}
@@ -157,7 +157,7 @@ public final class BlockIo implements ja
/**
* @return the current view of the block.
*/
- public BlockView getView()
+ public BlockView getView()
{
return view;
}
@@ -168,7 +168,7 @@ public final class BlockIo implements ja
*
* @param view the current view
*/
- public void setView( BlockView view )
+ public void setView( BlockView view )
{
this.view = view;
}
@@ -177,7 +177,7 @@ public final class BlockIo implements ja
/**
* Sets the dirty flag
*/
- /*No qualifier*/ void setDirty()
+ /*No qualifier*/ void setDirty()
{
dirty = true;
}
@@ -186,7 +186,7 @@ public final class BlockIo implements ja
/**
* Clears the dirty flag
*/
- /*No qualifier*/ void setClean()
+ /*No qualifier*/ void setClean()
{
dirty = false;
}
@@ -195,17 +195,17 @@ public final class BlockIo implements ja
/**
* Returns true if the dirty flag is set.
*/
- /*No qualifier*/ boolean isDirty()
+ /*No qualifier*/ boolean isDirty()
{
return dirty;
}
/**
- * Returns true if the block is still dirty with respect to the
+ * Returns true if the block is still dirty with respect to the
* transaction log.
*/
- /*No qualifier*/ boolean isInTransaction()
+ /*No qualifier*/ boolean isInTransaction()
{
return transactionCount.get() != 0;
}
@@ -216,7 +216,7 @@ public final class BlockIo implements ja
* block is in the log but not yet in the data recordFile. The method also
* takes a snapshot so that the data may be modified in new transactions.
*/
- /*No qualifier*/ void incrementTransactionCount()
+ /*No qualifier*/ void incrementTransactionCount()
{
transactionCount.getAndIncrement();
}
@@ -226,7 +226,7 @@ public final class BlockIo implements ja
* Decrements transaction count for this block, to signal that this
* block has been written from the log to the data recordFile.
*/
- /*No qualifier*/ void decrementTransactionCount()
+ /*No qualifier*/ void decrementTransactionCount()
{
if ( transactionCount.decrementAndGet() < 0 )
{
@@ -241,7 +241,7 @@ public final class BlockIo implements ja
* @param pos the position at which we will read the byte
* @return the read byte
*/
- public byte readByte( int pos )
+ public byte readByte( int pos )
{
return data[pos];
}
@@ -253,7 +253,7 @@ public final class BlockIo implements ja
* @param pos The position where we want to write the value to
* @param value the byte value we want to write into the BlockIo
*/
- public void writeByte( int pos, byte value )
+ public void writeByte( int pos, byte value )
{
data[pos] = value;
dirty = true;
@@ -266,7 +266,7 @@ public final class BlockIo implements ja
* @param pos the position at which we will read the short
* @return the read short
*/
- public short readShort( int pos )
+ public short readShort( int pos )
{
return ( short )
( ( ( data[pos+0] & 0xff ) << 8 ) |
@@ -280,7 +280,7 @@ public final class BlockIo implements ja
* @param pos The position where we want to write the value to
* @param value the short value we want to write into the BlockIo
*/
- public void writeShort( int pos, short value )
+ public void writeShort( int pos, short value )
{
data[pos+0] = ( byte ) ( 0xff & ( value >> 8 ) );
data[pos+1] = ( byte ) ( 0xff & ( value >> 0 ) );
@@ -294,7 +294,7 @@ public final class BlockIo implements ja
* @param pos the position at which we will read the int
* @return the read int
*/
- public int readInt( int pos )
+ public int readInt( int pos )
{
return
( data[pos+0] << 24) |
@@ -310,7 +310,7 @@ public final class BlockIo implements ja
* @param pos The position where we want to write the value to
* @param value the int value we want to write into the BlockIo
*/
- public void writeInt( int pos, int value )
+ public void writeInt( int pos, int value )
{
data[pos+0] = ( byte ) ( 0xff & ( value >> 24 ) );
data[pos+1] = ( byte ) ( 0xff & ( value >> 16 ) );
@@ -329,14 +329,14 @@ public final class BlockIo implements ja
public long readLong( int pos )
{
return
- ( ( long )( (long)data[pos+0] << 56 ) |
+ ( ( (long)data[pos+0] << 56 ) |
( (long)( data[pos+1] & 0xff ) << 48 ) |
( (long)( data[pos+2] & 0xff ) << 40 ) |
( (long)( data[pos+3] & 0xff ) << 32 ) |
( (long)( data[pos+4] & 0xff ) << 24 ) |
( (long)( data[pos+5] & 0xff ) << 16 ) |
( (long)( data[pos+6] & 0xff ) << 8 ) |
- ( (long)( data[pos+7] & 0xff ) ) );
+ ( data[pos+7] & 0xff ) );
}
@@ -362,7 +362,7 @@ public final class BlockIo implements ja
/**
* {@inheritDoc}
*/
- public String toString()
+ public String toString()
{
if ( view != null )
{
@@ -408,7 +408,7 @@ public final class BlockIo implements ja
/**
* implement externalizable interface
*/
- public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+ public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
{
blockId = in.readLong();
int length = in.readInt();
@@ -420,7 +420,7 @@ public final class BlockIo implements ja
/**
* implement externalizable interface
*/
- public void writeExternal( ObjectOutput out ) throws IOException
+ public void writeExternal( ObjectOutput out ) throws IOException
{
out.writeLong( blockId );
out.writeInt( data.length );
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/CacheRecordManager.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/CacheRecordManager.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/CacheRecordManager.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/CacheRecordManager.java Thu Feb 23 10:13:25 2012
@@ -59,7 +59,7 @@ import jdbm.helper.WrappedRuntimeExcepti
import java.io.IOException;
import java.util.Enumeration;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -86,12 +86,12 @@ public class CacheRecordManager implemen
*/
public CacheRecordManager( RecordManager recordManager, CachePolicy<Long,CacheEntry> cache )
{
- if ( recordManager == null )
+ if ( recordManager == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_517 ) );
}
- if ( cache == null )
+ if ( cache == null )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_542 ) );
}
@@ -106,7 +106,7 @@ public class CacheRecordManager implemen
* Get the underlying Record Manager.
*
* @return underlying RecordManager or null if CacheRecordManager has
- * been closed.
+ * been closed.
*/
public RecordManager getRecordManager()
{
@@ -118,7 +118,7 @@ public class CacheRecordManager implemen
* Get the underlying cache policy
*
* @return underlying CachePolicy or null if CacheRecordManager has
- * been closed.
+ * been closed.
*/
public CachePolicy<Long,CacheEntry> getCachePolicy()
{
@@ -153,11 +153,11 @@ public class CacheRecordManager implemen
long recid = recordManager.insert( obj, serializer );
- try
+ try
{
cache.put( recid, new CacheEntry( recid, obj, serializer, false ) );
- }
- catch ( CacheEvictionException except )
+ }
+ catch ( CacheEvictionException except )
{
throw new WrappedRuntimeException( except );
}
@@ -212,19 +212,19 @@ public class CacheRecordManager implemen
try {
CacheEntry entry = cache.get( recid );
- if ( entry != null )
+ if ( entry != null )
{
// reuse existing cache entry
entry.obj = obj;
entry.serializer = serializer;
entry.isDirty = true;
- }
- else
+ }
+ else
{
cache.put( recid, new CacheEntry( recid, obj, serializer, true ) );
}
- }
- catch ( CacheEvictionException except )
+ }
+ catch ( CacheEvictionException except )
{
throw new IOException( except.getLocalizedMessage() );
}
@@ -258,16 +258,16 @@ public class CacheRecordManager implemen
CacheEntry entry = cache.get( recid );
- if ( entry == null )
+ if ( entry == null )
{
entry = new CacheEntry( recid, null, serializer, false );
entry.obj = recordManager.fetch( recid, serializer );
- try
+ try
{
cache.put( recid, entry );
- }
- catch ( CacheEvictionException except )
+ }
+ catch ( CacheEvictionException except )
{
throw new WrappedRuntimeException( except );
}
@@ -394,7 +394,7 @@ public class CacheRecordManager implemen
*/
private void checkIfClosed() throws IllegalStateException
{
- if ( recordManager == null )
+ if ( recordManager == null )
{
throw new IllegalStateException( I18n.err( I18n.ERR_538 ) );
}
@@ -408,11 +408,11 @@ public class CacheRecordManager implemen
{
Enumeration<CacheEntry> enume = cache.elements();
- while ( enume.hasMoreElements() )
+ while ( enume.hasMoreElements() )
{
CacheEntry entry = enume.nextElement();
- if ( entry.isDirty )
+ if ( entry.isDirty )
{
recordManager.update( entry.recid, entry.obj, entry.serializer );
entry.isDirty = false;
@@ -421,7 +421,7 @@ public class CacheRecordManager implemen
}
/**
- * A class to store a cached entry.
+ * A class to store a cached entry.
*/
private static class CacheEntry
{
@@ -444,7 +444,7 @@ public class CacheRecordManager implemen
private class CacheListener implements CachePolicyListener<CacheEntry>
{
- /**
+ /**
* Notification that cache is evicting an object
*
* @param obj object evicted from cache
@@ -452,13 +452,13 @@ public class CacheRecordManager implemen
public void cacheObjectEvicted( CacheEntry obj ) throws CacheEvictionException
{
CacheEntry entry = obj;
- if ( entry.isDirty )
+ if ( entry.isDirty )
{
- try
+ try
{
recordManager.update( entry.recid, entry.obj, entry.serializer );
- }
- catch ( IOException except )
+ }
+ catch ( IOException except )
{
throw new CacheEvictionException( except );
}
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/DataPage.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/DataPage.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/DataPage.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/DataPage.java Thu Feb 23 10:13:25 2012
@@ -21,7 +21,7 @@
*
* 4. Products derived from this Software may not be called "JDBM"
* nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
+ * permission of Cees de Groot.
*
* 5. Due credit should be given to the JDBM Project
* (http://jdbm.sourceforge.net/).
@@ -46,15 +46,13 @@
*/
package jdbm.recman;
-
-
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Class describing a page that holds data.
*/
-final class DataPage extends PageHeader
+final class DataPage extends PageHeader
{
// offsets
/** first short in the file after the page header info: 18 byte offset */
@@ -70,7 +68,7 @@ final class DataPage extends PageHeader
/**
* Constructs a data page view from the indicated block.
*/
- DataPage( BlockIo block )
+ DataPage( BlockIo block )
{
super( block );
}
@@ -79,7 +77,7 @@ final class DataPage extends PageHeader
/**
* Factory method to create or return a data page for the indicated block.
*/
- static DataPage getDataPageView( BlockIo blockIo )
+ static DataPage getDataPageView( BlockIo blockIo )
{
BlockView view = blockIo.getView();
@@ -88,25 +86,25 @@ final class DataPage extends PageHeader
return ( DataPage ) view;
}
else
- {
+ {
return new DataPage( blockIo );
}
}
- /**
- * @return the first rowid's offset
+ /**
+ * @return the first rowid's offset
*/
- short getFirst()
+ short getFirst()
{
return blockIo.readShort( O_FIRST );
}
- /**
- * Sets the first rowid's offset
+ /**
+ * Sets the first rowid's offset
*/
- void setFirst( short value )
+ void setFirst( short value )
{
paranoiaMagicOk();
@@ -122,7 +120,7 @@ final class DataPage extends PageHeader
/**
* {@inheritDoc}
*/
- public String toString()
+ public String toString()
{
StringBuilder sb = new StringBuilder();
@@ -134,7 +132,7 @@ final class DataPage extends PageHeader
// The first rowId
sb.append( "first rowId: " ).append( getFirst() ).append( ", " );
- // The data per page
+ // The data per page
sb.append( "[p:" ).append( getPrev() ).append( ", " );
// The next page
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/FileHeader.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/FileHeader.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/FileHeader.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/FileHeader.java Thu Feb 23 10:13:25 2012
@@ -21,7 +21,7 @@
*
* 4. Products derived from this Software may not be called "JDBM"
* nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
+ * permission of Cees de Groot.
*
* 5. Due credit should be given to the JDBM Project
* (http://jdbm.sourceforge.net/).
@@ -49,7 +49,7 @@ package jdbm.recman;
import java.io.IOException;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -71,9 +71,9 @@ import org.apache.directory.server.i18n.
* <li>[72..79] : The BlockIo reference to the last FREEPHYSIDS_PAGE ID</li>
* <li>[80..87]* : The reference to the BlockIo which is the root for the data contained in this File.
* We may have more than one, but no more than 1014, if the BLOCK_SIZE is 8192</li>
- * </ul>
+ * </ul>
*/
-class FileHeader implements BlockView
+class FileHeader implements BlockView
{
/** Position of the Magic number for FileHeader */
private static final short O_MAGIC = 0; // short magic
@@ -99,7 +99,7 @@ class FileHeader implements BlockView
* @throws IOException if the block is too short to keep the file
* header.
*/
- FileHeader( BlockIo block, boolean isNew )
+ FileHeader( BlockIo block, boolean isNew )
{
this.block = block;
@@ -114,28 +114,28 @@ class FileHeader implements BlockView
}
- /**
- * Returns the offset of the "first" block of the indicated list
+ /**
+ * Returns the offset of the "first" block of the indicated list
*/
- private short offsetOfFirst( int list )
+ private short offsetOfFirst( int list )
{
return ( short ) ( O_LISTS + ( 2 * Magic.SZ_LONG * list ) );
}
- /**
- * Returns the offset of the "last" block of the indicated list
+ /**
+ * Returns the offset of the "last" block of the indicated list
*/
- private short offsetOfLast( int list )
+ private short offsetOfLast( int list )
{
return ( short ) ( offsetOfFirst( list ) + Magic.SZ_LONG );
}
- /**
- * Returns the offset of the indicated root
+ /**
+ * Returns the offset of the indicated root
*/
- private short offsetOfRoot( int root )
+ private short offsetOfRoot( int root )
{
return ( short ) ( O_ROOTS + ( root * Magic.SZ_LONG ) );
}
@@ -144,7 +144,7 @@ class FileHeader implements BlockView
/**
* Returns the first block of the indicated list
*/
- long getFirstOf( int list )
+ long getFirstOf( int list )
{
return block.readLong( offsetOfFirst( list ) );
}
@@ -153,7 +153,7 @@ class FileHeader implements BlockView
/**
* Sets the first block of the indicated list
*/
- void setFirstOf( int list, long value )
+ void setFirstOf( int list, long value )
{
block.writeLong( offsetOfFirst( list ), value );
}
@@ -162,7 +162,7 @@ class FileHeader implements BlockView
/**
* Returns the last block of the indicated list
*/
- long getLastOf( int list )
+ long getLastOf( int list )
{
return block.readLong( offsetOfLast( list ) );
}
@@ -171,7 +171,7 @@ class FileHeader implements BlockView
/**
* Sets the last block of the indicated list
*/
- void setLastOf( int list, long value )
+ void setLastOf( int list, long value )
{
block.writeLong( offsetOfLast( list ), value );
}
@@ -186,7 +186,7 @@ class FileHeader implements BlockView
*
* @see #NROOTS
*/
- long getRoot( int root )
+ long getRoot( int root )
{
return block.readLong( offsetOfRoot( root ) );
}
@@ -198,7 +198,7 @@ class FileHeader implements BlockView
* @see #getRoot
* @see #NROOTS
*/
- void setRoot( int root, long rowid )
+ void setRoot( int root, long rowid )
{
block.writeLong( offsetOfRoot( root ), rowid );
}
@@ -207,7 +207,7 @@ class FileHeader implements BlockView
/**
* {@inheritDoc}
*/
- public String toString()
+ public String toString()
{
StringBuilder sb = new StringBuilder();
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/LogicalRowIdManager.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/LogicalRowIdManager.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/LogicalRowIdManager.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/LogicalRowIdManager.java Thu Feb 23 10:13:25 2012
@@ -50,7 +50,7 @@ package jdbm.recman;
import java.io.IOException;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageHeader.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageHeader.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageHeader.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageHeader.java Thu Feb 23 10:13:25 2012
@@ -21,7 +21,7 @@
*
* 4. Products derived from this Software may not be called "JDBM"
* nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
+ * permission of Cees de Groot.
*
* 5. Due credit should be given to the JDBM Project
* (http://jdbm.sourceforge.net/).
@@ -49,7 +49,7 @@ package jdbm.recman;
import java.io.IOException;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -65,17 +65,17 @@ import org.apache.directory.server.i18n.
*
* The page header block view hence sees 18 bytes of page header data.
*/
-public class PageHeader implements BlockView
+public class PageHeader implements BlockView
{
// offsets into page header's (BlockIo's) buffer
/** the page (BlockIo's type code) short magic code */
- private static final short O_MAGIC = 0;
+ private static final short O_MAGIC = 0;
/** the long block id of the next block in the block list */
- private static final short O_NEXT = Magic.SZ_SHORT;
+ private static final short O_NEXT = Magic.SZ_SHORT;
/** the long block id of the previous block in the block list */
- private static final short O_PREV = O_NEXT + Magic.SZ_LONG;
+ private static final short O_PREV = O_NEXT + Magic.SZ_LONG;
/** the size of this page header */
protected static final short SIZE = O_PREV + Magic.SZ_LONG;
@@ -90,7 +90,7 @@ public class PageHeader implements Block
* @param blockIo The block that contains the page header
* @throws IOException if the block is too short to keep the page header.
*/
- protected PageHeader( BlockIo blockIo )
+ protected PageHeader( BlockIo blockIo )
{
this.blockIo = blockIo;
blockIo.setView( this );
@@ -106,7 +106,7 @@ public class PageHeader implements Block
* Constructs a new PageHeader of the indicated type. Used for newly
* created pages.
*/
- PageHeader( BlockIo blockIo, short type )
+ PageHeader( BlockIo blockIo, short type )
{
this.blockIo = blockIo;
blockIo.setView( this );
@@ -117,7 +117,7 @@ public class PageHeader implements Block
/**
* Factory method to create or return a page header for the indicated block.
*/
- static PageHeader getView ( BlockIo blockIo )
+ static PageHeader getView ( BlockIo blockIo )
{
BlockView view = blockIo.getView();
@@ -135,7 +135,7 @@ public class PageHeader implements Block
/**
* Returns true if the magic corresponds with the fileHeader magic.
*/
- private boolean magicOk()
+ private boolean magicOk()
{
int magic = getMagic();
@@ -147,7 +147,7 @@ public class PageHeader implements Block
/**
* For paranoia mode
*/
- protected void paranoiaMagicOk()
+ protected void paranoiaMagicOk()
{
if ( ! magicOk() )
{
@@ -156,10 +156,10 @@ public class PageHeader implements Block
}
- /**
- * @return The magic code (ie, the 2 first bytes of the inner BlockIo)
+ /**
+ * @return The magic code (ie, the 2 first bytes of the inner BlockIo)
*/
- short getMagic()
+ short getMagic()
{
return blockIo.readShort( O_MAGIC );
}
@@ -168,7 +168,7 @@ public class PageHeader implements Block
/**
* @return the next block (ie the long at position 2 in the BlockIo)
*/
- long getNext()
+ long getNext()
{
paranoiaMagicOk();
@@ -176,22 +176,22 @@ public class PageHeader implements Block
}
- /**
+ /**
* Sets the next blockIo.
*
* @param The next Block ID
*/
- void setNext( long next )
+ void setNext( long next )
{
paranoiaMagicOk();
blockIo.writeLong( O_NEXT, next );
}
- /**
+ /**
* @return the previous block (ie the long at position 10 in the BlockIo)
*/
- long getPrev()
+ long getPrev()
{
paranoiaMagicOk();
@@ -199,22 +199,22 @@ public class PageHeader implements Block
}
- /**
- * Sets the previous block.
+ /**
+ * Sets the previous block.
*/
- void setPrev( long prev )
+ void setPrev( long prev )
{
paranoiaMagicOk();
blockIo.writeLong( O_PREV, prev );
}
- /**
+ /**
* Sets the type of the page header
*
* @param type The PageHeader type to store at position 0
*/
- void setType( short type )
+ void setType( short type )
{
blockIo.writeShort( O_MAGIC, ( short ) ( Magic.BLOCK + type ) );
}
@@ -223,7 +223,7 @@ public class PageHeader implements Block
/**
* {@inheritDoc}
*/
- public String toString()
+ public String toString()
{
StringBuilder sb = new StringBuilder();
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageManager.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageManager.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageManager.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/PageManager.java Thu Feb 23 10:13:25 2012
@@ -21,7 +21,7 @@
*
* 4. Products derived from this Software may not be called "JDBM"
* nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
+ * permission of Cees de Groot.
*
* 5. Due credit should be given to the JDBM Project
* (http://jdbm.sourceforge.net/).
@@ -49,14 +49,14 @@ package jdbm.recman;
import java.io.IOException;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* This class manages the linked lists of pages that make up a recordFile. It contains
* a FileHeadrer and a reference to the recordFile it manages.<br/>
*/
-final class PageManager
+final class PageManager
{
/** our record recordFile */
private RecordFile recordFile;
@@ -76,14 +76,14 @@ final class PageManager
* @param The associated RecordFile
* @throws IOException If there is an issue storing data into the recordFile
*/
- PageManager( RecordFile recordFile ) throws IOException
+ PageManager( RecordFile recordFile ) throws IOException
{
this.recordFile = recordFile;
// Note that we hold on to the recordFile header node.
headerBuf = recordFile.get( 0 );
- // Assume recordFile is new if the recordFile header's magic number is 0.
+ // Assume recordFile is new if the recordFile header's magic number is 0.
boolean isNew = headerBuf.readShort( 0 ) == 0;
header = new FileHeader( headerBuf, isNew );
@@ -91,12 +91,12 @@ final class PageManager
/**
- * Allocates a page of the indicated type.
+ * Allocates a page of the indicated type.
*
* @param The page type we want to allocate
* @return The record ID of the page.
*/
- long allocate( short type ) throws IOException
+ long allocate( short type ) throws IOException
{
if ( type == Magic.FREE_PAGE )
{
@@ -109,13 +109,13 @@ final class PageManager
// Do we have something on the free list?
long freeBlock = header.getFirstOf( Magic.FREE_PAGE );
- if ( freeBlock != 0 )
+ if ( freeBlock != 0 )
{
// yes. Point to it and make the next of that page the
// new first free page.
header.setFirstOf( Magic.FREE_PAGE, getNext( freeBlock ) );
}
- else
+ else
{
// nope. make a new record
freeBlock = header.getLastOf( Magic.FREE_PAGE );
@@ -161,7 +161,7 @@ final class PageManager
recordFile.release( freeBlock, true );
// If there's a previous, fix up its pointer
- if ( oldLast != 0 )
+ if ( oldLast != 0 )
{
buf = recordFile.get( oldLast );
pageHdr = PageHeader.getView( buf );
@@ -179,7 +179,7 @@ final class PageManager
/**
* Frees a page of the indicated type.
*/
- void free( short type, long recid ) throws IOException
+ void free( short type, long recid ) throws IOException
{
if ( type == Magic.FREE_PAGE )
{
@@ -206,26 +206,26 @@ final class PageManager
recordFile.release( recid, true );
// remove the page from its old list
- if ( prev != 0 )
+ if ( prev != 0 )
{
buf = recordFile.get( prev );
pageHdr = PageHeader.getView( buf );
pageHdr.setNext( next );
recordFile.release( prev, true );
}
- else
+ else
{
header.setFirstOf( type, next );
}
- if ( next != 0 )
+ if ( next != 0 )
{
buf = recordFile.get( next );
pageHdr = PageHeader.getView( buf );
pageHdr.setPrev( prev );
recordFile.release( next, true );
}
- else
+ else
{
header.setLastOf( type, prev );
}
@@ -235,13 +235,13 @@ final class PageManager
/**
* Returns the page following the indicated block
*/
- long getNext( long block ) throws IOException
+ long getNext( long block ) throws IOException
{
- try
+ try
{
return PageHeader.getView( recordFile.get( block ) ).getNext();
- }
- finally
+ }
+ finally
{
recordFile.release( block, false );
}
@@ -251,13 +251,13 @@ final class PageManager
/**
* Returns the page before the indicated block
*/
- long getPrev( long block ) throws IOException
+ long getPrev( long block ) throws IOException
{
- try
+ try
{
return PageHeader.getView( recordFile.get( block ) ).getPrev();
- }
- finally
+ }
+ finally
{
recordFile.release( block, false );
}
@@ -267,7 +267,7 @@ final class PageManager
/**
* Returns the first page on the indicated list.
*/
- long getFirst( short type ) throws IOException
+ long getFirst( short type ) throws IOException
{
return header.getFirstOf( type );
}
@@ -276,7 +276,7 @@ final class PageManager
/**
* Returns the last page on the indicated list.
*/
- long getLast( short type ) throws IOException
+ long getLast( short type ) throws IOException
{
return header.getLastOf( type );
}
@@ -287,7 +287,7 @@ final class PageManager
* This forces a flush of all outstanding blocks (this is an implicit
* {@link RecordFile#commit} as well).
*/
- void commit() throws IOException
+ void commit() throws IOException
{
// write the header out
recordFile.release( headerBuf );
@@ -305,7 +305,7 @@ final class PageManager
*
* @TODO completely wrong description of method
*/
- void rollback() throws IOException
+ void rollback() throws IOException
{
// release header
recordFile.discard( headerBuf );
@@ -328,8 +328,8 @@ final class PageManager
* Closes the page manager. This flushes the page manager and releases
* the lock on the header.
*/
- void close() throws IOException
- {
+ void close() throws IOException
+ {
recordFile.release( headerBuf );
recordFile.commit();
headerBuf = null;
@@ -341,10 +341,10 @@ final class PageManager
/**
* Returns the recordFile header.
*/
- FileHeader getFileHeader()
+ FileHeader getFileHeader()
{
return header;
- }
+ }
RecordFile getRecordFile()
{
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/Provider.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/Provider.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/Provider.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/Provider.java Thu Feb 23 10:13:25 2012
@@ -56,7 +56,7 @@ import jdbm.RecordManagerOptions;
import jdbm.RecordManagerProvider;
import jdbm.helper.MRU;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
* Provider of the default RecordManager implementation.
@@ -82,7 +82,7 @@ public final class Provider implements R
String value = options.getProperty( RecordManagerOptions.DISABLE_TRANSACTIONS, "false" );
- if ( value.equalsIgnoreCase( "TRUE" ) )
+ if ( value.equalsIgnoreCase( "TRUE" ) )
{
( ( BaseRecordManager ) recman ).disableTransactions();
}
@@ -92,20 +92,20 @@ public final class Provider implements R
value = options.getProperty( RecordManagerOptions.CACHE_TYPE, RecordManagerOptions.NORMAL_CACHE );
- if ( value.equalsIgnoreCase( RecordManagerOptions.NORMAL_CACHE ) )
+ if ( value.equalsIgnoreCase( RecordManagerOptions.NORMAL_CACHE ) )
{
MRU cache = new MRU( cacheSize );
recman = new CacheRecordManager( recman, cache );
- }
- else if ( value.equalsIgnoreCase( RecordManagerOptions.SOFT_REF_CACHE ) )
+ }
+ else if ( value.equalsIgnoreCase( RecordManagerOptions.SOFT_REF_CACHE ) )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_551 ) );
- }
- else if ( value.equalsIgnoreCase( RecordManagerOptions.WEAK_REF_CACHE ) )
+ }
+ else if ( value.equalsIgnoreCase( RecordManagerOptions.WEAK_REF_CACHE ) )
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_552 ) );
- }
- else
+ }
+ else
{
throw new IllegalArgumentException( I18n.err( I18n.ERR_553, value ) );
}
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordFile.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordFile.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordFile.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordFile.java Thu Feb 23 10:13:25 2012
@@ -53,7 +53,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
@@ -64,7 +64,7 @@ import org.apache.directory.server.i18n.
* The set of dirty records on the in-use list constitutes a transaction.
* Later on, we will send these records to some recovery thingy.
*/
-public final class RecordFile
+public final class RecordFile
{
private TransactionManager transactionManager;
@@ -110,7 +110,7 @@ public final class RecordFile
* @throws IOException whenever the creation of the underlying
* RandomAccessFile throws it.
*/
- RecordFile( String fileName ) throws IOException
+ RecordFile( String fileName ) throws IOException
{
this.fileName = fileName;
file = new RandomAccessFile( fileName + EXTENSION, "rw" );
@@ -140,7 +140,7 @@ public final class RecordFile
/**
* @return the file name.
*/
- String getFileName()
+ String getFileName()
{
return fileName;
}
@@ -150,25 +150,25 @@ public final class RecordFile
* Disables transactions: doesn't sync and doesn't use the
* transaction manager.
*/
- void disableTransactions()
+ void disableTransactions()
{
transactionsDisabled = true;
}
/**
- * Gets a block from the file. The returned byte array is the in-memory
- * copy of the record, and thus can be written (and subsequently released
+ * Gets a block from the file. The returned byte array is the in-memory
+ * copy of the record, and thus can be written (and subsequently released
* with a dirty flag in order to write the block back).
*
* @param blockId The record number to retrieve.
*/
- BlockIo get( long blockId ) throws IOException
+ BlockIo get( long blockId ) throws IOException
{
// try in transaction list, dirty list, free list
BlockIo blockIo = inTxn.get( blockId );
- if ( blockIo != null )
+ if ( blockIo != null )
{
inTxn.remove( blockId );
inUse.put( blockId, blockIo );
@@ -178,7 +178,7 @@ public final class RecordFile
blockIo = dirty.get( blockId );
- if ( blockIo != null )
+ if ( blockIo != null )
{
dirty.remove( blockId );
inUse.put( blockId, blockIo );
@@ -186,11 +186,11 @@ public final class RecordFile
return blockIo;
}
- for ( Iterator<BlockIo> iterator = free.iterator(); iterator.hasNext(); )
+ for ( Iterator<BlockIo> iterator = free.iterator(); iterator.hasNext(); )
{
BlockIo cur = iterator.next();
- if ( cur.getBlockId() == blockId )
+ if ( cur.getBlockId() == blockId )
{
blockIo = cur;
iterator.remove();
@@ -201,7 +201,7 @@ public final class RecordFile
}
// sanity check: can't be on in use list
- if ( inUse.get( blockId ) != null )
+ if ( inUse.get( blockId ) != null )
{
throw new Error( I18n.err( I18n.ERR_554, blockId ) );
}
@@ -211,10 +211,10 @@ public final class RecordFile
long offset = blockId * BLOCK_SIZE;
long fileLength = file.length();
- if ( ( fileLength > 0 ) && ( offset <= fileLength ) )
+ if ( ( fileLength > 0 ) && ( offset <= fileLength ) )
{
read( file, offset, blockIo.getData(), BLOCK_SIZE );
- }
+ }
inUse.put( blockId, blockIo );
blockIo.setClean();
@@ -229,7 +229,7 @@ public final class RecordFile
* @param blockId The record number to release.
* @param isDirty If true, the block was modified since the get().
*/
- void release( long blockId, boolean isDirty ) throws IOException
+ void release( long blockId, boolean isDirty ) throws IOException
{
BlockIo blockIo = inUse.get( blockId );
@@ -252,22 +252,22 @@ public final class RecordFile
*
* @param block The block to release.
*/
- void release( BlockIo block )
+ void release( BlockIo block )
{
inUse.remove( block.getBlockId() );
- if ( block.isDirty() )
+ if ( block.isDirty() )
{
// System.out.println( "Dirty: " + key + block );
dirty.put( block.getBlockId(), block );
- }
- else
+ }
+ else
{
- if ( ! transactionsDisabled && block.isInTransaction() )
+ if ( ! transactionsDisabled && block.isInTransaction() )
{
inTxn.put( block.getBlockId(), block );
- }
- else
+ }
+ else
{
free.add( block );
}
@@ -280,7 +280,7 @@ public final class RecordFile
*
* @param block The block to discard.
*/
- void discard( BlockIo block )
+ void discard( BlockIo block )
{
inUse.remove( block.getBlockId() );
@@ -292,10 +292,10 @@ public final class RecordFile
/**
* Commits the current transaction by flushing all dirty buffers to disk.
*/
- void commit() throws IOException
+ void commit() throws IOException
{
// debugging...
- if ( ! inUse.isEmpty() && inUse.size() > 1 )
+ if ( ! inUse.isEmpty() && inUse.size() > 1 )
{
showList( inUse.values().iterator() );
throw new Error( I18n.err( I18n.ERR_556, inUse.size() ) );
@@ -303,29 +303,29 @@ public final class RecordFile
// System.out.println("committing...");
- if ( dirty.size() == 0 )
+ if ( dirty.size() == 0 )
{
// if no dirty blocks, skip commit process
return;
}
- if ( ! transactionsDisabled )
+ if ( ! transactionsDisabled )
{
getTxnMgr().start();
}
- for ( BlockIo blockIo : dirty.values() )
+ for ( BlockIo blockIo : dirty.values() )
{
// System.out.println("node " + node + " map size now " + dirty.size());
- if ( transactionsDisabled )
+ if ( transactionsDisabled )
{
sync( blockIo );
blockIo.setClean();
free.add( blockIo );
}
- else
+ else
{
getTxnMgr().add( blockIo );
inTxn.put( blockIo.getBlockId(), blockIo );
@@ -334,7 +334,7 @@ public final class RecordFile
dirty.clear();
- if ( ! transactionsDisabled )
+ if ( ! transactionsDisabled )
{
getTxnMgr().commit();
}
@@ -344,10 +344,10 @@ public final class RecordFile
/**
* Rollback the current transaction by discarding all dirty buffers
*/
- void rollback() throws IOException
+ void rollback() throws IOException
{
// debugging...
- if ( ! inUse.isEmpty() )
+ if ( ! inUse.isEmpty() )
{
showList( inUse.values().iterator() );
throw new Error( I18n.err( I18n.ERR_557, inUse.size() ) );
@@ -356,12 +356,12 @@ public final class RecordFile
// System.out.println("rollback...");
dirty.clear();
- if ( ! transactionsDisabled )
+ if ( ! transactionsDisabled )
{
getTxnMgr().synchronizeLogFromDisk();
}
- if ( ! inTxn.isEmpty() )
+ if ( ! inTxn.isEmpty() )
{
showList( inTxn.values().iterator() );
throw new Error( I18n.err( I18n.ERR_558, inTxn.size() ) );
@@ -372,9 +372,9 @@ public final class RecordFile
/**
* Commits and closes file.
*/
- void close() throws IOException
+ void close() throws IOException
{
- if ( ! dirty.isEmpty() )
+ if ( ! dirty.isEmpty() )
{
commit();
}
@@ -384,21 +384,21 @@ public final class RecordFile
getTxnMgr().shutdown();
}
- if ( ! inTxn.isEmpty() )
+ if ( ! inTxn.isEmpty() )
{
showList( inTxn.values().iterator() );
throw new Error( I18n.err( I18n.ERR_559 ) );
}
// these actually ain't that bad in a production release
- if ( ! dirty.isEmpty() )
+ if ( ! dirty.isEmpty() )
{
System.out.println( "ERROR: dirty blocks at close time" );
showList( dirty.values().iterator() );
throw new Error( I18n.err( I18n.ERR_560 ) );
}
- if ( ! inUse.isEmpty() )
+ if ( ! inUse.isEmpty() )
{
System.out.println( "ERROR: inUse blocks at close time" );
showList( inUse.values().iterator() );
@@ -416,9 +416,9 @@ public final class RecordFile
* Force closing the file and underlying transaction manager.
* Used for testing purposed only.
*/
- void forceClose() throws IOException
+ void forceClose() throws IOException
{
- if ( ! transactionsDisabled )
+ if ( ! transactionsDisabled )
{
getTxnMgr().forceClose();
}
@@ -429,10 +429,10 @@ public final class RecordFile
/**
* Prints contents of a list
*/
- private void showList( Iterator<BlockIo> i )
+ private void showList( Iterator<BlockIo> i )
{
int cnt = 0;
- while ( i.hasNext() )
+ while ( i.hasNext() )
{
System.out.println( "elem " + cnt + ": " + i.next() );
cnt++;
@@ -441,16 +441,16 @@ public final class RecordFile
/**
- * Returns a new BlockIo. The BlockIo is retrieved (and removed) from the
+ * Returns a new BlockIo. The BlockIo is retrieved (and removed) from the
* released list or created new.
*/
- private BlockIo getNewBlockIo( long blockId ) throws IOException
+ private BlockIo getNewBlockIo( long blockId ) throws IOException
{
BlockIo blockIo = null;
- if ( ! free.isEmpty() )
+ if ( ! free.isEmpty() )
{
- blockIo = ( BlockIo ) free.removeFirst();
+ blockIo = free.removeFirst();
blockIo.setBlockId( blockId );
}
@@ -472,11 +472,11 @@ public final class RecordFile
* @param blockIo The blocIo to write on disk
* @exception IOException If we have a problem while trying to write the blockIo to disk
*/
- void sync( BlockIo blockIo ) throws IOException
+ void sync( BlockIo blockIo ) throws IOException
{
byte[] data = blockIo.getData();
- if ( data != null )
+ if ( data != null )
{
// Write the data to disk now.
long offset = blockIo.getBlockId() * BLOCK_SIZE;
@@ -491,9 +491,9 @@ public final class RecordFile
*
* @param recycle true if block data can be reused
*/
- void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException
+ void releaseFromTransaction( BlockIo node, boolean recycle ) throws IOException
{
- if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle )
+ if ( ( inTxn.remove( node.getBlockId() ) != null ) && recycle )
{
free.add( node );
}
@@ -503,7 +503,7 @@ public final class RecordFile
/**
* Synchronizes the file.
*/
- void sync() throws IOException
+ void sync() throws IOException
{
file.getFD().sync();
}
@@ -512,15 +512,15 @@ public final class RecordFile
/**
* Utility method: Read a block from a RandomAccessFile
*/
- private static void read( RandomAccessFile file, long offset, byte[] buffer, int nBytes ) throws IOException
+ private static void read( RandomAccessFile file, long offset, byte[] buffer, int nBytes ) throws IOException
{
file.seek( offset );
int remaining = nBytes;
int pos = 0;
- while ( remaining > 0 )
+ while ( remaining > 0 )
{
int read = file.read( buffer, pos, remaining );
- if ( read == -1 )
+ if ( read == -1 )
{
System.arraycopy( cleanData, 0, buffer, pos, remaining );
break;
Modified: directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordHeader.java
URL: http://svn.apache.org/viewvc/directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordHeader.java?rev=1292731&r1=1292561&r2=1292731&view=diff
==============================================================================
--- directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordHeader.java (original)
+++ directory/jdbm/trunk/jdbm2/src/main/java/jdbm/recman/RecordHeader.java Thu Feb 23 10:13:25 2012
@@ -21,7 +21,7 @@
*
* 4. Products derived from this Software may not be called "JDBM"
* nor may "JDBM" appear in their names without prior written
- * permission of Cees de Groot.
+ * permission of Cees de Groot.
*
* 5. Due credit should be given to the JDBM Project
* (http://jdbm.sourceforge.net/).
@@ -47,17 +47,17 @@
package jdbm.recman;
-import org.apache.directory.server.i18n.I18n;
+import jdbm.I18n;
/**
- * The data that comes at the start of a record of data. It stores both the
- * current size and the available size for the record - the latter can be
- * bigger than the former, which allows the record to grow without needing to
- * be moved and which allows the system to put small records in larger free
+ * The data that comes at the start of a record of data. It stores both the
+ * current size and the available size for the record - the latter can be
+ * bigger than the former, which allows the record to grow without needing to
+ * be moved and which allows the system to put small records in larger free
* spots.
*/
-class RecordHeader
+class RecordHeader
{
// offsets
private static final short O_CURRENTSIZE = 0; // int currentSize
@@ -70,10 +70,10 @@ class RecordHeader
/**
- * Constructs a record header from the indicated data starting at the
+ * Constructs a record header from the indicated data starting at the
* indicated position.
*/
- RecordHeader( BlockIo block, short pos )
+ RecordHeader( BlockIo block, short pos )
{
this.block = block;
this.pos = pos;
@@ -86,39 +86,39 @@ class RecordHeader
/** Returns the current size */
- int getCurrentSize()
+ int getCurrentSize()
{
return block.readInt( pos + O_CURRENTSIZE );
}
/** Sets the current size */
- void setCurrentSize( int value )
+ void setCurrentSize( int value )
{
block.writeInt( pos + O_CURRENTSIZE, value );
}
/** Returns the available size */
- int getAvailableSize()
+ int getAvailableSize()
{
return block.readInt( pos + O_AVAILABLESIZE );
}
/** Sets the available size */
- void setAvailableSize( int value )
+ void setAvailableSize( int value )
{
block.writeInt( pos + O_AVAILABLESIZE, value );
}
// overrides java.lang.Object
- public String toString()
+ public String toString()
{
- return "RH( " + block.getBlockId() + " : " + pos
+ return "RH( " + block.getBlockId() + " : " + pos
+ ", avl = " + getAvailableSize()
- + ", cur = " + getCurrentSize()
+ + ", cur = " + getCurrentSize()
+ " )";
}
}
\ No newline at end of file