You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2017/12/20 13:17:12 UTC
ambari git commit: AMBARI-22677. Don't call pprint.pformat
unnecessarily in Ambari agent (amagyar)
Repository: ambari
Updated Branches:
refs/heads/trunk f3dc1ca39 -> 4e731d31f
AMBARI-22677. Don't call pprint.pformat unnecessarily in Ambari agent (amagyar)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/4e731d31
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/4e731d31
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/4e731d31
Branch: refs/heads/trunk
Commit: 4e731d31f7c59bceab3c91565686384645251546
Parents: f3dc1ca
Author: Attila Magyar <am...@hortonworks.com>
Authored: Wed Dec 20 14:16:36 2017 +0100
Committer: Attila Magyar <am...@hortonworks.com>
Committed: Wed Dec 20 14:16:36 2017 +0100
----------------------------------------------------------------------
.../src/main/python/ambari_agent/ActionQueue.py | 21 ++++++++++----------
.../python/ambari_agent/CommandStatusDict.py | 2 +-
.../src/main/python/ambari_agent/Controller.py | 17 ++++++++--------
.../ambari_agent/CustomServiceOrchestrator.py | 4 ++--
.../src/main/python/ambari_agent/DataCleaner.py | 4 ++--
.../src/main/python/ambari_agent/Heartbeat.py | 17 ++++++++--------
.../src/main/python/ambari_agent/LiveStatus.py | 3 +--
.../main/python/ambari_agent/PythonExecutor.py | 15 +++++++-------
.../ambari_agent/PythonReflectiveExecutor.py | 3 ++-
.../main/python/ambari_agent/RecoveryManager.py | 17 ++++++++--------
.../ambari_agent/StatusCommandsExecutor.py | 3 ++-
.../python/ambari_agent/alerts/ams_alert.py | 8 +++++---
.../python/ambari_agent/alerts/metric_alert.py | 3 ++-
.../src/main/python/ambari_agent/security.py | 8 ++++----
14 files changed, 66 insertions(+), 59 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index f1b3a42..da4dc4c 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -121,7 +121,8 @@ class ActionQueue(threading.Thread):
for command in commands:
logger.info("Canceling command with taskId = {tid}".format(tid = str(command['target_task_id'])))
- logger.debug(pprint.pformat(command))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug(pprint.pformat(command))
task_id = command['target_task_id']
reason = command['reason']
@@ -200,7 +201,7 @@ class ActionQueue(threading.Thread):
def process_command(self, command):
# make sure we log failures
commandType = command['commandType']
- logger.debug("Took an element of Queue (command type = %s)." % commandType)
+ logger.debug("Took an element of Queue (command type = %s).", commandType)
try:
if commandType in [self.EXECUTION_COMMAND, self.BACKGROUND_EXECUTION_COMMAND, self.AUTO_EXECUTION_COMMAND]:
try:
@@ -211,7 +212,7 @@ class ActionQueue(threading.Thread):
if self.controller.recovery_manager.enabled():
self.controller.recovery_manager.stop_execution_command()
else:
- logger.error("Unrecognized command " + pprint.pformat(command))
+ logger.error("Unrecognized command %s", pprint.pformat(command))
except Exception:
logger.exception("Exception while processing {0} command".format(commandType))
@@ -475,14 +476,14 @@ class ActionQueue(threading.Thread):
self.customServiceOrchestrator
def on_background_command_complete_callback(self, process_condensed_result, handle):
- logger.debug('Start callback: %s' % process_condensed_result)
- logger.debug('The handle is: %s' % handle)
+ logger.debug('Start callback: %s', process_condensed_result)
+ logger.debug('The handle is: %s', handle)
status = self.COMPLETED_STATUS if handle.exitCode == 0 else self.FAILED_STATUS
aborted_postfix = self.customServiceOrchestrator.command_canceled_reason(handle.command['taskId'])
if aborted_postfix:
status = self.FAILED_STATUS
- logger.debug('Set status to: %s , reason = %s' % (status, aborted_postfix))
+ logger.debug('Set status to: %s , reason = %s', status, aborted_postfix)
else:
aborted_postfix = ''
@@ -556,11 +557,9 @@ class ActionQueue(threading.Thread):
result['extra'] = component_extra
- logger.debug("Got live status for component " + component + \
- " of service " + str(service) + \
- " of cluster " + str(cluster))
-
- logger.debug(pprint.pformat(result))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Got live status for component %s of service %s of cluster %s", component, service, cluster)
+ logger.debug(pprint.pformat(result))
if result is not None:
self.commandStatuses.put_command_status(command, result)
except Exception, err:
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py b/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
index 7a97f3f..8ff5818 100644
--- a/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
+++ b/ambari-agent/src/main/python/ambari_agent/CommandStatusDict.py
@@ -105,7 +105,7 @@ class CommandStatusDict():
# Component status is useful once, removing it
del self.current_state[key]
elif command ['commandType'] in [ActionQueue.AUTO_EXECUTION_COMMAND]:
- logger.debug("AUTO_EXECUTION_COMMAND task deleted " + str(command['commandId']))
+ logger.debug("AUTO_EXECUTION_COMMAND task deleted %s", command['commandId'])
del self.current_state[key]
pass
result = {
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/Controller.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Controller.py b/ambari-agent/src/main/python/ambari_agent/Controller.py
index bc923c3..ef50440 100644
--- a/ambari-agent/src/main/python/ambari_agent/Controller.py
+++ b/ambari-agent/src/main/python/ambari_agent/Controller.py
@@ -174,8 +174,9 @@ class Controller(threading.Thread):
self.hostname, prettyData)
ret = self.sendRequest(self.registerUrl, data)
- prettyData = pprint.pformat(ret)
- logger.debug("Registration response is %s", prettyData)
+
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Registration response is %s", pprint.pformat(ret))
# exitstatus is a code of error which was raised on server side.
# exitstatus = 0 (OK - Default)
@@ -203,7 +204,7 @@ class Controller(threading.Thread):
self.cluster_configuration.update_configurations_from_heartbeat(ret)
self.recovery_manager.update_configuration_from_registration(ret)
self.config.update_configuration_from_registration(ret)
- logger.debug("Updated config:" + str(self.config))
+ logger.debug("Updated config: %s", self.config)
# Start StatusCommandExecutor child process or restart it if already running
# in order to receive up to date agent config.
@@ -557,11 +558,11 @@ class Controller(threading.Thread):
if LiveStatus.SERVICES:
return
- logger.debug("Updating components map of cluster " + cluster_name)
+ logger.debug("Updating components map of cluster %s", cluster_name)
# May throw IOError on server connection error
response = self.sendRequest(self.componentsUrl + cluster_name, None)
- logger.debug("Response from %s was %s", self.serverHostname, str(response))
+ logger.debug("Response from %s was %s", self.serverHostname, response)
services, client_components, server_components = [], [], []
for service, components in response['components'].items():
@@ -578,9 +579,9 @@ class Controller(threading.Thread):
LiveStatus.COMPONENTS = server_components
logger.debug("Components map updated")
- logger.debug("LiveStatus.SERVICES" + str(LiveStatus.SERVICES))
- logger.debug("LiveStatus.CLIENT_COMPONENTS" + str(LiveStatus.CLIENT_COMPONENTS))
- logger.debug("LiveStatus.COMPONENTS" + str(LiveStatus.COMPONENTS))
+ logger.debug("LiveStatus.SERVICES %s", LiveStatus.SERVICES)
+ logger.debug("LiveStatus.CLIENT_COMPONENTS %s", LiveStatus.CLIENT_COMPONENTS)
+ logger.debug("LiveStatus.COMPONENTS %s", LiveStatus.COMPONENTS)
def get_status_commands_executor(self):
return self.statusCommandsExecutor
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
index 645f824..f92ef1d 100644
--- a/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
+++ b/ambari-agent/src/main/python/ambari_agent/CustomServiceOrchestrator.py
@@ -112,7 +112,7 @@ class CustomServiceOrchestrator():
def map_task_to_process(self, task_id, processId):
with self.commands_in_progress_lock:
- logger.debug('Maps taskId=%s to pid=%s' % (task_id, processId))
+ logger.debug('Maps taskId=%s to pid=%s', task_id, processId)
self.commands_in_progress[task_id] = processId
def cancel_command(self, task_id, reason):
@@ -446,7 +446,7 @@ class CustomServiceOrchestrator():
def command_canceled_reason(self, task_id):
with self.commands_in_progress_lock:
if self.commands_in_progress.has_key(task_id):#Background command do not push in this collection (TODO)
- logger.debug('Pop with taskId %s' % task_id)
+ logger.debug('Pop with taskId %s', task_id)
pid = self.commands_in_progress.pop(task_id)
if not isinstance(pid, int):
reason = pid
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/DataCleaner.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/DataCleaner.py b/ambari-agent/src/main/python/ambari_agent/DataCleaner.py
index 0b66fa7..9c3b2e1 100644
--- a/ambari-agent/src/main/python/ambari_agent/DataCleaner.py
+++ b/ambari-agent/src/main/python/ambari_agent/DataCleaner.py
@@ -68,7 +68,7 @@ class DataCleaner(threading.Thread):
logger.info('Data cleanup thread killed.')
def cleanup(self):
- logger.debug("Cleaning up inside directory " + self.data_dir)
+ logger.debug("Cleaning up inside directory %s", self.data_dir)
now = time.time()
total_size_bytes = 0
file_path_to_timestamp = {}
@@ -82,7 +82,7 @@ class DataCleaner(threading.Thread):
file_age = now - os.path.getmtime(file_path)
if file_age > self.file_max_age:
os.remove(os.path.join(file_path))
- logger.debug('Removed file: ' + file_path)
+ logger.debug('Removed file: %s', file_path)
else:
# Since file wasn't deleted in first pass, consider it for the second one with oldest files first
file_size = os.path.getsize(file_path)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/Heartbeat.py b/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
index d7c0325..11ad652 100644
--- a/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
+++ b/ambari-agent/src/main/python/ambari_agent/Heartbeat.py
@@ -75,12 +75,12 @@ class Heartbeat:
if int(id) == 0:
componentsMapped = False
- logger.debug("Building Heartbeat: {responseId = %s, timestamp = %s, "
- "commandsInProgress = %s, componentsMapped = %s,"
- "recoveryTimestamp = %s}",
- str(id), str(timestamp), repr(commandsInProgress), repr(componentsMapped), str(recovery_timestamp))
-
- logger.debug("Heartbeat: %s", pformat(heartbeat))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Building Heartbeat: {responseId = %s, timestamp = %s, "
+ "commandsInProgress = %s, componentsMapped = %s, "
+ "recoveryTimestamp = %s}",
+ id, timestamp, commandsInProgress, componentsMapped, recovery_timestamp)
+ logger.debug("Heartbeat: %s", pformat(heartbeat))
hostInfo = HostInfo(self.config)
if add_state:
@@ -93,8 +93,9 @@ class Heartbeat:
mounts = Hardware(config=self.config, cache_info=False).osdisks()
heartbeat['mounts'] = mounts
- logger.debug("agentEnv: %s", str(nodeInfo))
- logger.debug("mounts: %s", str(mounts))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("agentEnv: %s", nodeInfo)
+ logger.debug("mounts: %s", mounts)
if self.collector is not None:
heartbeat['alerts'] = self.collector.alerts()
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/LiveStatus.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/LiveStatus.py b/ambari-agent/src/main/python/ambari_agent/LiveStatus.py
index b6d54ed..a506e28 100644
--- a/ambari-agent/src/main/python/ambari_agent/LiveStatus.py
+++ b/ambari-agent/src/main/python/ambari_agent/LiveStatus.py
@@ -62,6 +62,5 @@ class LiveStatus:
if active_config is not None:
livestatus['configurationTags'] = active_config
- logger.debug("The live status for component " + str(self.component) +
- " of service " + str(self.service) + " is " + str(livestatus))
+ logger.debug("The live status for component %s of service %s is %s", self.component, self.service, livestatus)
return livestatus
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py b/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
index ea6f895..139c141 100644
--- a/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PythonExecutor.py
@@ -93,7 +93,8 @@ class PythonExecutor(object):
The structured out file, however, is preserved during multiple invocations that use the same file.
"""
pythonCommand = self.python_command(script, script_params)
- logger.debug("Running command " + pprint.pformat(pythonCommand))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Running command %s", pprint.pformat(pythonCommand))
if handle is None:
tmpout, tmperr = self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files, backup_log_files)
@@ -127,7 +128,7 @@ class PythonExecutor(object):
"""
Log some useful information after task failure.
"""
- logger.info("Command " + pprint.pformat(pythonCommand) + " failed with exitcode=" + str(result['exitcode']))
+ logger.info("Command %s failed with exitcode=%s", pprint.pformat(pythonCommand), result['exitcode'])
log_process_information(logger)
def prepare_process_result(self, returncode, tmpoutfile, tmperrfile, tmpstructedoutfile, timeout=None):
@@ -138,7 +139,7 @@ class PythonExecutor(object):
(" after waiting %s secs" % str(timeout) if timeout else "")
returncode = 999
result = self.condenseOutput(out, error, returncode, structured_out)
- logger.debug("Result: %s" % result)
+ logger.debug("Result: %s", result)
return result
def read_result_from_files(self, out_path, err_path, structured_out_path):
@@ -223,10 +224,10 @@ class BackgroundThread(threading.Thread):
def run(self):
process_out, process_err = self.pythonExecutor.open_subprocess_files(self.holder.out_file, self.holder.err_file, True)
- logger.debug("Starting process command %s" % self.holder.command)
+ logger.debug("Starting process command %s", self.holder.command)
process = self.pythonExecutor.launch_python_subprocess(self.holder.command, process_out, process_err)
- logger.debug("Process has been started. Pid = %s" % process.pid)
+ logger.debug("Process has been started. Pid = %s", process.pid)
self.holder.handle.pid = process.pid
self.holder.handle.status = BackgroundCommandExecutionHandle.RUNNING_STATUS
@@ -236,6 +237,6 @@ class BackgroundThread(threading.Thread):
self.holder.handle.exitCode = process.returncode
process_condensed_result = self.pythonExecutor.prepare_process_result(process.returncode, self.holder.out_file, self.holder.err_file, self.holder.structured_out_file)
- logger.debug("Calling callback with args %s" % process_condensed_result)
+ logger.debug("Calling callback with args %s", process_condensed_result)
self.holder.handle.on_background_command_complete_callback(process_condensed_result, self.holder.handle)
- logger.debug("Exiting from thread for holder pid %s" % self.holder.handle.pid)
+ logger.debug("Exiting from thread for holder pid %s", self.holder.handle.pid)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py b/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
index b27d7d1..b021320 100644
--- a/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PythonReflectiveExecutor.py
@@ -46,7 +46,8 @@ class PythonReflectiveExecutor(PythonExecutor):
override_output_files = True, backup_log_files = True,
handle = None, log_info_on_failure=True):
pythonCommand = self.python_command(script, script_params)
- logger.debug("Running command reflectively " + pprint.pformat(pythonCommand))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Running command reflectively %s", pprint.pformat(pythonCommand))
script_dir = os.path.dirname(script)
self.open_subprocess_files(tmpoutfile, tmperrfile, override_output_files, backup_log_files)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py b/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
index be335f2..c196fd8 100644
--- a/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
+++ b/ambari-agent/src/main/python/ambari_agent/RecoveryManager.py
@@ -128,7 +128,7 @@ class RecoveryManager:
def set_paused(self, paused):
if self.paused != paused:
- logger.debug("RecoveryManager is transitioning from isPaused = " + str(self.paused) + " to " + str(paused))
+ logger.debug("RecoveryManager is transitioning from isPaused = %s to %s", self.paused, paused)
self.paused = paused
def enabled(self):
@@ -574,7 +574,8 @@ class RecoveryManager:
if reg_resp and "recoveryConfig" in reg_resp:
- logger.info("RecoverConfig = " + pprint.pformat(reg_resp["recoveryConfig"]))
+ if logger.isEnabledFor(logging.INFO):
+ logger.info("RecoverConfig = %s", pprint.pformat(reg_resp["recoveryConfig"]))
config = reg_resp["recoveryConfig"]
if "type" in config:
if config["type"] in ["AUTO_INSTALL_START", "AUTO_START", "FULL"]:
@@ -691,8 +692,8 @@ class RecoveryManager:
if commands and len(commands) > 0:
for command in commands:
self.store_or_update_command(command)
- if self.EXECUTION_COMMAND_DETAILS in command:
- logger.debug("Details to construct exec commands: " + pprint.pformat(command[self.EXECUTION_COMMAND_DETAILS]))
+ if logger.isEnabledFor(logging.DEBUG) and self.EXECUTION_COMMAND_DETAILS in command:
+ logger.debug("Details to construct exec commands: %s", pprint.pformat(command[self.EXECUTION_COMMAND_DETAILS]))
pass
@@ -748,7 +749,7 @@ class RecoveryManager:
# Store the execution command details
self.remove_command(component)
self.add_command(component, command[self.EXECUTION_COMMAND_DETAILS])
- logger.debug("Stored command details for " + component)
+ logger.debug("Stored command details for %s", component)
else:
logger.warn("Expected field " + self.EXECUTION_COMMAND_DETAILS + " unavailable.")
pass
@@ -855,7 +856,7 @@ class RecoveryManager:
insert_time = self.stored_exec_commands[component_update_key]
age = self._now_() - insert_time
if self.COMMAND_REFRESH_DELAY_SEC < age:
- logger.debug("Removing stored command for component : " + str(component) + " as its " + str(age) + " sec old")
+ logger.debug("Removing stored command for component : %s as it's %s sec old", component, age)
self.remove_command(component)
pass
@@ -867,7 +868,7 @@ class RecoveryManager:
component_update_key = self.COMPONENT_UPDATE_KEY_FORMAT.format(component)
del self.stored_exec_commands[component]
del self.stored_exec_commands[component_update_key]
- logger.debug("Removed stored command for component : " + str(component))
+ logger.debug("Removed stored command for component : %s", component)
return True
finally:
self.__status_lock.release()
@@ -880,7 +881,7 @@ class RecoveryManager:
component_update_key = self.COMPONENT_UPDATE_KEY_FORMAT.format(component)
self.stored_exec_commands[component] = command
self.stored_exec_commands[component_update_key] = self._now_()
- logger.debug("Added command for component : " + str(component))
+ logger.debug("Added command for component : %s", component)
finally:
self.__status_lock.release()
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/StatusCommandsExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/StatusCommandsExecutor.py b/ambari-agent/src/main/python/ambari_agent/StatusCommandsExecutor.py
index f42e134..ad90b83 100644
--- a/ambari-agent/src/main/python/ambari_agent/StatusCommandsExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/StatusCommandsExecutor.py
@@ -64,7 +64,8 @@ class SingleProcessStatusCommandsExecutor(StatusCommandsExecutor):
command['serviceName'] + " of cluster " + \
command['clusterName'] + " to the queue.")
self.statusCommandQueue.put(command)
- logger.debug(pprint.pformat(command))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug(pprint.pformat(command))
def process_results(self):
"""
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/alerts/ams_alert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/alerts/ams_alert.py b/ambari-agent/src/main/python/ambari_agent/alerts/ams_alert.py
index 70f100f..29b885b 100644
--- a/ambari-agent/src/main/python/ambari_agent/alerts/ams_alert.py
+++ b/ambari-agent/src/main/python/ambari_agent/alerts/ams_alert.py
@@ -64,8 +64,9 @@ class AmsAlert(MetricAlert):
# use the URI lookup keys to get a final URI value to query
alert_uri = self._get_uri_from_structure(self.uri_property_keys)
- logger.debug("[Alert][{0}] Calculated metric URI to be {1} (ssl={2})".format(
- self.get_name(), alert_uri.uri, str(alert_uri.is_ssl_enabled)))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("[Alert][{0}] Calculated metric URI to be {1} (ssl={2})".format(
+ self.get_name(), alert_uri.uri, str(alert_uri.is_ssl_enabled)))
host = BaseAlert.get_host_from_url(alert_uri.uri)
if host is None:
@@ -94,7 +95,8 @@ class AmsAlert(MetricAlert):
collect_result = self._get_result(value_list[0] if compute_result is None else compute_result)
- logger.debug("[Alert][{0}] Computed result = {1}".format(self.get_name(), str(value_list)))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("[Alert][{0}] Computed result = {1}".format(self.get_name(), str(value_list)))
return (collect_result, value_list)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py b/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
index 803bdc6..66a1d05 100644
--- a/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
+++ b/ambari-agent/src/main/python/ambari_agent/alerts/metric_alert.py
@@ -107,7 +107,8 @@ class MetricAlert(BaseAlert):
collect_result = self._get_result(value_list[0] if check_value is None else check_value)
- logger.debug("[Alert][{0}] Resolved values = {1}".format(self.get_name(), str(value_list)))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("[Alert][{0}] Resolved values = {1}".format(self.get_name(), str(value_list)))
return (collect_result, value_list)
http://git-wip-us.apache.org/repos/asf/ambari/blob/4e731d31/ambari-agent/src/main/python/ambari_agent/security.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/security.py b/ambari-agent/src/main/python/ambari_agent/security.py
index 45de7bb..d752ee6 100644
--- a/ambari-agent/src/main/python/ambari_agent/security.py
+++ b/ambari-agent/src/main/python/ambari_agent/security.py
@@ -48,8 +48,7 @@ class VerifiedHTTPSConnection(httplib.HTTPSConnection):
def connect(self):
self.two_way_ssl_required = self.config.isTwoWaySSLConnection(self.host)
- logger.debug("Server two-way SSL authentication required: %s" % str(
- self.two_way_ssl_required))
+ logger.debug("Server two-way SSL authentication required: %s", self.two_way_ssl_required)
if self.two_way_ssl_required is True:
logger.info(
'Server require two-way SSL authentication. Use it instead of one-way...')
@@ -230,9 +229,10 @@ class CertificateManager():
f.close()
try:
data = json.loads(response)
- logger.debug("Sign response from Server: \n" + pprint.pformat(data))
+ if logger.isEnabledFor(logging.DEBUG):
+ logger.debug("Sign response from Server: \n" + pprint.pformat(data))
except Exception:
- logger.warn("Malformed response! data: " + str(data))
+ logger.warn("Malformed response! data: %s", data)
data = {'result': 'ERROR'}
result = data['result']
if result == 'OK':