You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ds...@apache.org on 2015/06/14 19:32:07 UTC
ambari git commit: AMBARI-11914 Enable NameNode HA fails while
stopping RegionServer (dsen)
Repository: ambari
Updated Branches:
refs/heads/trunk 094245f31 -> 9ad9dcc25
AMBARI-11914 Enable NameNode HA fails while stopping RegionServer (dsen)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9ad9dcc2
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9ad9dcc2
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9ad9dcc2
Branch: refs/heads/trunk
Commit: 9ad9dcc25cf26a269637db8d3ffc26be205bc5eb
Parents: 094245f
Author: Dmytro Sen <ds...@apache.org>
Authored: Sun Jun 14 20:31:49 2015 +0300
Committer: Dmytro Sen <ds...@apache.org>
Committed: Sun Jun 14 20:31:49 2015 +0300
----------------------------------------------------------------------
.../python/resource_management/core/shell.py | 34 ++++++++++----------
1 file changed, 17 insertions(+), 17 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/9ad9dcc2/ambari-common/src/main/python/resource_management/core/shell.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py
index 1ea27f8..75b5fcf 100644
--- a/ambari-common/src/main/python/resource_management/core/shell.py
+++ b/ambari-common/src/main/python/resource_management/core/shell.py
@@ -142,7 +142,7 @@ def _call_wrapper(command, **kwargs):
except ExecuteTimeoutException as ex:
if on_timeout:
Logger.info("Executing '%s'. Reason: %s" % (on_timeout, str(ex)))
- checked_call(on_timeout)
+ result = checked_call(on_timeout)
else:
raise
except Fail as ex:
@@ -212,9 +212,9 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE
preexec_fn=preexec_fn)
if timeout:
- timeout_event = threading.Event()
- t = threading.Timer( timeout, _on_timeout, [proc, timeout_event] )
- t.start()
+ timeout_happened=False
+ start = time.time()
+ end = start+timeout
if not wait_for_finish:
return proc
@@ -235,6 +235,10 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE
all_output = ""
while read_set:
+ if timeout and time.time()> end:
+ timeout_happened=True
+ proc.kill()
+ break
ready, _, _ = select.select(read_set, [], [])
for out_fd in read_set:
if out_fd in ready:
@@ -258,7 +262,14 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE
if logoutput:
_print(line)
- proc.wait()
+ # Wait for process to terminate
+ while proc.poll() == None:
+ if timeout and time.time()> end:
+ timeout_happened=True
+ proc.kill()
+ break
+ time.sleep(1)
+
finally:
for fp in files_to_close:
fp.close()
@@ -268,10 +279,7 @@ def _call(command, logoutput=None, throw_on_failure=True, stdout=subprocess.PIPE
all_output = all_output.strip('\n')
if timeout:
- if not timeout_event.is_set():
- t.cancel()
- # timeout occurred
- else:
+ if timeout_happened:
err_msg = ("Execution of '%s' was killed due timeout after %d seconds") % (command, timeout)
raise ExecuteTimeoutException(err_msg)
@@ -350,14 +358,6 @@ def string_cmd_from_args_list(command, auto_escape=True):
escape_func = lambda x:quote_bash_args(x) if auto_escape else lambda x:x
return ' '.join(escape_func(x) for x in command)
-def _on_timeout(proc, timeout_event):
- timeout_event.set()
- if proc.poll() == None:
- try:
- proc.terminate()
- except:
- pass
-
def _print(line):
sys.stdout.write(line)
sys.stdout.flush()
\ No newline at end of file