Index: lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java
===================================================================
--- lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/store/TestBufferedIndexInput.java	(working copy)
@@ -348,12 +348,6 @@
         dir.deleteFile(name);
       }
       @Override
-      public long fileModified(String name)
-        throws IOException
-      {
-        return dir.fileModified(name);
-      }
-      @Override
       public boolean fileExists(String name)
         throws IOException
       {
Index: lucene/src/test/org/apache/lucene/index/TestIndexReader.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestIndexReader.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/index/TestIndexReader.java	(working copy)
@@ -381,60 +381,6 @@
         _TestUtil.rmDir(dirFile);
     }
 
-    public void testLastModified() throws Exception {
-      for(int i=0;i<2;i++) {
-        final Directory dir = newDirectory();
-        assertFalse(IndexReader.indexExists(dir));
-        IndexWriter writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
-        addDocumentWithFields(writer);
-        assertTrue(IndexWriter.isLocked(dir));		// writer open, so dir is locked
-        writer.close();
-        assertTrue(IndexReader.indexExists(dir));
-        IndexReader reader = IndexReader.open(dir);
-        assertFalse(IndexWriter.isLocked(dir));		// reader only, no lock
-        long version = IndexReader.lastModified(dir);
-        if (i == 1) {
-          long version2 = IndexReader.lastModified(dir);
-          assertEquals(version, version2);
-        }
-        reader.close();
-        // modify index and check version has been
-        // incremented:
-        Thread.sleep(1000);
-
-        writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
-        addDocumentWithFields(writer);
-        writer.close();
-        reader = IndexReader.open(dir);
-        assertTrue("old lastModified is " + version + "; new lastModified is " + IndexReader.lastModified(dir), version <= IndexReader.lastModified(dir));
-        reader.close();
-        dir.close();
-      }
-    }
-
-    public void testVersion() throws IOException {
-      Directory dir = newDirectory();
-      assertFalse(IndexReader.indexExists(dir));
-      IndexWriter writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)));
-      addDocumentWithFields(writer);
-      assertTrue(IndexWriter.isLocked(dir));		// writer open, so dir is locked
-      writer.close();
-      assertTrue(IndexReader.indexExists(dir));
-      IndexReader reader = IndexReader.open(dir);
-      assertFalse(IndexWriter.isLocked(dir));		// reader only, no lock
-      long version = IndexReader.getCurrentVersion(dir);
-      reader.close();
-      // modify index and check version has been
-      // incremented:
-      writer  = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random)).setOpenMode(OpenMode.CREATE));
-      addDocumentWithFields(writer);
-      writer.close();
-      reader = IndexReader.open(dir);
-      assertTrue("old version is " + version + "; new version is " + IndexReader.getCurrentVersion(dir), version < IndexReader.getCurrentVersion(dir));
-      reader.close();
-      dir.close();
-    }
-
     public void testOpenReaderAfterDelete() throws IOException {
       File dirFile = _TestUtil.getTempDir("deletetest");
       Directory dir = newFSDirectory(dirFile);
Index: lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/index/TestDeletionPolicy.java	(working copy)
@@ -18,10 +18,12 @@
  */
 
 import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
-import java.util.Collection;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
@@ -32,7 +34,6 @@
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.similarities.DefaultSimilarity;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
 
@@ -47,20 +48,12 @@
     final IndexCommit firstCommit =  commits.get(0);
     long last = SegmentInfos.generationFromSegmentsFileName(firstCommit.getSegmentsFileName());
     assertEquals(last, firstCommit.getGeneration());
-    long lastVersion = firstCommit.getVersion();
-    long lastTimestamp = firstCommit.getTimestamp();
     for(int i=1;i<commits.size();i++) {
       final IndexCommit commit =  commits.get(i);
       long now = SegmentInfos.generationFromSegmentsFileName(commit.getSegmentsFileName());
-      long nowVersion = commit.getVersion();
-      long nowTimestamp = commit.getTimestamp();
       assertTrue("SegmentInfos commits are out-of-order", now > last);
-      assertTrue("SegmentInfos versions are out-of-order", nowVersion > lastVersion);
-      assertTrue("SegmentInfos timestamps are out-of-order: now=" + nowTimestamp + " vs last=" + lastTimestamp, nowTimestamp >= lastTimestamp);
       assertEquals(now, commit.getGeneration());
       last = now;
-      lastVersion = nowVersion;
-      lastTimestamp = nowTimestamp;
     }
   }
 
@@ -158,6 +151,10 @@
     }
   }
 
+  static long getCommitTime(IndexCommit commit) throws IOException {
+    return Long.parseLong(commit.getUserData().get("commitTime"));
+  }
+
   /*
    * Delete a commit only when it has been obsoleted by N
    * seconds.
@@ -184,10 +181,10 @@
       IndexCommit lastCommit = commits.get(commits.size()-1);
 
       // Any commit older than expireTime should be deleted:
-      double expireTime = dir.fileModified(lastCommit.getSegmentsFileName())/1000.0 - expirationTimeSeconds;
+      double expireTime = getCommitTime(lastCommit)/1000.0 - expirationTimeSeconds;
 
       for (final IndexCommit commit : commits) {
-        double modTime = dir.fileModified(commit.getSegmentsFileName())/1000.0;
+        double modTime = getCommitTime(commit)/1000.0;
         if (commit != lastCommit && modTime < expireTime) {
           commit.delete();
           numDelete += 1;
@@ -213,6 +210,9 @@
       ((LogMergePolicy) mp).setUseCompoundFile(true);
     }
     IndexWriter writer = new IndexWriter(dir, conf);
+    Map<String,String> commitData = new HashMap<String,String>();
+    commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
+    writer.commit(commitData);
     writer.close();
 
     final int ITER = 9;
@@ -233,6 +233,9 @@
       for(int j=0;j<17;j++) {
         addDoc(writer);
       }
+      commitData = new HashMap<String,String>();
+      commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
+      writer.commit(commitData);
       writer.close();
 
       if (i < ITER-1) {
@@ -269,7 +272,9 @@
         // if we are on a filesystem that seems to have only
         // 1 second resolution, allow +1 second in commit
         // age tolerance:
-        long modTime = dir.fileModified(fileName);
+        SegmentInfos sis = new SegmentInfos();
+        sis.read(dir, fileName);
+        long modTime = Long.parseLong(sis.getUserData().get("commitTime"));
         oneSecondResolution &= (modTime % 1000) == 0;
         final long leeway = (long) ((SECONDS + (oneSecondResolution ? 1.0:0.0))*1000);
 
Index: lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/index/TestCrashCausesCorruptIndex.java	(working copy)
@@ -228,14 +228,6 @@
      * {@inheritDoc}
      */
     @Override
