From 21040519b09634b0c4d7ac9a43ef033d48ba199b Mon Sep 17 00:00:00 2001 From: Arvind Prabhakar Date: Thu, 22 Sep 2011 00:32:51 +0000 Subject: [PATCH] SQOOP-339. Error handling for mknod failure. (Joey Echeverria via Arvind Prabhakar) git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1173919 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/com/cloudera/sqoop/io/NamedFifo.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/java/com/cloudera/sqoop/io/NamedFifo.java b/src/java/com/cloudera/sqoop/io/NamedFifo.java index 421fb4b0..9a9f6d08 100644 --- a/src/java/com/cloudera/sqoop/io/NamedFifo.java +++ b/src/java/com/cloudera/sqoop/io/NamedFifo.java @@ -24,12 +24,15 @@ import java.io.IOException; import org.apache.hadoop.util.Shell; +import org.apache.log4j.Logger; /** * A named FIFO channel. */ public class NamedFifo { + private static final Logger LOG = Logger.getLogger(NamedFifo.class); + private File fifoFile; /** Create a named FIFO object at the local fs path given by 'pathname'. */ @@ -61,9 +64,9 @@ public void create() throws IOException { /** * Create a named FIFO object with the specified fs permissions. - * This depends on the 'mknod' system utility existing. (for example, - * provided by Linux coreutils). This object will be deleted when - * the process exits. + * This depends on the 'mknod' or 'mkfifo' (Mac OS X) system utility + * existing. (for example, provided by Linux coreutils). This object + * will be deleted when the process exits. * @throws IOException on failure. */ public void create(int permissions) throws IOException { @@ -73,7 +76,20 @@ public void create(int permissions) throws IOException { String modeStr = Integer.toString(permissions, 8); // Create the FIFO itself. - Shell.execCommand("mknod", "--mode=0" + modeStr, filename, "p"); + try { + String output = Shell.execCommand("mknod", "--mode=0" + modeStr, + filename, "p"); + LOG.info("mknod output:\n"+output); + } catch (IOException ex) { + LOG.info("IO error running mknod: " + ex.getMessage()); + LOG.debug("IO error running mknod", ex); + } + if (!this.fifoFile.exists()) { + LOG.info("mknod failed, falling back to mkfifo"); + String output = Shell.execCommand("mkfifo", "-m", "0" + modeStr, + filename); + LOG.info("mkfifo output:\n"+output); + } // Schedule the FIFO to be cleaned up when we exit. this.fifoFile.deleteOnExit();