You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2016/12/30 15:57:15 UTC
[39/50] [abbrv] lucene-solr:jira/solr-9854: 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/197590a9
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/197590a9
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/197590a9
Branch: refs/heads/jira/solr-9854
Commit: 197590a928cfefa51b1a8307046e5a11e5400e34
Parents: a5e5c4a
Author: markrmiller <ma...@apache.org>
Authored: Wed Dec 28 16:16:14 2016 -0500
Committer: markrmiller <ma...@apache.org>
Committed: Thu Dec 29 05:47:41 2016 -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/197590a9/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 06566e0..1383859 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -294,6 +294,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/197590a9/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);
+ }
}