-    public long fileModified(String name) throws IOException {
-      return realDirectory.fileModified(name);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
     public String[] listAll() throws IOException {
       return realDirectory.listAll();
     }
Index: lucene/src/test/org/apache/lucene/index/TestIndexCommit.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestIndexCommit.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/index/TestIndexCommit.java	(working copy)
@@ -34,12 +34,10 @@
     
     IndexCommit ic1 = new IndexCommit() {
       @Override public String getSegmentsFileName() { return "a"; }
-      @Override public long getVersion() { return 12; }
       @Override public Directory getDirectory() { return dir; }
       @Override public Collection<String> getFileNames() throws IOException { return null; }
       @Override public void delete() {}
       @Override public long getGeneration() { return 0; }
-      @Override public long getTimestamp() throws IOException { return 1;}
       @Override public Map<String, String> getUserData() throws IOException { return null; }
       @Override public boolean isDeleted() { return false; }
       @Override public int getSegmentCount() { return 2; }
@@ -47,12 +45,10 @@
     
     IndexCommit ic2 = new IndexCommit() {
       @Override public String getSegmentsFileName() { return "b"; }
-      @Override public long getVersion() { return 12; }
       @Override public Directory getDirectory() { return dir; }
       @Override public Collection<String> getFileNames() throws IOException { return null; }
       @Override public void delete() {}
       @Override public long getGeneration() { return 0; }
-      @Override public long getTimestamp() throws IOException { return 1;}
       @Override public Map<String, String> getUserData() throws IOException { return null; }
       @Override public boolean isDeleted() { return false; }
       @Override public int getSegmentCount() { return 2; }
Index: lucene/src/test/org/apache/lucene/index/TestFieldsReader.java
===================================================================
--- lucene/src/test/org/apache/lucene/index/TestFieldsReader.java	(revision 1236444)
+++ lucene/src/test/org/apache/lucene/index/TestFieldsReader.java	(working copy)
@@ -126,10 +126,6 @@
       return fsDir.fileExists(name);
     }
     @Override
-    public long fileModified(String name) throws IOException {
-      return fsDir.fileModified(name);
-    }
-    @Override
     public void deleteFile(String name) throws IOException {
       fsDir.deleteFile(name);
     }
Index: lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/CompoundFileDirectory.java	(working copy)
@@ -249,14 +249,6 @@
     return entries.containsKey(IndexFileNames.stripSegmentName(name));
   }
   
-  
-  /** Returns the time the compound file was last modified. */
-  @Override
-  public long fileModified(String name) throws IOException {
-    ensureOpen();
-    return directory.fileModified(fileName);
-  }
-  
   /** Not implemented
    * @throws UnsupportedOperationException */
   @Override
Index: lucene/src/java/org/apache/lucene/store/RAMFile.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/RAMFile.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/RAMFile.java	(working copy)
@@ -26,8 +26,6 @@
   RAMDirectory directory;
   protected long sizeInBytes;
 
-  private long lastModified = System.currentTimeMillis();
-
   // File used as buffer, in no RAMDirectory
   public RAMFile() {}
   
@@ -44,15 +42,6 @@
     this.length = length;
   }
 
-  // For non-stream access from thread that might be concurrent with writing
-  public synchronized long getLastModified() {
-    return lastModified;
-  }
-
-  protected synchronized void setLastModified(long lastModified) {
-    this.lastModified = lastModified;
-  }
-
   protected final byte[] addBuffer(int size) {
     byte[] buffer = newBuffer(size);
     synchronized(this) {
Index: lucene/src/java/org/apache/lucene/store/RAMDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/RAMDirectory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/RAMDirectory.java	(working copy)
@@ -98,19 +98,6 @@
     return fileMap.containsKey(name);
   }
 
-  /** Returns the time the named file was last modified.
-   * @throws IOException if the file does not exist
-   */
-  @Override
-  public final long fileModified(String name) throws IOException {
-    ensureOpen();
-    RAMFile file = fileMap.get(name);
-    if (file == null) {
-      throw new FileNotFoundException(name);
-    }
-    return file.getLastModified();
-  }
-
   /** Returns the length in bytes of a file in the directory.
    * @throws IOException if the file does not exist
    */
Index: lucene/src/java/org/apache/lucene/store/Directory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/Directory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/Directory.java	(working copy)
@@ -62,10 +62,6 @@
   public abstract boolean fileExists(String name)
        throws IOException;
 
-  /** Returns the time the named file was last modified. */
-  public abstract long fileModified(String name)
-       throws IOException;
-
   /** Removes an existing file in the directory. */
   public abstract void deleteFile(String name)
        throws IOException;
Index: lucene/src/java/org/apache/lucene/store/NRTCachingDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/NRTCachingDirectory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/NRTCachingDirectory.java	(working copy)
@@ -153,15 +153,6 @@
   }
 
   @Override
-  public synchronized long fileModified(String name) throws IOException {
-    if (cache.fileExists(name)) {
-      return cache.fileModified(name);
-    } else {
-      return delegate.fileModified(name);
-    }
-  }
-
-  @Override
   public synchronized void deleteFile(String name) throws IOException {
     if (VERBOSE) {
       System.out.println("nrtdir.deleteFile name=" + name);
Index: lucene/src/java/org/apache/lucene/store/RAMOutputStream.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/RAMOutputStream.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/RAMOutputStream.java	(working copy)
@@ -167,7 +167,6 @@
 
   @Override
   public void flush() throws IOException {
-    file.setLastModified(System.currentTimeMillis());
     setFileLength();
   }
 
Index: lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/FileSwitchDirectory.java	(working copy)
@@ -138,11 +138,6 @@
   }
 
   @Override
-  public long fileModified(String name) throws IOException {
-    return getDirectory(name).fileModified(name);
-  }
-
-  @Override
   public void deleteFile(String name) throws IOException {
     getDirectory(name).deleteFile(name);
   }
Index: lucene/src/java/org/apache/lucene/store/FSDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/FSDirectory.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/store/FSDirectory.java	(working copy)
@@ -251,14 +251,6 @@
   }
 
   /** Returns the time the named file was last modified. */
-  @Override
-  public long fileModified(String name) {
-    ensureOpen();
-    File file = new File(directory, name);
-    return file.lastModified();
-  }
-
-  /** Returns the time the named file was last modified. */
   public static long fileModified(File directory, String name) {
     File file = new File(directory, name);
     return file.lastModified();
Index: lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/SnapshotDeletionPolicy.java	(working copy)
@@ -126,11 +126,6 @@
     }
 
     @Override
-    public long getVersion() {
-      return cp.getVersion();
-    }
-
-    @Override
     public boolean isDeleted() {
       return cp.isDeleted();
     }
Index: lucene/src/java/org/apache/lucene/index/SegmentInfos.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/SegmentInfos.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/SegmentInfos.java	(working copy)
@@ -94,16 +94,15 @@
    * Whenever you add a new format, make it 1 smaller (negative version logic)! */
   public static final int FORMAT_SEGMENTS_GEN_CURRENT = -2;
     
-  public int counter = 0;    // used to name new segments
+  public int counter;    // used to name new segments
   
   /**
-   * counts how often the index has been changed by adding or deleting docs.
-   * starting with the current time in milliseconds forces to create unique version numbers.
+   * counts how often the index has been changed
    */
-  public long version = System.currentTimeMillis();
+  public long version;
   
-  private long generation = 0;     // generation of the "segments_N" for the next commit
-  private long lastGeneration = 0; // generation of the "segments_N" file we last successfully read
+  private long generation;     // generation of the "segments_N" for the next commit
+  private long lastGeneration; // generation of the "segments_N" file we last successfully read
                                    // or wrote; this is normally the same as generation except if
                                    // there was an IOException that had interrupted a commit
 
Index: lucene/src/java/org/apache/lucene/index/IndexCommit.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/IndexCommit.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/IndexCommit.java	(working copy)
@@ -83,39 +83,31 @@
   public boolean equals(Object other) {
     if (other instanceof IndexCommit) {
       IndexCommit otherCommit = (IndexCommit) other;
-      return otherCommit.getDirectory().equals(getDirectory()) && otherCommit.getVersion() == getVersion();
-    } else
+      return otherCommit.getDirectory().equals(getDirectory()) && otherCommit.getGeneration() == getGeneration();
+    } else {
       return false;
+    }
   }
 
   @Override
   public int hashCode() {
-    return (int) (getDirectory().hashCode() + getVersion());
+    return getDirectory().hashCode() + Long.valueOf(getGeneration()).hashCode();
   }
 
-  /** Returns the version for this IndexCommit.  This is the
-   *  same value that {@link IndexReader#getVersion} would
-   *  return if it were opened on this commit. */
-  public abstract long getVersion();
-
   /** Returns the generation (the _N in segments_N) for this
    *  IndexCommit */
   public abstract long getGeneration();
 
-  /** Convenience method that returns the last modified time
-   *  of the segments_N file corresponding to this index
-   *  commit, equivalent to
-   *  getDirectory().fileModified(getSegmentsFileName()). */
-  public long getTimestamp() throws IOException {
-    return getDirectory().fileModified(getSegmentsFileName());
-  }
-
   /** Returns userData, previously passed to {@link
    *  IndexWriter#commit(Map)} for this commit.  Map is
    *  String -> String. */
   public abstract Map<String,String> getUserData() throws IOException;
   
   public int compareTo(IndexCommit commit) {
+    if (getDirectory() != commit.getDirectory()) {
+      throw new UnsupportedOperationException("cannot compare IndexCommits from different Directory instances");
+    }
+
     long gen = getGeneration();
     long comgen = commit.getGeneration();
     if (gen < comgen) {
@@ -126,5 +118,4 @@
       return 0;
     }
   }
-
 }
Index: lucene/src/java/org/apache/lucene/index/DirectoryReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/DirectoryReader.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/DirectoryReader.java	(working copy)
@@ -423,7 +423,6 @@
     Collection<String> files;
     Directory dir;
     long generation;
-    long version;
     final Map<String,String> userData;
     private final int segmentCount;
 
@@ -432,7 +431,6 @@
       this.dir = dir;
       userData = infos.getUserData();
       files = Collections.unmodifiableCollection(infos.files(dir, true));
-      version = infos.getVersion();
       generation = infos.getGeneration();
       segmentCount = infos.size();
     }
@@ -463,11 +461,6 @@
     }
 
     @Override
-    public long getVersion() {
-      return version;
-    }
-
-    @Override
     public long getGeneration() {
       return generation;
     }
