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 2011/10/24 13:14:17 UTC
svn commit: r1188092 - in /directory/apacheds/branches/apacheds-txns:
core-api/src/main/java/org/apache/directory/server/core/log/
core/src/main/java/org/apache/directory/server/core/log/
core/src/test/java/org/apache/directory/server/core/log/
Author: elecharny
Date: Mon Oct 24 11:14:16 2011
New Revision: 1188092
URL: http://svn.apache.org/viewvc?rev=1188092&view=rev
Log:
o Added toString() methods
o Removed useless initialization of arrays
o Changed the way we handle exception on LogFlushScantest
o Minor cleanups
Modified:
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/LogAnchor.java
directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/UserLogRecord.java
directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogFileManager.java
directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/LogAnchor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/LogAnchor.java?rev=1188092&r1=1188091&r2=1188092&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/LogAnchor.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/LogAnchor.java Mon Oct 24 11:14:16 2011
@@ -78,7 +78,7 @@ public class LogAnchor
public void resetLogAnchor( LogAnchor logAnchor )
{
- this.resetLogAnchor( logAnchor.getLogFileNumber(), logAnchor.getLogFileOffset(), logAnchor.getLogLSN() );
+ resetLogAnchor( logAnchor.getLogFileNumber(), logAnchor.getLogFileOffset(), logAnchor.getLogLSN() );
}
@@ -98,4 +98,13 @@ public class LogAnchor
{
return this.logLSN;
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "File number: " + logFileNumber + ", offset: " + logFileOffset + ", LSN: " + Long.toHexString( logLSN );
+ }
}
Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/UserLogRecord.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/UserLogRecord.java?rev=1188092&r1=1188091&r2=1188092&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/UserLogRecord.java (original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/log/UserLogRecord.java Mon Oct 24 11:14:16 2011
@@ -63,4 +63,13 @@ public class UserLogRecord
{
return logAnchor;
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "Length: " + length + ", offset: " + offset + ", anchor: " + logAnchor;
+ }
}
Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogFileManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogFileManager.java?rev=1188092&r1=1188091&r2=1188092&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogFileManager.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/DefaultLogFileManager.java Mon Oct 24 11:14:16 2011
@@ -269,4 +269,13 @@ import java.io.RandomAccessFile;
raf.seek( position );
}
}
+
+
+ /**
+ * @see Object#toString()
+ */
+ public String toString()
+ {
+ return "log path: " + logFilePath + ", suffix: " + suffix;
+ }
}
Modified: directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java?rev=1188092&r1=1188091&r2=1188092&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/main/java/org/apache/directory/server/core/log/LogFlushManager.java Mon Oct 24 11:14:16 2011
@@ -154,7 +154,7 @@ import org.apache.directory.server.i18n.
{
// First get the rewind count then the position to which the readhead advanced
int readHeadRewindCount = logBuffer.readHeadRewindCount.get();
- int readHeadPosition = logBuffer.readHeadPosition;
+ int readHeadPosition = logBuffer.readHeadPosition;
if ( ( logBuffer.writeHeadRewindCount == readHeadRewindCount ) ||
( ( logBuffer.writeHeadRewindCount == readHeadRewindCount + 1 ) &&
@@ -483,7 +483,7 @@ import org.apache.directory.server.i18n.
int offset;
offset = logBuffer.readHeadPosition;
- currentLogFile.append( logBuffer.buffer, offset, totalLength );
+ currentLogFile.append( logBuffer.buffer, offset, totalLength );
//move the position to the next record
logBuffer.readHeadPosition = readHead.position();
Modified: directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java?rev=1188092&r1=1188091&r2=1188092&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java (original)
+++ directory/apacheds/branches/apacheds-txns/core/src/test/java/org/apache/directory/server/core/log/LogFlushScanTest.java Mon Oct 24 11:14:16 2011
@@ -20,6 +20,7 @@
package org.apache.directory.server.core.log;
import java.io.IOException;
+import java.util.Arrays;
import org.junit.After;
import org.junit.Before;
@@ -28,6 +29,7 @@ import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
/**
*
@@ -84,19 +86,12 @@ public class LogFlushScanTest
UserLogRecord logRecord = new UserLogRecord();
byte recordData[] = new byte[dataLength];
byte userRecord[];
- boolean failed = false;
- byte writtenCounter = 0;
+ byte writtenCounter = 1;
byte readCounter = 0;
LogAnchor startingPoint = new LogAnchor();
- for ( idx = 0; idx < dataLength; idx++ )
- {
- recordData[idx] = writtenCounter;
- }
- writtenCounter++;
-
try
{
logRecord.setData( recordData, dataLength );
@@ -105,15 +100,12 @@ public class LogFlushScanTest
// Record the starting point
startingPoint.resetLogAnchor( logRecord.getLogAnchor() );
- for ( idx = 0; idx < dataLength; idx++ )
- {
- recordData[idx] = writtenCounter;
- }
+ Arrays.fill( recordData, (byte)writtenCounter );
+
writtenCounter++;
logRecord.setData( recordData, dataLength );
log.log( logRecord, true ); //Sync what we logged so far
-
LogScanner logScanner = log.beginScan( startingPoint );
@@ -131,20 +123,17 @@ public class LogFlushScanTest
}
assertTrue( writtenCounter == readCounter );
-
}
catch( IOException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
catch( InvalidLogException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
-
- assertTrue( failed == false );
}
@@ -156,7 +145,6 @@ public class LogFlushScanTest
UserLogRecord logRecord = new UserLogRecord();
byte recordData[] = new byte[dataLength];
byte userRecord[];
- boolean failed = false;
byte writtenCounter = 1;
byte readCounter = 1;
@@ -170,10 +158,7 @@ public class LogFlushScanTest
{
while ( writtenCounter < maxCounter )
{
- for ( idx = 0; idx < dataLength; idx++ )
- {
- recordData[idx] = writtenCounter;
- }
+ Arrays.fill( recordData, (byte)writtenCounter );
logRecord.setData( recordData, dataLength );
boolean sync = ( ( writtenCounter % 11 ) == 0 ) || ( writtenCounter == ( maxCounter - 1 ) );
@@ -216,12 +201,12 @@ public class LogFlushScanTest
catch( IOException e )
{
e.printStackTrace();
- failed = true;
- }
+ fail();
+ }
catch( InvalidLogException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
}
@@ -234,15 +219,9 @@ public class LogFlushScanTest
UserLogRecord logRecord = new UserLogRecord();
byte recordData[] = new byte[dataLength];
byte userRecord[];
- boolean failed = false;
LogAnchor startingPoint = new LogAnchor();
- for ( idx = 0; idx < dataLength; idx++ )
- {
- recordData[idx] = 0;
- }
-
logRecord.setData( recordData, dataLength );
try
@@ -252,16 +231,14 @@ public class LogFlushScanTest
catch( IOException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
catch( InvalidLogException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
- assertTrue( failed == false );
-
startingPoint.resetLogAnchor( logRecord.getLogAnchor() );
byte key = 1;
@@ -308,12 +285,12 @@ public class LogFlushScanTest
catch( IOException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
catch( InvalidLogException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
assertTrue( sum == expectedSum );
@@ -338,12 +315,8 @@ public class LogFlushScanTest
UserLogRecord logRecord = new UserLogRecord();
byte recordData[] = new byte[dataLength];
int idx;
- boolean failed = false;
- for ( idx = 0; idx < dataLength; idx++ )
- {
- recordData[idx] = key;
- }
+ Arrays.fill( recordData, (byte)key );
logRecord.setData( recordData, dataLength );
@@ -352,6 +325,7 @@ public class LogFlushScanTest
for ( idx = 0; idx < numAppends; idx++ )
{
boolean sync = false;
+
if ( ( ( idx % 3 ) == 0 ) || ( idx == numAppends - 1 ) )
{
sync = true;
@@ -363,15 +337,13 @@ public class LogFlushScanTest
catch( IOException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
catch( InvalidLogException e )
{
e.printStackTrace();
- failed = true;
+ fail();
}
-
- assertTrue( failed == false );
}
}
}