jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dpfis...@apache.org
Subject svn commit: r1241481 - in /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal: DatabaseJournal.java FileJournal.java FileRevision.java
Date Tue, 07 Feb 2012 15:06:26 GMT
Author: dpfister
Date: Tue Feb  7 15:06:25 2012
New Revision: 1241481

URL: http://svn.apache.org/viewvc?rev=1241481&view=rev
Log:
JCR-3229 - FileRevision should have a flag to control whether to sync the file on every write.

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileJournal.java
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRevision.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java?rev=1241481&r1=1241480&r2=1241481&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/DatabaseJournal.java
Tue Feb  7 15:06:25 2012
@@ -364,7 +364,7 @@ public class DatabaseJournal extends Abs
         // Get the local file revision from disk (upgrade; see JCR-1087)
         long localFileRevision = 0L;
         if (getRevision() != null) {
-            InstanceRevision currentFileRevision = new FileRevision(new File(getRevision()));
+            InstanceRevision currentFileRevision = new FileRevision(new File(getRevision()),
true);
             localFileRevision = currentFileRevision.get();
             currentFileRevision.close();
         }

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileJournal.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileJournal.java?rev=1241481&r1=1241480&r2=1241481&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileJournal.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileJournal.java
Tue Feb  7 15:06:25 2012
@@ -247,7 +247,7 @@ public class FileJournal extends Abstrac
      * {@inheritDoc}
      */
     public InstanceRevision getInstanceRevision() throws JournalException {
-        return new FileRevision(new File(getRevision()));
+        return new FileRevision(new File(getRevision()), true);
     }
 
     /**

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRevision.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRevision.java?rev=1241481&r1=1241480&r2=1241481&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRevision.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/journal/FileRevision.java
Tue Feb  7 15:06:25 2012
@@ -39,6 +39,11 @@ public class FileRevision implements Ins
     private final RandomAccessFile raf;
 
     /**
+     * Flag indicating whether to sync the file on every write.
+     */
+    private final boolean sync;
+
+    /**
      * Cached value.
      */
     private long value;
@@ -52,9 +57,13 @@ public class FileRevision implements Ins
      * Creates a new file based revision counter.
      *
      * @param file holding global counter
+     * @param sync whether to sync the file on every write
+     * 
      * @throws JournalException if some error occurs
      */
-    public FileRevision(File file) throws JournalException {
+    public FileRevision(File file, boolean sync) throws JournalException {
+        this.sync = sync;
+
         try {
             if (!file.exists()) {
                 file.createNewFile();
@@ -101,7 +110,9 @@ public class FileRevision implements Ins
             }
             raf.seek(0L);
             raf.writeLong(value);
-            raf.getFD().sync();
+            if (sync) {
+                raf.getFD().sync();
+            }
             this.value = value;
         } catch (IOException e) {
             throw new JournalException("I/O error occurred.", e);



Mime
View raw message