jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r718216 - in /jackrabbit/branches/1.5: ./ jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java
Date Mon, 17 Nov 2008 10:39:47 GMT
Author: jukka
Date: Mon Nov 17 02:39:45 2008
New Revision: 718216

URL: http://svn.apache.org/viewvc?rev=718216&view=rev
Log:
1.5: Merged revision 713072 (JCR-1850). Ignored revisions 713059, 713065, 713076 and 713162.

Modified:
    jackrabbit/branches/1.5/   (props changed)
    jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java

Propchange: jackrabbit/branches/1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 17 02:39:45 2008
@@ -1,2 +1,2 @@
 /jackrabbit/branches/1.3:631261
-/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037
+/jackrabbit/trunk:703899-704158,704165,704167,704324,704358,704361,704864,704933,704939,705010,705033,705243,705496,705522,705579,705925,705932,705934,705937-705938,705961,706242,706273,706285-706286,706562,706606,706649,706655,706660,706697,706918,707303-707304,707307,707310,707630,708206,708598,708609,708613,708619,708634,708840,708863,708909,708929,708943,709115,709142,709207,709211,710047,711238,711566-711567,711595,711841-711843,712984-712985,713037,713059,713065,713072,713076,713162

Modified: jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java?rev=718216&r1=718215&r2=718216&view=diff
==============================================================================
--- jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java
(original)
+++ jackrabbit/branches/1.5/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRecordLog.java
Mon Nov 17 02:39:45 2008
@@ -31,6 +31,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
 
 /**
  * A file record log is a file containing {@link Record}s. Every file record
@@ -140,7 +142,8 @@
         this.logFile = logFile;
 
         if (logFile.exists()) {
-            DataInputStream in = new DataInputStream(new FileInputStream(logFile));
+            DataInputStream in = new DataInputStream(
+                    new BufferedInputStream(new FileInputStream(logFile), 128));
 
             try {
                 readHeader(in);
@@ -160,7 +163,8 @@
      */
     public void init(long previousRevision) throws IOException {
         if (isNew) {
-            DataOutputStream out = new DataOutputStream(new FileOutputStream(logFile));
+            DataOutputStream out = new DataOutputStream(
+                    new BufferedOutputStream(new FileOutputStream(logFile), 128));
 
             try {
                 writeHeader(out);
@@ -274,12 +278,14 @@
     public long append(String journalId, String producerId, InputStream in, int length)
             throws IOException {
 
-        DataOutputStream out = new DataOutputStream(new FileOutputStream(logFile, true));
+        OutputStream out = new FileOutputStream(logFile, true);
 
         try {
-            out.writeUTF(journalId);
-            out.writeUTF(producerId);
-            out.writeInt(length);
+            DataBuffer buffer = new DataBuffer();
+            buffer.writeUTF(journalId);
+            buffer.writeUTF(producerId);
+            buffer.writeInt(length);
+            buffer.copy(out);
 
             IOUtils.copy(in, out);
             out.flush();
@@ -426,4 +432,28 @@
         }
         return utflen;
     }
+
+    /**
+     * A simple helper class that writes to a buffer. The current buffer can
+     * be {@link #copy copied} to an output stream.
+     */
+    private static final class DataBuffer extends DataOutputStream {
+
+        public DataBuffer() {
+            super(new ByteArrayOutputStream());
+        }
+
+        /**
+         * Copies the bytes the are currently held in the buffer to the given
+         * output stream.
+         *
+         * @param out the output stream where the buffered data is written.
+         * @throws IOException if an error occurs while writing data to
+         *          <code>out</code>.
+         */
+        public void copy(OutputStream out) throws IOException {
+            byte[] buffer = ((ByteArrayOutputStream) super.out).toByteArray();
+            out.write(buffer);
+        }
+    }
 }



Mime
View raw message