mirror of
https://github.com/apache/sqoop.git
synced 2025-05-04 06:22:46 +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:
parent
230c687d88
commit
21040519b0
@ -24,12 +24,15 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.util.Shell;
|
import org.apache.hadoop.util.Shell;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A named FIFO channel.
|
* A named FIFO channel.
|
||||||
*/
|
*/
|
||||||
public class NamedFifo {
|
public class NamedFifo {
|
||||||
|
|
||||||
|
private static final Logger LOG = Logger.getLogger(NamedFifo.class);
|
||||||
|
|
||||||
private File fifoFile;
|
private File fifoFile;
|
||||||
|
|
||||||
/** Create a named FIFO object at the local fs path given by 'pathname'. */
|
/** 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.
|
* Create a named FIFO object with the specified fs permissions.
|
||||||
* This depends on the 'mknod' system utility existing. (for example,
|
* This depends on the 'mknod' or 'mkfifo' (Mac OS X) system utility
|
||||||
* provided by Linux coreutils). This object will be deleted when
|
* existing. (for example, provided by Linux coreutils). This object
|
||||||
* the process exits.
|
* will be deleted when the process exits.
|
||||||
* @throws IOException on failure.
|
* @throws IOException on failure.
|
||||||
*/
|
*/
|
||||||
public void create(int permissions) throws IOException {
|
public void create(int permissions) throws IOException {
|
||||||
@ -73,7 +76,20 @@ public void create(int permissions) throws IOException {
|
|||||||
String modeStr = Integer.toString(permissions, 8);
|
String modeStr = Integer.toString(permissions, 8);
|
||||||
|
|
||||||
// Create the FIFO itself.
|
// 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.
|
// Schedule the FIFO to be cleaned up when we exit.
|
||||||
this.fifoFile.deleteOnExit();
|
this.fifoFile.deleteOnExit();
|
||||||
|
Loading…
Reference in New Issue
Block a user