Remove unnecessary publish logs in PCA. Add a generic log message when publishing events
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/bf6f1051 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/bf6f1051 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/bf6f1051 Branch: refs/heads/stratos-4.1.x Commit: bf6f1051f5a4a522f8406e43aebb36a87a93835e Parents: 885bf56 Author: Akila Perera <[email protected]> Authored: Sat Nov 21 12:02:37 2015 +0530 Committer: Akila Perera <[email protected]> Committed: Sat Nov 21 12:31:32 2015 +0530 ---------------------------------------------------------------------- .../cartridge.agent/modules/event/eventhandler.py | 18 +++++++----------- .../cartridge.agent/cartridge.agent/publisher.py | 17 ++++++----------- 2 files changed, 13 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/bf6f1051/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py index 1dfe834..85624ae 100644 --- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py +++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/modules/event/eventhandler.py @@ -18,14 +18,15 @@ import json from threading import Thread -from ..util import cartridgeagentutils -from ..artifactmgt.git.agentgithandler import * -from ..artifactmgt.repository import Repository -from config import Config import publisher from entity import * -from ..util.log import LogFactory + import constants +from config import Config +from ..artifactmgt.git.agentgithandler import * +from ..artifactmgt.repository import Repository +from ..util import cartridgeagentutils +from ..util.log import LogFactory SUPER_TENANT_ID = "-1234" SUPER_TENANT_REPO_PATH = "/repository/deployment/server/" @@ -368,14 +369,9 @@ class EventHandler: self.execute_event_extendables(constants.APPLICATION_SIGNUP_REMOVAL_EVENT, {}) def cleanup(self, event): - self.__log.debug("Executing cleanup extension for event %s" % event) - + self.__log.debug("Executing cleanup extension for event %s..." % event) publisher.publish_maintenance_mode_event() - self.execute_event_extendables("clean", {}) - self.__log.info("Cleaning up finished in the cartridge instance...") - - self.__log.info("Publishing ready to shutdown event...") publisher.publish_instance_ready_to_shutdown_event() def execute_event_extendables(self, event, input_values): http://git-wip-us.apache.org/repos/asf/stratos/blob/bf6f1051/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py index dcafe47..a24650a 100644 --- a/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py +++ b/components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent/publisher.py @@ -16,6 +16,7 @@ # under the License. import threading + import paho.mqtt.publish as publish import time @@ -58,7 +59,6 @@ def publish_instance_started_event(): publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC + constants.INSTANCE_STARTED_EVENT) publisher.publish(instance_started_event) Config.started = True - log.info("Instance started event published") else: log.warn("Instance already started") @@ -95,9 +95,7 @@ def publish_instance_activated_event(): publisher = get_publisher(constants.INSTANCE_STATUS_TOPIC + constants.INSTANCE_ACTIVATED_EVENT) publisher.publish(instance_activated_event) - log.info("Instance activated event published") log.info("Starting health statistics notifier") - health_stat_publishing_enabled = Config.read_property(constants.CEP_PUBLISHER_ENABLED, True) if health_stat_publishing_enabled: @@ -151,14 +149,13 @@ def publish_maintenance_mode_event(): publisher.publish(instance_maintenance_mode_event) Config.maintenance = True - log.info("Instance maintenance mode event published") else: log.warn("Instance already in a maintenance mode") def publish_instance_ready_to_shutdown_event(): if not Config.ready_to_shutdown: - log.info("Publishing instance activated event...") + log.info("Publishing instance ready to shutdown event...") service_name = Config.service_name cluster_id = Config.cluster_id @@ -181,7 +178,6 @@ def publish_instance_ready_to_shutdown_event(): publisher.publish(instance_shutdown_event) Config.ready_to_shutdown = True - log.info("Instance ReadyToShutDown event published") else: log.warn("Instance already in a ReadyToShutDown event...") @@ -190,14 +186,12 @@ def publish_complete_topology_request_event(): complete_topology_request_event = CompleteTopologyRequestEvent() publisher = get_publisher(constants.INITIALIZER_TOPIC + constants.COMPLETE_TOPOLOGY_REQUEST_EVENT) publisher.publish(complete_topology_request_event) - log.info("Complete topology request event published") def publish_complete_tenant_request_event(): complete_tenant_request_event = CompleteTenantRequestEvent() publisher = get_publisher(constants.INITIALIZER_TOPIC + constants.COMPLETE_TENANT_REQUEST_EVENT) publisher.publish(complete_tenant_request_event) - log.info("Complete tenant request event published") def get_publisher(topic): @@ -252,10 +246,11 @@ class EventPublisher: try: publish.single(self.__topic, payload, hostname=mb_ip, port=mb_port, auth=auth) - self.__log.debug("Event published to %s:%s" % (mb_ip, mb_port)) + self.__log.debug("Event type: %s published to MB: %s:%s" % (str(event.__class__), mb_ip, mb_port)) return True except: - self.__log.debug("Could not publish event to message broker %s:%s." % (mb_ip, mb_port)) + self.__log.debug( + "Could not publish event to message broker %s:%s." % (mb_ip, mb_port)) self.__log.debug( "Could not publish event to any of the provided message brokers. Retrying in %s seconds." @@ -263,6 +258,6 @@ class EventPublisher: time.sleep(retry_interval) - self.__log.warn("Could not publish even to any of the provided message brokers before " + self.__log.warn("Could not publish event to any of the provided message brokers before " "the timeout [%s] exceeded. The event will be dropped." % Config.mb_publisher_timeout) return False
