mirror of https://github.com/apache/lucene.git
SOLR-9901: Implement move in HdfsDirectoryFactory.
This commit is contained in:
parent
a5e5c4a043
commit
197590a928
|
@ -294,6 +294,8 @@ Bug Fixes
|
||||||
* SOLR-9859: replication.properties cannot be updated after being written and neither replication.properties or
|
* 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)
|
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
|
Other Changes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.hadoop.fs.Path;
|
||||||
import org.apache.hadoop.fs.PathFilter;
|
import org.apache.hadoop.fs.PathFilter;
|
||||||
import org.apache.hadoop.security.UserGroupInformation;
|
import org.apache.hadoop.security.UserGroupInformation;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.LockFactory;
|
import org.apache.lucene.store.LockFactory;
|
||||||
import org.apache.lucene.store.NRTCachingDirectory;
|
import org.apache.lucene.store.NRTCachingDirectory;
|
||||||
import org.apache.lucene.store.NoLockFactory;
|
import org.apache.lucene.store.NoLockFactory;
|
||||||
|
@ -577,4 +578,23 @@ public class HdfsDirectoryFactory extends CachingDirectoryFactory implements Sol
|
||||||
FileContext fileContext = FileContext.getFileContext(getConf());
|
FileContext fileContext = FileContext.getFileContext(getConf());
|
||||||
fileContext.rename(new Path(hdfsDirPath + "/" + fileName), new Path(hdfsDirPath + "/" + toName), Options.Rename.OVERWRITE);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue