Repository: hbase Updated Branches: refs/heads/0.98 6ef814e6d -> 40390b139
HBASE-12819 ExportSnapshot doesn't close FileSystem instances Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/40390b13 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/40390b13 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/40390b13 Branch: refs/heads/0.98 Commit: 40390b13940178f729a0cc144ad5ebd3e671caf5 Parents: 6ef814e Author: tedyu <yuzhih...@gmail.com> Authored: Thu Jan 8 09:02:37 2015 -0800 Committer: tedyu <yuzhih...@gmail.com> Committed: Thu Jan 8 09:02:37 2015 -0800 ---------------------------------------------------------------------- .../apache/hadoop/hbase/snapshot/ExportSnapshot.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/40390b13/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java index f9c7a6d..5e2d0df 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/snapshot/ExportSnapshot.java @@ -63,6 +63,7 @@ import org.apache.hadoop.hbase.util.EnvironmentEdgeManager; import org.apache.hadoop.hbase.util.FSUtils; import org.apache.hadoop.hbase.util.Pair; import org.apache.hadoop.io.BytesWritable; +import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.io.SequenceFile; import org.apache.hadoop.io.Writable; @@ -157,12 +158,14 @@ public class ExportSnapshot extends Configured implements Tool { testFailures = conf.getBoolean(CONF_TEST_FAILURE, false); try { + conf.setBoolean("fs." + inputRoot.toUri().getScheme() + ".impl.disable.cache", true); inputFs = FileSystem.get(inputRoot.toUri(), conf); } catch (IOException e) { throw new IOException("Could not get the input FileSystem with root=" + inputRoot, e); } try { + conf.setBoolean("fs." + outputRoot.toUri().getScheme() + ".impl.disable.cache", true); outputFs = FileSystem.get(outputRoot.toUri(), conf); } catch (IOException e) { throw new IOException("Could not get the output FileSystem with root="+ outputRoot, e); @@ -185,6 +188,12 @@ public class ExportSnapshot extends Configured implements Tool { } @Override + protected void cleanup(Context context) { + IOUtils.closeStream(inputFs); + IOUtils.closeStream(outputFs); + } + + @Override public void map(BytesWritable key, NullWritable value, Context context) throws InterruptedException, IOException { SnapshotFileInfo inputInfo = SnapshotFileInfo.parseFrom(copyBytes(key)); @@ -863,8 +872,10 @@ public class ExportSnapshot extends Configured implements Tool { targetName = snapshotName; } + conf.setBoolean("fs." + inputRoot.toUri().getScheme() + ".impl.disable.cache", true); FileSystem inputFs = FileSystem.get(inputRoot.toUri(), conf); LOG.debug("inputFs=" + inputFs.getUri().toString() + " inputRoot=" + inputRoot); + conf.setBoolean("fs." + outputRoot.toUri().getScheme() + ".impl.disable.cache", true); FileSystem outputFs = FileSystem.get(outputRoot.toUri(), conf); LOG.debug("outputFs=" + outputFs.getUri().toString() + " outputRoot=" + outputRoot.toString()); @@ -958,6 +969,9 @@ public class ExportSnapshot extends Configured implements Tool { } outputFs.delete(outputSnapshotDir, true); return 1; + } finally { + IOUtils.closeStream(inputFs); + IOUtils.closeStream(outputFs); } }