directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1229150 - in /directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log: LogAnchor.java UserLogRecord.java
Date Mon, 09 Jan 2012 13:47:58 GMT
Author: elecharny
Date: Mon Jan  9 13:47:58 2012
New Revision: 1229150

URL: http://svn.apache.org/viewvc?rev=1229150&view=rev
Log:
Made those two classes Externalizable

Modified:
    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
    directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java

Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java?rev=1229150&r1=1229149&r2=1229150&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/LogAnchor.java
Mon Jan  9 13:47:58 2012
@@ -20,6 +20,11 @@
 package org.apache.directory.server.core.api.log;
 
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
 import org.apache.directory.server.i18n.I18n;
 
 
@@ -28,7 +33,7 @@ import org.apache.directory.server.i18n.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class LogAnchor
+public class LogAnchor implements Externalizable
 {
     // TODO move this to logger 
     /** Invalid/unknown lsn. Log LSN starts at UNKNOWN_LSN + 1 and is ever increasing */
@@ -104,6 +109,35 @@ public class LogAnchor
 
 
     /**
+     * Read back the LogAnchor from the stream.
+     */
+    @Override
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        logFileNumber = in.readLong();
+        logFileOffset = in.readLong();
+        logLSN = in.readLong();
+    }
+
+
+    /**
+     * Write the logAnchor in a stream. The format is : <br/>
+     * <ul>
+     * <li>logFileNumber</li>
+     * <li>logFileOffset</li>
+     * <li>logLSN</li>
+     * </ul>
+     */
+    @Override
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        out.writeLong( logFileNumber );
+        out.writeLong( logFileOffset );
+        out.writeLong( logLSN );
+    }
+
+
+    /**
      * @see Object#toString()
      */
     public String toString()

Modified: directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java?rev=1229150&r1=1229149&r2=1229150&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
(original)
+++ directory/apacheds/branches/apacheds-txns/core-api/src/main/java/org/apache/directory/server/core/api/log/UserLogRecord.java
Mon Jan  9 13:47:58 2012
@@ -20,12 +20,18 @@
 package org.apache.directory.server.core.api.log;
 
 
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+
 /** 
  * A user log record that can be used to pass user record between the clients and the logger.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class UserLogRecord
+public class UserLogRecord implements Externalizable
 {
     /** array used to hold user log records */
     private byte[] recordHolder;
@@ -79,6 +85,41 @@ public class UserLogRecord
 
 
     /**
+     * Read back the entry from the stream.
+     */
+    @Override
+    public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
+    {
+        length = in.readInt();
+        int dataSize = in.readInt();
+
+        recordHolder = new byte[dataSize];
+        in.readFully( recordHolder );
+
+        logAnchor = new LogAnchor();
+        logAnchor.readExternal( in );
+    }
+
+
+    /**
+     * Write the logRecord in a stream. The format is : <br/>
+     * <ul>
+     * <li>length of the stored data</li>
+     * <li>data</li>
+     * <li>The logAnchor</li>
+     * </ul>
+     */
+    @Override
+    public void writeExternal( ObjectOutput out ) throws IOException
+    {
+        out.writeInt( length );
+        out.write( recordHolder.length );
+        out.write( recordHolder );
+        logAnchor.writeExternal( out );
+    }
+
+
+    /**
      * @see Object#toString()
      */
     public String toString()



Mime
View raw message