Make sharding methods with only one job
Change-Id: Id1e9a9ee316517923907bf0593e851448528c75c
This commit is contained in:
parent
370ac4cd70
commit
f56071e573
@ -1996,26 +1996,36 @@ class ContainerBroker(DatabaseBroker):
|
||||
self.update_metadata({'X-Container-Sysmeta-Shard-' + key:
|
||||
(value, Timestamp.now().internal)})
|
||||
|
||||
def get_sharding_sysmeta(self, key=None, include_timestamps=False):
|
||||
def get_sharding_sysmeta_with_timestamps(self):
|
||||
"""
|
||||
Returns sharding specific info from the broker's metadata with
|
||||
timestamps.
|
||||
|
||||
:param key: if given the value stored under ``key`` in the sharding
|
||||
info will be returned.
|
||||
:return: a dict of sharding info with their timestamps.
|
||||
"""
|
||||
prefix = 'X-Container-Sysmeta-Shard-'
|
||||
return {
|
||||
k[len(prefix):]: v
|
||||
for k, v in self.metadata.items()
|
||||
if k.startswith(prefix)
|
||||
}
|
||||
|
||||
def get_sharding_sysmeta(self, key=None):
|
||||
"""
|
||||
Returns sharding specific info from the broker's metadata.
|
||||
|
||||
:param key: if given the value stored under ``key`` in the sharding
|
||||
info will be returned.
|
||||
:param include_timestamps: bool, return the metadata timestamps
|
||||
along with the metadata. I.e last modified timestamp.
|
||||
:return: either a dict of sharding info or the value stored under
|
||||
``key`` in that dict.
|
||||
"""
|
||||
prefix = 'X-Container-Sysmeta-Shard-'
|
||||
metadata = self.metadata
|
||||
info = dict((k[len(prefix):], v if include_timestamps else v[0])
|
||||
for k, v in metadata.items() if k.startswith(prefix))
|
||||
info = self.get_sharding_sysmeta_with_timestamps()
|
||||
if key:
|
||||
if include_timestamps:
|
||||
return info.get(key, (None, None))
|
||||
return info.get(key)
|
||||
return info
|
||||
return info.get(key, (None, None))[0]
|
||||
else:
|
||||
return {k: v[0] for k, v in info.items()}
|
||||
|
||||
def _load_root_info(self):
|
||||
"""
|
||||
|
@ -250,7 +250,7 @@ class CleavingContext(object):
|
||||
:return: list of tuples of (CleavingContext, timestamp)
|
||||
"""
|
||||
brokers = broker.get_brokers()
|
||||
sysmeta = brokers[-1].get_sharding_sysmeta(include_timestamps=True)
|
||||
sysmeta = brokers[-1].get_sharding_sysmeta_with_timestamps()
|
||||
|
||||
for key, (val, timestamp) in sysmeta.items():
|
||||
# If the value is of length 0, then the metadata is
|
||||
|
Loading…
Reference in New Issue
Block a user