5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-03 05:01:10 +08:00

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
This commit is contained in:
Arvind Prabhakar 2011-09-22 00:32:51 +00:00
parent 230c687d88
commit 21040519b0

View File

@ -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();