Author: olga Date: Mon Sep 22 13:14:03 2008 New Revision: 697969 URL: http://svn.apache.org/viewvc?rev=697969&view=rev Log: PIG-411: Pig leaves HOD processes behind if Ctrl-C is used before HOD connection is fully established
Modified: incubator/pig/branches/types/CHANGES.txt incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java Modified: incubator/pig/branches/types/CHANGES.txt URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/CHANGES.txt?rev=697969&r1=697968&r2=697969&view=diff ============================================================================== --- incubator/pig/branches/types/CHANGES.txt (original) +++ incubator/pig/branches/types/CHANGES.txt Mon Sep 22 13:14:03 2008 @@ -1,6 +1,5 @@ Pig Change Log - Trunk (unreleased changes) INCOMPATIBLE CHANGES @@ -205,6 +204,8 @@ PIG-333: allowing no parethesis with single column alias with flatten (sms via olgan) + PIG-426: Adding result of two UDFs gives a syntax error + PIG-426: Adding result of two UDFs gives a syntax error (sms via olgan) PIG-436: alias is lost when single column is flattened (pradeepk via @@ -224,4 +225,5 @@ PIG-424: nested foreach with flatten and agg gives an error (sms via olgan) - + PIG-411: Pig leaves HOD processes behind if Ctrl-C is used before HOD + connection is fully established (olgan) Modified: incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java URL: http://svn.apache.org/viewvc/incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java?rev=697969&r1=697968&r2=697969&view=diff ============================================================================== --- incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java (original) +++ incubator/pig/branches/types/src/org/apache/pig/backend/hadoop/executionengine/HExecutionEngine.java Mon Sep 22 13:14:03 2008 @@ -360,7 +360,7 @@ // setup shutdown hook to make sure we tear down hod connection Runtime.getRuntime().addShutdownHook(new ShutdownThread()); - hodProcess = runCommand(server, cmdarray); + runCommand(server, cmdarray, true); // print all the information provided by HOD try { @@ -422,8 +422,12 @@ } private synchronized void closeHod(String server){ - if (hodProcess == null) + if (hodProcess == null){ + // just cleanup the dir if it exists and return + if (hodConfDir != null) + deleteDir(server, hodConfDir); return; + } // hod deallocate format: hod deallocate -d <conf dir> String[] cmdarray = new String[4]; @@ -439,13 +443,17 @@ log.debug("Disconnect command: " + cmdToString(cmdarray)); try { - Process p = runCommand(server, cmdarray); + runCommand(server, cmdarray, false); } catch (Exception e) { log.warn("Failed to disconnect from HOD; error: " + e.getMessage()); + hodProcess.destroy(); } finally { - if (remoteHodConfDir != null) + if (remoteHodConfDir != null){ deleteDir(server, remoteHodConfDir); - deleteDir(LOCAL, hodConfDir); + if (hodConfDir != null) + deleteDir(LOCAL, hodConfDir); + }else + deleteDir(server, hodConfDir); } hodProcess = null; @@ -462,7 +470,7 @@ cmdarray[0] = "cat"; cmdarray[1] = remoteFile; - Process p = runCommand(server, cmdarray); + Process p = runCommand(server, cmdarray, false); BufferedWriter bw; try { @@ -497,7 +505,7 @@ return cmd.toString(); } - private Process runCommand(String server, String[] cmdarray) throws ExecException { + private Process runCommand(String server, String[] cmdarray, boolean connect) throws ExecException { Process p; try { if (server.equals(LOCAL)) { @@ -508,6 +516,9 @@ p = fac.ssh(cmdToString(cmdarray)); } + if (connect) + hodProcess = p; + //this should return as soon as connection is shutdown int rc = p.waitFor(); if (rc != 0) { @@ -572,7 +583,7 @@ cmdarray[2] = dir; try{ - Process p = runCommand(server, cmdarray); + runCommand(server, cmdarray, false); }catch(Exception e){ log.warn("Failed to remove HOD configuration directory - " + dir); } @@ -667,7 +678,7 @@ cmdarray[1] = dir; try{ - Process p = runCommand(server, cmdarray); + runCommand(server, cmdarray, false); } catch(ExecException e){ log.warn("Failed to create HOD configuration directory - " + dir + "Retrying...");