Repository: incubator-blur Updated Branches: refs/heads/console-v2 1ffef615f -> d276fd610
Fixing a symlink in the HdfsDirectory. Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/9b96e817 Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/9b96e817 Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/9b96e817 Branch: refs/heads/console-v2 Commit: 9b96e817c3f5780073c58ec70baba0b8367ef142 Parents: 08c2c52 Author: Aaron McCurry <[email protected]> Authored: Sat Mar 22 11:41:30 2014 -0400 Committer: Aaron McCurry <[email protected]> Committed: Sat Mar 22 11:41:30 2014 -0400 ---------------------------------------------------------------------- .../blur/manager/writer/IndexImporterTest.java | 9 +++++++++ .../apache/blur/store/hdfs/HdfsDirectory.java | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9b96e817/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java ---------------------------------------------------------------------- diff --git a/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java b/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java index 821065d..4800865 100644 --- a/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java +++ b/blur-core/src/test/java/org/apache/blur/manager/writer/IndexImporterTest.java @@ -212,6 +212,12 @@ public class IndexImporterTest { assertFalse(_fileSystem.exists(_path)); assertFalse(_fileSystem.exists(_badRowIdsPath)); assertTrue(_fileSystem.exists(_badIndexPath)); + validateIndex(); + } + + private void validateIndex() throws IOException { + HdfsDirectory dir = new HdfsDirectory(_configuration, _shardPath); + DirectoryReader.open(dir).close(); } @Test @@ -241,6 +247,7 @@ public class IndexImporterTest { } _indexImporter.cleanupOldDirs(); assertFalse(fileSystem.exists(_path)); + validateIndex(); } @Test @@ -253,6 +260,7 @@ public class IndexImporterTest { assertFalse(_fileSystem.exists(_path)); assertFalse(_fileSystem.exists(_badRowIdsPath)); assertTrue(_fileSystem.exists(_inUsePath)); + validateIndex(); } @Test @@ -265,6 +273,7 @@ public class IndexImporterTest { assertFalse(_fileSystem.exists(_path)); assertTrue(_fileSystem.exists(_badRowIdsPath)); assertFalse(_fileSystem.exists(_inUsePath)); + validateIndex(); } private Record genRecord(String recordId) { http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/9b96e817/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java ---------------------------------------------------------------------- diff --git a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java index bdf4f31..bd1a236 100644 --- a/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java +++ b/blur-store/src/main/java/org/apache/blur/store/hdfs/HdfsDirectory.java @@ -97,12 +97,29 @@ public class HdfsDirectory extends Directory implements LastModified, HdfsSymlin FileStatus[] listStatus = _fileSystem.listStatus(_path); for (FileStatus fileStatus : listStatus) { if (!fileStatus.isDir()) { - _fileLengthMap.put(fileStatus.getPath().getName(), fileStatus.getLen()); + Path p = fileStatus.getPath(); + String name = p.getName(); + if (name.endsWith(LNK)) { + String resolvedName = getRealFileName(name); + Path resolvedPath = getPath(resolvedName); + FileStatus resolvedFileStatus = _fileSystem.getFileStatus(resolvedPath); + _fileLengthMap.put(resolvedName, resolvedFileStatus.getLen()); + } else { + _fileLengthMap.put(name, fileStatus.getLen()); + } } } } } + private String getRealFileName(String name) { + if (name.endsWith(LNK)) { + int lastIndexOf = name.lastIndexOf(LNK); + return name.substring(0, lastIndexOf); + } + return name; + } + private MetricsGroup createNewMetricsGroup(String scope) { MetricName readAccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Read Latency in \u00B5s", scope); MetricName writeAcccessName = new MetricName(ORG_APACHE_BLUR, HDFS, "Write Latency in \u00B5s", scope);