Index: lucene/src/java/org/apache/lucene/index/IndexReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/IndexReader.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/IndexReader.java	(working copy)
@@ -469,36 +469,6 @@
   }
 
   /**
-   * Returns the time the index in the named directory was last modified. 
-   * Do not use this to check whether the reader is still up-to-date, use
-   * {@link #isCurrent()} instead. 
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   */
-  public static long lastModified(final Directory directory2) throws CorruptIndexException, IOException {
-    return ((Long) new SegmentInfos.FindSegmentsFile(directory2) {
-        @Override
-        public Object doBody(String segmentFileName) throws IOException {
-          return Long.valueOf(directory2.fileModified(segmentFileName));
-        }
-      }.run()).longValue();
-  }
-  
-  /**
-   * Reads version number from segments files. The version number is
-   * initialized with a timestamp and then increased by one for each change of
-   * the index.
-   * 
-   * @param directory where the index resides.
-   * @return version number.
-   * @throws CorruptIndexException if the index is corrupt
-   * @throws IOException if there is a low-level IO error
-   */
-  public static long getCurrentVersion(Directory directory) throws CorruptIndexException, IOException {
-    return SegmentInfos.readCurrentVersion(directory);
-  }
-  
-  /**
    * Reads commitUserData, previously passed to {@link
    * IndexWriter#commit(Map)}, from current index
    * segments file.  This will return null if {@link
@@ -525,19 +495,8 @@
    * a reader based on a Directory), then this method
    * returns the version recorded in the commit that the
    * reader opened.  This version is advanced every time
-   * {@link IndexWriter#commit} is called.</p>
+   * a change is made with {@link IndexWriter}.</p>
    *
-   * <p>If instead this reader is a near real-time reader
-   * (ie, obtained by a call to {@link
-   * IndexWriter#getReader}, or by calling {@link #openIfChanged}
-   * on a near real-time reader), then this method returns
-   * the version of the last commit done by the writer.
-   * Note that even as further changes are made with the
-   * writer, the version will not changed until a commit is
-   * completed.  Thus, you should not rely on this method to
-   * determine when a near real-time reader should be
-   * opened.  Use {@link #isCurrent} instead.</p>
-   *
    * @throws UnsupportedOperationException unless overridden in subclass
    */
   public long getVersion() {
Index: lucene/src/java/org/apache/lucene/index/IndexFileDeleter.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/IndexFileDeleter.java	(revision 1236444)
+++ lucene/src/java/org/apache/lucene/index/IndexFileDeleter.java	(working copy)
@@ -655,7 +655,6 @@
     boolean deleted;
     Directory directory;
     Collection<CommitPoint> commitsToDelete;
-    long version;
     long generation;
     final Map<String,String> userData;
     private final int segmentCount;
@@ -665,7 +664,6 @@
       this.commitsToDelete = commitsToDelete;
       userData = segmentInfos.getUserData();
       segmentsFileName = segmentInfos.getCurrentSegmentFileName();
-      version = segmentInfos.getVersion();
       generation = segmentInfos.getGeneration();
       files = Collections.unmodifiableCollection(segmentInfos.files(directory, true));
       segmentCount = segmentInfos.size();
@@ -697,11 +695,6 @@
     }
 
     @Override
-    public long getVersion() {
-      return version;
-    }
-
-    @Override
     public long getGeneration() {
       return generation;
     }
Index: lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java
===================================================================
--- lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java	(revision 1236444)
+++ lucene/src/test-framework/java/org/apache/lucene/store/MockDirectoryWrapper.java	(working copy)
@@ -703,12 +703,6 @@
   }
 
   @Override
-  public synchronized long fileModified(String name) throws IOException {
-    maybeYield();
-    return delegate.fileModified(name);
-  }
-
-  @Override
   public synchronized long fileLength(String name) throws IOException {
     maybeYield();
     return delegate.fileLength(name);
Index: solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java
===================================================================
--- solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java	(revision 1236444)
+++ solr/core/src/test/org/apache/solr/core/TestSolrDeletionPolicy1.java	(working copy)
@@ -92,10 +92,10 @@
     addDocs();
     Map<Long, IndexCommit> commits = delPolicy.getCommits();
     IndexCommit latest = delPolicy.getLatestCommit();
-    for (Long version : commits.keySet()) {
-      if (commits.get(version) == latest)
+    for (Long gen : commits.keySet()) {
+      if (commits.get(gen) == latest)
         continue;
-      assertEquals(1, commits.get(version).getSegmentCount());
+      assertEquals(1, commits.get(gen).getSegmentCount());
     }
   }
 
@@ -126,7 +126,7 @@
     );
 
     commits = delPolicy.getCommits();
-    assertTrue(!commits.containsKey(ic.getVersion()));
+    assertTrue(!commits.containsKey(ic.getGeneration()));
   }
 
 }
Index: solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java
===================================================================
--- solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/update/SolrIndexWriter.java	(working copy)
@@ -25,6 +25,8 @@
 import java.text.DateFormat;
 import java.util.Date;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.Map;
+import java.util.HashMap;
 
 import org.apache.lucene.codecs.Codec;
 import org.apache.lucene.index.IndexDeletionPolicy;
@@ -50,6 +52,11 @@
   public static final AtomicLong numOpens = new AtomicLong();
   public static final AtomicLong numCloses = new AtomicLong();
 
+
+  /** Stored into each Lucene commit to record the
+   *  System.currentTimeMillis() when commit was called. */
+  public static final String COMMIT_TIME_MSEC_KEY = "commitTimeMSec";
+
   String name;
   private DirectoryFactory directoryFactory;
 
