lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sim...@apache.org
Subject svn commit: r1138420 - in /lucene/dev/trunk/lucene/src: java/org/apache/lucene/store/CompoundFileWriter.java test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
Date Wed, 22 Jun 2011 12:06:26 GMT
Author: simonw
Date: Wed Jun 22 12:06:26 2011
New Revision: 1138420

URL: http://svn.apache.org/viewvc?rev=1138420&view=rev
Log:
LUCENE-3218: added FileHandle Tracking for CFS tests and throw explicit exception if existing
files are overwritten in the CFS

Modified:
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java
    lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java
    lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java?rev=1138420&r1=1138419&r2=1138420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/store/CompoundFileWriter.java Wed Jun
22 12:06:26 2011
@@ -226,6 +226,9 @@ final class CompoundFileWriter {
         out = new DirectCFSIndexOutput(dataOut, entry, false);
       } else {
         entry.dir = this.directory;
+        if (directory.fileExists(name)) {
+          throw new IOException("File already exists");
+        }
         out = new DirectCFSIndexOutput(directory.createOutput(name), entry,
             true);
       }

Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java?rev=1138420&r1=1138419&r2=1138420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java
(original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockCompoundFileDirectoryWrapper.java
Wed Jun 22 12:06:26 2011
@@ -26,13 +26,17 @@ public class MockCompoundFileDirectoryWr
   private final CompoundFileDirectory delegate;
   private final String name;
   
-  public MockCompoundFileDirectoryWrapper(String name, MockDirectoryWrapper parent, CompoundFileDirectory
delegate) throws IOException {
+  public MockCompoundFileDirectoryWrapper(String name, MockDirectoryWrapper parent, CompoundFileDirectory
delegate, boolean forWrite) throws IOException {
     super(parent, name, 1024);
     this.name = name;
     this.parent = parent;
     this.delegate = delegate;
-    super.initForRead(Collections.<String,FileEntry>emptyMap());
-    parent.addFileHandle(this, name, true);
+    if (forWrite) {
+      super.initForWrite();
+    } else {
+      super.initForRead(Collections.<String,FileEntry>emptyMap());
+    }
+    parent.addFileHandle(this, name, !forWrite);
   }
   
   @Override
@@ -140,4 +144,8 @@ public class MockCompoundFileDirectoryWr
     return delegate.openInputSlice(id, offset, length, readBufferSize);
   }
 
+  @Override
+  public CompoundFileDirectory createCompoundOutput(String name) throws IOException {
+    return delegate.createCompoundOutput(name);
+  }
 }

Modified: lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java?rev=1138420&r1=1138419&r2=1138420&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
(original)
+++ lucene/dev/trunk/lucene/src/test-framework/org/apache/lucene/store/MockDirectoryWrapper.java
Wed Jun 22 12:06:26 2011
@@ -420,9 +420,15 @@ public class MockDirectoryWrapper extend
   @Override
   public synchronized CompoundFileDirectory openCompoundInput(String name, int bufferSize)
throws IOException {
     maybeYield();
-    return new MockCompoundFileDirectoryWrapper(name, this, delegate.openCompoundInput(name,
bufferSize));
+    return new MockCompoundFileDirectoryWrapper(name, this, delegate.openCompoundInput(name,
bufferSize), false);
   }
-  
+   
+  @Override
+  public CompoundFileDirectory createCompoundOutput(String name) throws IOException {
+    maybeYield();
+    return new MockCompoundFileDirectoryWrapper(name, this, delegate.createCompoundOutput(name),
true);
+  }
+
   /** Provided for testing purposes.  Use sizeInBytes() instead. */
   public synchronized final long getRecomputedSizeInBytes() throws IOException {
     if (!(delegate instanceof RAMDirectory))



Mime
View raw message