From fc656273d494eff26a1d18adab0bfbd32222cb56 Mon Sep 17 00:00:00 2001 From: Bilung Lee Date: Thu, 3 Nov 2011 07:10:50 +0000 Subject: [PATCH] SQOOP-373 Can only write to default file system on direct import git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1196980 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/sqoop/io/SplittingOutputStream.java | 3 +-- src/java/org/apache/sqoop/util/DirectImportUtils.java | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/sqoop/io/SplittingOutputStream.java b/src/java/org/apache/sqoop/io/SplittingOutputStream.java index 60d554f1..5f98192e 100644 --- a/src/java/org/apache/sqoop/io/SplittingOutputStream.java +++ b/src/java/org/apache/sqoop/io/SplittingOutputStream.java @@ -79,8 +79,6 @@ public SplittingOutputStream(final Configuration conf, final Path destDir, /** Initialize the OutputStream to the next file to write to. */ private void openNextFile() throws IOException { - FileSystem fs = FileSystem.get(conf); - StringBuffer sb = new StringBuffer(); Formatter fmt = new Formatter(sb); fmt.format("%05d", this.fileNum++); @@ -89,6 +87,7 @@ private void openNextFile() throws IOException { filename = filename + codec.getDefaultExtension(); } Path destFile = new Path(destDir, filename); + FileSystem fs = destFile.getFileSystem(conf); LOG.debug("Opening next output file: " + destFile); if (fs.exists(destFile)) { Path canonicalDest = destFile.makeQualified(fs); diff --git a/src/java/org/apache/sqoop/util/DirectImportUtils.java b/src/java/org/apache/sqoop/util/DirectImportUtils.java index 8ea9662c..e1bf22f4 100644 --- a/src/java/org/apache/sqoop/util/DirectImportUtils.java +++ b/src/java/org/apache/sqoop/util/DirectImportUtils.java @@ -77,10 +77,10 @@ public static void setFilePermissions(File file, String modstr) public static SplittableBufferedWriter createHdfsSink(Configuration conf, SqoopOptions options, ImportJobContext context) throws IOException { - FileSystem fs = FileSystem.get(conf); Path destDir = context.getDestination(); + FileSystem fs = destDir.getFileSystem(conf); - LOG.debug("Writing to filesystem: " + conf.get("fs.default.name")); + LOG.debug("Writing to filesystem: " + fs.getUri()); LOG.debug("Creating destination directory " + destDir); fs.mkdirs(destDir);