@@ -117,6 +124,7 @@
   @Override
   public void close() throws IOException {
     log.debug("Closing Writer " + name);
+
     Directory directory = getDirectory();
     final InfoStream infoStream = isClosed ? null : getConfig().getInfoStream();    
     try {
Index: solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java
===================================================================
--- solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/update/DirectUpdateHandler2.java	(working copy)
@@ -22,6 +22,8 @@
 
 import java.io.IOException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 import java.util.concurrent.atomic.AtomicLong;
@@ -34,14 +36,14 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.queryparser.classic.ParseException;
+import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.MatchAllDocsQuery;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
+import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.SolrException;
-import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.core.SolrConfig.UpdateHandlerInfo;
@@ -51,6 +53,7 @@
 import org.apache.solr.search.QParser;
 import org.apache.solr.search.QueryUtils;
 import org.apache.solr.search.function.ValueSourceRangeFilter;
+import org.apache.solr.update.SolrIndexWriter;
 
 /**
  *  TODO: add soft commitWithin support
@@ -387,7 +390,9 @@
         }
 
         // SolrCore.verbose("writer.commit() start writer=",writer);
-        writer.commit();
+        final Map<String,String> commitData = new HashMap<String,String>();
+        commitData.put(SolrIndexWriter.COMMIT_TIME_MSEC_KEY, String.valueOf(System.currentTimeMillis()));
+        writer.commit(commitData);
         // SolrCore.verbose("writer.commit() end");
         numDocsPending.set(0);
         callPostCommitCallbacks();
Index: solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java
===================================================================
--- solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/servlet/cache/HttpCacheHeaderUtil.java	(working copy)
@@ -35,6 +35,7 @@
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.update.SolrIndexWriter;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 
@@ -157,7 +158,7 @@
       // assume default, change if needed (getOpenTime() should be fast)
       lastMod =
         LastModFrom.DIRLASTMOD == lastModFrom
-        ? IndexReader.lastModified(searcher.getIndexReader().directory())
+        ? Long.parseLong(searcher.getIndexReader().getIndexCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY))
         : searcher.getOpenTime();
     } catch (IOException e) {
       // we're pretty freaking screwed if this happens
Index: solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java
===================================================================
--- solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/core/IndexDeletionPolicyWrapper.java	(working copy)
@@ -16,15 +16,16 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.index.IndexCommit;
-import org.apache.lucene.index.IndexDeletionPolicy;
-import org.apache.lucene.store.Directory;
-
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.lucene.index.IndexCommit;
+import org.apache.lucene.index.IndexDeletionPolicy;
+import org.apache.lucene.store.Directory;
+import org.apache.solr.update.SolrIndexWriter;
+
 /**
  * A wrapper for an IndexDeletionPolicy instance.
  * <p/>
@@ -65,13 +66,13 @@
   /**
    * Set the duration for which commit point is to be reserved by the deletion policy.
    *
-   * @param indexVersion version of the commit point to be reserved
+   * @param indexGen gen of the commit point to be reserved
    * @param reserveTime  time in milliseconds for which the commit point is to be reserved
    */
-  public void setReserveDuration(Long indexVersion, long reserveTime) {
+  public void setReserveDuration(Long indexGen, long reserveTime) {
     long timeToSet = System.currentTimeMillis() + reserveTime;
     for(;;) {
-      Long previousTime = reserves.put(indexVersion, timeToSet);
+      Long previousTime = reserves.put(indexGen, timeToSet);
 
       // this is the common success case: the older time didn't exist, or
       // came before the new time.
@@ -103,19 +104,19 @@
   /** Permanently prevent this commit point from being deleted.
    * A counter is used to allow a commit point to be correctly saved and released
    * multiple times. */
-  public synchronized void saveCommitPoint(Long indexCommitVersion) {
-    AtomicInteger reserveCount = savedCommits.get(indexCommitVersion);
+  public synchronized void saveCommitPoint(Long indexCommitGen) {
+    AtomicInteger reserveCount = savedCommits.get(indexCommitGen);
     if (reserveCount == null) reserveCount = new AtomicInteger();
     reserveCount.incrementAndGet();
-    savedCommits.put(indexCommitVersion, reserveCount);
+    savedCommits.put(indexCommitGen, reserveCount);
   }
 
   /** Release a previously saved commit point */
-  public synchronized void releaseCommitPoint(Long indexCommitVersion) {
-    AtomicInteger reserveCount = savedCommits.get(indexCommitVersion);
+  public synchronized void releaseCommitPoint(Long indexCommitGen) {
+    AtomicInteger reserveCount = savedCommits.get(indexCommitGen);
     if (reserveCount == null) return;// this should not happen
     if (reserveCount.decrementAndGet() <= 0) {
-      savedCommits.remove(indexCommitVersion);
+      savedCommits.remove(indexCommitGen);
     }
   }
 
@@ -165,10 +166,10 @@
 
     @Override
     public void delete() {
-      Long version = delegate.getVersion();
-      Long reserve = reserves.get(version);
+      Long gen = delegate.getGeneration();
+      Long reserve = reserves.get(gen);
       if (reserve != null && System.currentTimeMillis() < reserve) return;
-      if(savedCommits.containsKey(version)) return;
+      if(savedCommits.containsKey(gen)) return;
       delegate.delete();
     }
 
@@ -188,11 +189,6 @@
     }
 
     @Override
-    public long getVersion() {
-      return delegate.getVersion();
-    }
-
-    @Override
     public long getGeneration() {
       return delegate.getGeneration();
     }
@@ -203,22 +199,17 @@
     }
 
     @Override
-    public long getTimestamp() throws IOException {
-      return delegate.getTimestamp();
-    }
-
-    @Override
     public Map getUserData() throws IOException {
       return delegate.getUserData();
     }    
   }
 
   /**
-   * @param version the version of the commit point
+   * @param gen the gen of the commit point
    * @return a commit point corresponding to the given version
    */
-  public IndexCommit getCommitPoint(Long version) {
-    return solrVersionVsCommits.get(version);
+  public IndexCommit getCommitPoint(Long gen) {
+    return solrVersionVsCommits.get(gen);
   }
 
   /**
@@ -236,10 +227,20 @@
     Map<Long, IndexCommit> map = new ConcurrentHashMap<Long, IndexCommit>();
     for (IndexCommitWrapper wrapper : list) {
       if (!wrapper.isDeleted())
-        map.put(wrapper.getVersion(), wrapper.delegate);
+        map.put(wrapper.delegate.getGeneration(), wrapper.delegate);
     }
     solrVersionVsCommits = map;
     latestCommit = ((list.get(list.size() - 1)).delegate);
   }
+
+  public static long getCommitTimestamp(IndexCommit commit) throws IOException {
+    final Map<String,String> commitData = commit.getUserData();
+    String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
+    if (commitTime != null) {
+      return Long.parseLong(commitTime);
+    } else {
+      return 0;
+    }
+  }
 }
 
Index: solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java
===================================================================
--- solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/core/SolrDeletionPolicy.java	(working copy)
@@ -21,6 +21,7 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.update.SolrIndexWriter;
 import org.apache.solr.schema.DateField;
 import org.apache.solr.util.DateMathParser;
 import org.apache.solr.util.plugin.NamedListInitializedPlugin;
@@ -87,7 +88,6 @@
       }
 
       sb.append(",segFN=").append(commit.getSegmentsFileName());
-      sb.append(",version=").append(commit.getVersion());
       sb.append(",generation=").append(commit.getGeneration());
       sb.append(",filenames=").append(commit.getFileNames());
     } catch (Exception e) {
@@ -133,7 +133,7 @@
     synchronized (this) {
       long maxCommitAgeTimeStamp = -1L;
       IndexCommit newest = commits.get(commits.size() - 1);
-      log.info("newest commit = " + newest.getVersion());
+      log.info("newest commit = " + newest.getGeneration());
 
       int singleSegKept = (newest.getSegmentCount() == 1) ? 1 : 0;
       int totalKept = 1;
@@ -149,7 +149,7 @@
               DateMathParser dmp = new DateMathParser(DateField.UTC, Locale.US);
               maxCommitAgeTimeStamp = dmp.parseMath(maxCommitAge).getTime();
             }
-            if (commit.getTimestamp() < maxCommitAgeTimeStamp) {
+            if (Long.parseLong(commit.getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY)) < maxCommitAgeTimeStamp) {
               commit.delete();
               continue;
             }
@@ -175,27 +175,6 @@
     } // end synchronized
   }
 
-  private String getId(IndexCommit commit) {
-    StringBuilder sb = new StringBuilder();
-    Directory dir = commit.getDirectory();
-
-    // For anything persistent, make something that will
-    // be the same, regardless of the Directory instance.
-    if (dir instanceof FSDirectory) {
-      FSDirectory fsd = (FSDirectory) dir;
-      File fdir = fsd.getDirectory();
-      sb.append(fdir.getPath());
-    } else {
-      sb.append(dir);
-    }
-
-    sb.append('/');
-    sb.append(commit.getGeneration());
-    sb.append('_');
-    sb.append(commit.getVersion());
-    return sb.toString();
-  }
-
   public String getMaxCommitAge() {
     return maxCommitAge;
   }
Index: solr/core/src/java/org/apache/solr/handler/SnapShooter.java
===================================================================
--- solr/core/src/java/org/apache/solr/handler/SnapShooter.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/handler/SnapShooter.java	(working copy)
@@ -70,7 +70,7 @@
   }
 
   void createSnapAsync(final IndexCommit indexCommit, final int numberToKeep, final ReplicationHandler replicationHandler) {
-    replicationHandler.core.getDeletionPolicy().saveCommitPoint(indexCommit.getVersion());
+    replicationHandler.core.getDeletionPolicy().saveCommitPoint(indexCommit.getGeneration());
 
     new Thread() {
       @Override
@@ -112,7 +112,7 @@
       LOG.error("Exception while creating snapshot", e);
       details.add("snapShootException", e.getMessage());
     } finally {
-      replicationHandler.core.getDeletionPolicy().releaseCommitPoint(indexCommit.getVersion());   
+      replicationHandler.core.getDeletionPolicy().releaseCommitPoint(indexCommit.getGeneration());
       replicationHandler.snapShootDetails = details;
       if (lock != null) {
         try {
Index: solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java
===================================================================
--- solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/handler/ReplicationHandler.java	(working copy)
@@ -60,6 +60,7 @@
 import org.apache.solr.response.BinaryQueryResponseWriter;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.search.SolrIndexSearcher;
+import org.apache.solr.update.SolrIndexWriter;
 import org.apache.solr.util.NumberUtils;
 import org.apache.solr.util.RefCounted;
 import org.apache.solr.util.plugin.SolrCoreAware;
@@ -139,8 +140,8 @@
         // in a catastrophic failure, but will result in the client getting an empty file list for
         // the CMD_GET_FILE_LIST command.
         //
-        core.getDeletionPolicy().setReserveDuration(commitPoint.getVersion(), reserveCommitDuration);
-        rsp.add(CMD_INDEX_VERSION, commitPoint.getVersion());
+        core.getDeletionPolicy().setReserveDuration(commitPoint.getGeneration(), reserveCommitDuration);
+        rsp.add(CMD_INDEX_VERSION, core.getDeletionPolicy().getCommitTimestamp(commitPoint));
         rsp.add(GENERATION, commitPoint.getGeneration());
       } else {
         // This happens when replication is not configured to happen after startup and no commit/optimize
@@ -219,7 +220,7 @@
     for (IndexCommit c : commits.values()) {
       try {
         NamedList<Object> nl = new NamedList<Object>();
-        nl.add("indexVersion", c.getVersion());
+        nl.add("indexVersion", core.getDeletionPolicy().getCommitTimestamp(c));
         nl.add(GENERATION, c.getGeneration());
         nl.add(CMD_GET_FILE_LIST, c.getFileNames());
         l.add(nl);
@@ -332,21 +333,21 @@
 
   @SuppressWarnings("unchecked")
   private void getFileList(SolrParams solrParams, SolrQueryResponse rsp) {
-    String v = solrParams.get(CMD_INDEX_VERSION);
+    String v = solrParams.get(GENERATION);
     if (v == null) {
-      rsp.add("status", "no indexversion specified");
+      rsp.add("status", "no index generation specified");
       return;
     }
-    long version = Long.parseLong(v);
-    IndexCommit commit = core.getDeletionPolicy().getCommitPoint(version);
+    long gen = Long.parseLong(v);
+    IndexCommit commit = core.getDeletionPolicy().getCommitPoint(gen);
  
     //System.out.println("ask for files for gen:" + commit.getGeneration() + core.getCoreDescriptor().getCoreContainer().getZkController().getNodeName());
     if (commit == null) {
-      rsp.add("status", "invalid indexversion");
+      rsp.add("status", "invalid index generation");
       return;
     }
     // reserve the indexcommit for sometime
-    core.getDeletionPolicy().setReserveDuration(version, reserveCommitDuration);
+    core.getDeletionPolicy().setReserveDuration(gen, reserveCommitDuration);
     List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
     try {
       //get all the files in the commit
@@ -359,10 +360,10 @@
         result.add(fileMeta);
       }
     } catch (IOException e) {
-      rsp.add("status", "unable to get file names for given indexversion");
+      rsp.add("status", "unable to get file names for given index generation");
       rsp.add("exception", e);
-      LOG.warn("Unable to get file names for indexCommit version: "
-               + version, e);
+      LOG.warn("Unable to get file names for indexCommit generation: "
+               + gen, e);
     }
     rsp.add(CMD_GET_FILE_LIST, result);
     if (confFileNameAlias.size() < 1)
@@ -487,8 +488,13 @@
     long version[] = new long[2];
     RefCounted<SolrIndexSearcher> searcher = core.getSearcher();
     try {
-      version[0] = searcher.get().getIndexReader().getIndexCommit().getVersion();
-      version[1] = searcher.get().getIndexReader().getIndexCommit().getGeneration();
+      final IndexCommit commit = searcher.get().getIndexReader().getIndexCommit();
+      final Map<String,String> commitData = commit.getUserData();
+      String commitTime = commitData.get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
+      if (commitTime != null) {
+        version[0] = Long.parseLong(commitTime);
+      }
+      version[1] = commit.getGeneration();
     } catch (IOException e) {
       LOG.warn("Unable to get index version : ", e);
     } finally {
@@ -574,7 +580,6 @@
     }
 
     if (isMaster && commit != null) {
-      master.add("replicatableIndexVersion", commit.getVersion());
       master.add("replicatableGeneration", commit.getGeneration());
     }
 
@@ -846,7 +851,7 @@
                 Collection<IndexCommit> commits = IndexReader.listCommits(reader.directory());
                 for (IndexCommit ic : commits) {
                   if(ic.getSegmentCount() == 1){
-                    if(indexCommitPoint == null || indexCommitPoint.getVersion() < ic.getVersion()) indexCommitPoint = ic;
+                    if(indexCommitPoint == null || indexCommitPoint.getGeneration() < ic.getGeneration()) indexCommitPoint = ic;
                   }
                 }
               } else{
@@ -857,7 +862,7 @@
               // always saves the last commit point (and the last optimized commit point, if needed)
               /***
               if(indexCommitPoint != null){
-                core.getDeletionPolicy().saveCommitPoint(indexCommitPoint.getVersion());
+                core.getDeletionPolicy().saveCommitPoint(indexCommitPoint.getGeneration());
               }
               ***/
             }
@@ -958,10 +963,10 @@
           // always saves the last commit point (and the last optimized commit point, if needed)
           /***
           if (indexCommitPoint != null) {
-            core.getDeletionPolicy().saveCommitPoint(indexCommitPoint.getVersion());
+            core.getDeletionPolicy().saveCommitPoint(indexCommitPoint.getGeneration());
           }
           if(oldCommitPoint != null){
-            core.getDeletionPolicy().releaseCommitPoint(oldCommitPoint.getVersion());
+            core.getDeletionPolicy().releaseCommitPoint(oldCommitPoint.getGeneration());
           }
           ***/
         }
@@ -989,7 +994,7 @@
 
     private FastOutputStream fos;
 
-    private Long indexVersion;
+    private Long indexGen;
     private IndexDeletionPolicyWrapper delPolicy;
 
     public FileStream(SolrParams solrParams) {
@@ -1004,8 +1009,8 @@
       String sLen = params.get(LEN);
       String compress = params.get(COMPRESSION);
       String sChecksum = params.get(CHECKSUM);
-      String sindexVersion = params.get(CMD_INDEX_VERSION);
-      if (sindexVersion != null) indexVersion = Long.parseLong(sindexVersion);
+      String sGen = params.get(GENERATION);
+      if (sGen != null) indexGen = Long.parseLong(sGen);
       if (Boolean.parseBoolean(compress)) {
         fos = new FastOutputStream(new DeflaterOutputStream(out));
       } else {
@@ -1063,9 +1068,9 @@
             }
             fos.write(buf, 0, (int) bytesRead);
             fos.flush();
-            if (indexVersion != null && (packetsWritten % 5 == 0)) {
+            if (indexGen != null && (packetsWritten % 5 == 0)) {
               //after every 5 packets reserve the commitpoint for some time
-              delPolicy.setReserveDuration(indexVersion, reserveCommitDuration);
+              delPolicy.setReserveDuration(indexGen, reserveCommitDuration);
             }
             packetsWritten++;
           }
Index: solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java
===================================================================
--- solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java	(working copy)
@@ -48,6 +48,7 @@
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.schema.FieldType;
+import org.apache.solr.update.SolrIndexWriter;
 import org.apache.solr.schema.IndexSchema;
 import org.apache.solr.schema.SchemaField;
 import org.apache.solr.search.SolrIndexSearcher;
@@ -562,7 +563,10 @@
     indexInfo.add("current", reader.isCurrent() );
     indexInfo.add("hasDeletions", reader.hasDeletions() );
     indexInfo.add("directory", dir );
-    indexInfo.add("lastModified", new Date(IndexReader.lastModified(dir)) );
+    String s = reader.getIndexCommit().getUserData().get(SolrIndexWriter.COMMIT_TIME_MSEC_KEY);
+    if (s != null) {
+      indexInfo.add("lastModified", new Date(Long.parseLong(s)));
+    }
     return indexInfo;
   }
   //////////////////////// SolrInfoMBeans methods //////////////////////
Index: solr/core/src/java/org/apache/solr/handler/SnapPuller.java
===================================================================
--- solr/core/src/java/org/apache/solr/handler/SnapPuller.java	(revision 1236444)
+++ solr/core/src/java/org/apache/solr/handler/SnapPuller.java	(working copy)
@@ -28,6 +28,7 @@
 import org.apache.solr.common.util.JavaBinCodec;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.core.SolrCore;
+import org.apache.solr.core.IndexDeletionPolicyWrapper;
 import static org.apache.solr.handler.ReplicationHandler.*;
 
 import org.apache.solr.request.LocalSolrQueryRequest;
@@ -210,10 +211,10 @@
   /**
    * Fetches the list of files in a given index commit point
    */
-  void fetchFileList(long version) throws IOException {
+  void fetchFileList(long gen) throws IOException {
     PostMethod post = new PostMethod(masterUrl);
     post.addParameter(COMMAND, CMD_GET_FILE_LIST);
-    post.addParameter(CMD_INDEX_VERSION, String.valueOf(version));
+    post.addParameter(GENERATION, String.valueOf(gen));
     post.addParameter("wt", "javabin");
 
     @SuppressWarnings("unchecked")
@@ -225,7 +226,7 @@
       filesToDownload = Collections.synchronizedList(f);
     else {
       filesToDownload = Collections.emptyList();
-      LOG.error("No files to download for indexversion: "+ version);
+      LOG.error("No files to download for index generation: "+ gen);
     }
 
     f = nl.get(CONF_FILES);
@@ -274,7 +275,7 @@
       }
       
       if (latestVersion == 0L) {
-        if (force && commit.getVersion() != 0) {
+        if (force && commit.getGeneration() != 0) {
           // since we won't get the files for an empty index,
           // we just clear ours and commit
           core.getUpdateHandler().getSolrCoreState().getIndexWriter(core).deleteAll();
@@ -288,17 +289,17 @@
         return true;
       }
       
-      if (commit.getVersion() == latestVersion && commit.getGeneration() == latestGeneration) {
+      if (IndexDeletionPolicyWrapper.getCommitTimestamp(commit) == latestVersion) {
         //master and slave are already in sync just return
         LOG.info("Slave in sync with master.");
         successfulInstall = true;
         return true;
       }
-      LOG.info("Master's version: " + latestVersion + ", generation: " + latestGeneration);
-      LOG.info("Slave's version: " + commit.getVersion() + ", generation: " + commit.getGeneration());
+      LOG.info("Master's generation: " + latestGeneration);
+      LOG.info("Slave's generation: " + commit.getGeneration());
       LOG.info("Starting replication process");
       // get the list of files first
-      fetchFileList(latestVersion);
+      fetchFileList(latestGeneration);
       // this can happen if the commit point is deleted before we fetch the file list.
       if(filesToDownload.isEmpty()) return false;
       LOG.info("Number of files in latest index in master: " + filesToDownload.size());
@@ -309,7 +310,7 @@
       filesDownloaded = Collections.synchronizedList(new ArrayList<Map<String, Object>>());
       // if the generateion of master is older than that of the slave , it means they are not compatible to be copied
       // then a new index direcory to be created and all the files need to be copied
-      boolean isFullCopyNeeded = commit.getVersion() >= latestVersion || force;
+      boolean isFullCopyNeeded = IndexDeletionPolicyWrapper.getCommitTimestamp(commit) >= latestVersion || force;
       File tmpIndexDir = createTempindexDir(core);
       if (isIndexStale())
         isFullCopyNeeded = true;
@@ -318,11 +319,11 @@
       File indexDir = null ;
       try {
         indexDir = new File(core.getIndexDir());
-        downloadIndexFiles(isFullCopyNeeded, tmpIndexDir, latestVersion);
+        downloadIndexFiles(isFullCopyNeeded, tmpIndexDir, latestGeneration);
         LOG.info("Total time taken for download : " + ((System.currentTimeMillis() - replicationStartTime) / 1000) + " secs");
         Collection<Map<String, Object>> modifiedConfFiles = getModifiedConfFiles(confFilesToDownload);
         if (!modifiedConfFiles.isEmpty()) {
-          downloadConfFiles(confFilesToDownload, latestVersion);
+          downloadConfFiles(confFilesToDownload, latestGeneration);
           if (isFullCopyNeeded) {
             successfulInstall = modifyIndexProps(tmpIndexDir.getName());
             deleteTmpIdxDir =  false;
@@ -530,7 +531,7 @@
     }.start();
   }
 
-  private void downloadConfFiles(List<Map<String, Object>> confFilesToDownload, long latestVersion) throws Exception {
+  private void downloadConfFiles(List<Map<String, Object>> confFilesToDownload, long latestGeneration) throws Exception {
     LOG.info("Starting download of configuration files from master: " + confFilesToDownload);
     confFilesDownloaded = Collections.synchronizedList(new ArrayList<Map<String, Object>>());
     File tmpconfDir = new File(solrCore.getResourceLoader().getConfigDir(), "conf." + getDateAsStr(new Date()));
@@ -542,7 +543,7 @@
       }
       for (Map<String, Object> file : confFilesToDownload) {
         String saveAs = (String) (file.get(ALIAS) == null ? file.get(NAME) : file.get(ALIAS));
-        fileFetcher = new FileFetcher(tmpconfDir, file, saveAs, true, latestVersion);
+        fileFetcher = new FileFetcher(tmpconfDir, file, saveAs, true, latestGeneration);
         currentFile = file;
         fileFetcher.fetchFile();
         confFilesDownloaded.add(new HashMap<String, Object>(file));
@@ -561,13 +562,13 @@
    *
    * @param downloadCompleteIndex is it a fresh index copy
    * @param tmpIdxDir               the directory to which files need to be downloadeed to
-   * @param latestVersion         the version number
+   * @param latestGeneration         the version number
    */
-  private void downloadIndexFiles(boolean downloadCompleteIndex, File tmpIdxDir, long latestVersion) throws Exception {
+  private void downloadIndexFiles(boolean downloadCompleteIndex, File tmpIdxDir, long latestGeneration) throws Exception {
     for (Map<String, Object> file : filesToDownload) {
       File localIndexFile = new File(solrCore.getIndexDir(), (String) file.get(NAME));
       if (!localIndexFile.exists() || downloadCompleteIndex) {
-        fileFetcher = new FileFetcher(tmpIdxDir, file, (String) file.get(NAME), false, latestVersion);
+        fileFetcher = new FileFetcher(tmpIdxDir, file, (String) file.get(NAME), false, latestGeneration);
         currentFile = file;
         fileFetcher.fetchFile();
         filesDownloaded.add(new HashMap<String, Object>(file));
@@ -896,10 +897,10 @@
 
     private boolean aborted = false;
 
-    private Long indexVersion;
+    private Long indexGen;
 
     FileFetcher(File dir, Map<String, Object> fileDetails, String saveAs,
-                boolean isConf, long latestVersion) throws IOException {
+                boolean isConf, long latestGen) throws IOException {
       this.copy2Dir = dir;
       this.fileName = (String) fileDetails.get(NAME);
       this.size = (Long) fileDetails.get(SIZE);
@@ -908,7 +909,7 @@
       if(fileDetails.get(LAST_MODIFIED) != null){
         lastmodified = (Long)fileDetails.get(LAST_MODIFIED);
       }
-      indexVersion = latestVersion;
+      indexGen = latestGen;
 
       this.file = new File(copy2Dir, saveAs);
       
@@ -1077,7 +1078,7 @@
       //the method is command=filecontent
       post.addParameter(COMMAND, CMD_GET_FILE);
       //add the version to download. This is used to reserve the download
-      post.addParameter(CMD_INDEX_VERSION, indexVersion.toString());
+      post.addParameter(GENERATION, indexGen.toString());
       if (isConf) {
         //set cf instead of file for config file
         post.addParameter(CONF_FILE_SHORT, fileName);
