diff options
author | Lingxian Kong <anlin.kong@gmail.com> | 2020-04-04 00:24:37 +1300 |
---|---|---|
committer | Lingxian Kong <anlin.kong@gmail.com> | 2020-04-04 15:11:33 +1300 |
commit | f31867330499ab517f16fcfdbd03da7a3238deff (patch) | |
tree | 179742d616597f54152a4720914beb63b0a2bc81 | |
parent | 9d8fb455d5d7111424091800ebfb6147cfde2871 (diff) | |
download | trove-f31867330499ab517f16fcfdbd03da7a3238deff.tar.gz |
Change @property usage to function
osprofiler is walking through all the properties of a class when the
service is starting. Removing @property to avoid unneccesary code logic
running during service initialization.
Change-Id: I53635e167808de18093a15c871b6de7d94afc8d0
6 files changed, 14 insertions, 21 deletions
diff --git a/trove/guestagent/datastore/experimental/cassandra/manager.py b/trove/guestagent/datastore/experimental/cassandra/manager.py index 40a6498f..504d9b3f 100644 --- a/trove/guestagent/datastore/experimental/cassandra/manager.py +++ b/trove/guestagent/datastore/experimental/cassandra/manager.py @@ -65,8 +65,7 @@ class Manager(manager.Manager): def configuration_manager(self): return self.app.configuration_manager - @property - def datastore_log_defs(self): + def get_datastore_log_defs(self): system_log_file = self.validate_log_file( self.app.cassandra_system_log_file, self.app.cassandra_owner) return { diff --git a/trove/guestagent/datastore/experimental/postgresql/manager.py b/trove/guestagent/datastore/experimental/postgresql/manager.py index 56f8ef73..6d4d7909 100644 --- a/trove/guestagent/datastore/experimental/postgresql/manager.py +++ b/trove/guestagent/datastore/experimental/postgresql/manager.py @@ -68,8 +68,7 @@ class Manager(manager.Manager): def configuration_manager(self): return self.app.configuration_manager - @property - def datastore_log_defs(self): + def get_datastore_log_defs(self): owner = self.app.pgsql_owner long_query_time = CONF.get(self.manager).get( 'guest_log_long_query_time') diff --git a/trove/guestagent/datastore/experimental/redis/manager.py b/trove/guestagent/datastore/experimental/redis/manager.py index 73f28efb..68a7d79c 100644 --- a/trove/guestagent/datastore/experimental/redis/manager.py +++ b/trove/guestagent/datastore/experimental/redis/manager.py @@ -53,8 +53,7 @@ class Manager(manager.Manager): def configuration_manager(self): return self._app.configuration_manager - @property - def datastore_log_defs(self): + def get_datastore_log_defs(self): logfile = self._app.get_logfile() if not logfile: return {} diff --git a/trove/guestagent/datastore/manager.py b/trove/guestagent/datastore/manager.py index 38d853bf..9ec80648 100644 --- a/trove/guestagent/datastore/manager.py +++ b/trove/guestagent/datastore/manager.py @@ -142,8 +142,7 @@ class Manager(periodic_task.PeriodicTasks): """ return None - @property - def datastore_log_defs(self): + def get_datastore_log_defs(self): """Any datastore-specific log files should be overridden in this dict by the corresponding Manager class. @@ -182,11 +181,10 @@ class Manager(periodic_task.PeriodicTasks): }, } - @property - def guest_log_defs(self): + def get_guest_log_defs(self): """Return all the guest log defs.""" if not self._guest_log_defs: - self._guest_log_defs = dict(self.datastore_log_defs) + self._guest_log_defs = dict(self.get_datastore_log_defs()) self._guest_log_defs.update(self.guestagent_log_defs) return self._guest_log_defs @@ -198,8 +196,7 @@ class Manager(periodic_task.PeriodicTasks): def guest_log_context(self, context): self._guest_log_context = context - @property - def guest_log_cache(self): + def get_guest_log_cache(self): """Make sure the guest_log_cache is loaded and return it.""" self._refresh_guest_log_cache() return self._guest_log_cache @@ -215,7 +212,7 @@ class Manager(periodic_task.PeriodicTasks): # Load the initial cache self._guest_log_cache = {} if self.guest_log_context: - gl_defs = self.guest_log_defs + gl_defs = self.get_guest_log_defs() try: exposed_logs = CONF.get(self.manager).get( 'guest_log_exposed_logs') @@ -496,7 +493,7 @@ class Manager(periodic_task.PeriodicTasks): def guest_log_list(self, context): LOG.info("Getting list of guest logs.") self.guest_log_context = context - gl_cache = self.guest_log_cache + gl_cache = self.get_guest_log_cache() result = filter(None, [gl_cache[log_name].show() if gl_cache[log_name].exposed else None for log_name in gl_cache.keys()]) @@ -517,7 +514,7 @@ class Manager(periodic_task.PeriodicTasks): {'log': log_name, 'en': enable, 'dis': disable, 'pub': publish, 'disc': discard}) self.guest_log_context = context - gl_cache = self.guest_log_cache + gl_cache = self.get_guest_log_cache() if log_name in gl_cache: if ((gl_cache[log_name].type == guest_log.LogType.SYS) and not publish): @@ -563,7 +560,7 @@ class Manager(periodic_task.PeriodicTasks): if self.configuration_manager: LOG.debug("%(verb)s log '%(log)s'", {'verb': verb, 'log': log_name}) - gl_def = self.guest_log_defs[log_name] + gl_def = self.get_guest_log_defs()[log_name] enable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_ENABLE_LABEL, log_name) disable_cfg_label = "%s_%s_log" % (self.GUEST_LOG_DISABLE_LABEL, @@ -614,7 +611,7 @@ class Manager(periodic_task.PeriodicTasks): """Sets the status of log_name to 'status' - if log_name is not provided, sets the status on all logs. """ - gl_cache = self.guest_log_cache + gl_cache = self.get_guest_log_cache() names = [log_name] if not log_name or log_name not in gl_cache: names = gl_cache.keys() diff --git a/trove/guestagent/datastore/mysql_common/manager.py b/trove/guestagent/datastore/mysql_common/manager.py index 6d61c5dd..3ffc4940 100644 --- a/trove/guestagent/datastore/mysql_common/manager.py +++ b/trove/guestagent/datastore/mysql_common/manager.py @@ -70,8 +70,7 @@ class MySqlManager(manager.Manager): return self.mysql_app( self.mysql_app_status.get()).configuration_manager - @property - def datastore_log_defs(self): + def get_datastore_log_defs(self): owner = 'mysql' datastore_dir = self.mysql_app.get_data_dir() server_section = configurations.MySQLConfParser.SERVER_CONF_SECTION diff --git a/trove/tests/unittests/guestagent/test_manager.py b/trove/tests/unittests/guestagent/test_manager.py index 462b87ff..d34edb6b 100644 --- a/trove/tests/unittests/guestagent/test_manager.py +++ b/trove/tests/unittests/guestagent/test_manager.py @@ -259,7 +259,7 @@ class ManagerTest(trove_testtools.TestCase): def assert_guest_log_status(self, original_status, new_status, expected_final_status): - gl_cache = self.manager.guest_log_cache + gl_cache = self.manager.get_guest_log_cache() gl_cache[self.log_name_sys]._status = original_status self.manager.set_guest_log_status(new_status, self.log_name_sys) assert_equal(gl_cache[self.log_name_sys].status, expected_final_status, |