Repository: hbase Updated Branches: refs/heads/master 9246af8da -> ee32eebea
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/ee32eebe Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ee32eebe Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ee32eebe Branch: refs/heads/master Commit: ee32eebeab38be4e171c6aaf362aff9a584a37f3 Parents: 9246af8 Author: tedyu <[email protected]> Authored: Thu Jan 8 08:51:25 2015 -0800 Committer: tedyu <[email protected]> Committed: Thu Jan 8 08:51:25 2015 -0800 ---------------------------------------------------------------------- .../apache/hadoop/hbase/snapshot/ExportSnapshot.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/ee32eebe/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 02ae346..2655e2b 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 @@ -59,6 +59,7 @@ import org.apache.hadoop.hbase.protobuf.generated.SnapshotProtos.SnapshotRegionM 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.Writable; import org.apache.hadoop.mapreduce.Job; @@ -152,12 +153,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); @@ -174,6 +177,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(key.copyBytes()); @@ -854,8 +863,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()); @@ -949,6 +960,9 @@ public class ExportSnapshot extends Configured implements Tool { } outputFs.delete(outputSnapshotDir, true); return 1; + } finally { + IOUtils.closeStream(inputFs); + IOUtils.closeStream(outputFs); } }
