You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2017/01/03 22:44:48 UTC

[2/6] lucene-solr:branch_6x: SOLR-9901: Implement move in HdfsDirectoryFactory.

SOLR-9901: Implement move in HdfsDirectoryFactory.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/90902a61
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/90902a61
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/90902a61

Branch: refs/heads/branch_6x
Commit: 90902a610ba724c7f02096b167cfb921e383789c
Parents: 7eebe5d
Author: markrmiller <ma...@apache.org>
Authored: Wed Dec 28 16:16:14 2016 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Tue Jan 3 17:36:35 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 ++
 .../apache/solr/core/HdfsDirectoryFactory.java  | 20 ++++++++++++++++++++
 2 files changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/90902a61/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 8cb645c..283e47b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -252,6 +252,8 @@ Bug Fixes
 * SOLR-9859: replication.properties cannot be updated after being written and neither replication.properties or 
   index.properties are durable in the face of a crash. (Pushkar Raste, Chris de Kok, Cao Manh Dat, Mark Miller)
 
+* SOLR-9901: Implement move in HdfsDirectoryFactory. (Mark Miller)
+
 Other Changes
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/90902a61/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
index d481e03..e1e3d6e 100644
--- a/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
+++ b/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
@@ -37,6 +37,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IOContext;
 import org.apache.lucene.store.LockFactory;
 import org.apache.lucene.store.NRTCachingDirectory;
 import org.apache.lucene.store.NoLockFactory;
@@ -577,4 +578,23 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
     FileContext fileContext = FileContext.getFileContext(getConf());
     fileContext.rename(new Path(hdfsDirPath + "/" + fileName), new Path(hdfsDirPath + "/" + toName), Options.Rename.OVERWRITE);
   }
+  
+  @Override
+  public void move(Directory fromDir, Directory toDir, String fileName, IOContext ioContext) throws IOException {
+    
+    Directory baseFromDir = getBaseDir(fromDir);
+    Directory baseToDir = getBaseDir(toDir);
+    
+    if (baseFromDir instanceof HdfsDirectory && baseToDir instanceof HdfsDirectory) {
+      Path dir1 = ((HdfsDirectory) baseFromDir).getHdfsDirPath();
+      Path dir2 = ((HdfsDirectory) baseToDir).getHdfsDirPath();
+      Path file1 = new Path(dir1, fileName);
+      Path file2 = new Path(dir2, fileName);
+      FileContext fileContext = FileContext.getFileContext(getConf());
+      fileContext.rename(file1, file2);
+      return;
+    }
+
+    super.move(fromDir, toDir, fileName, ioContext);
+  }
 }