use message id to generate hbase unique key
We currently can disable computing signature for metering message, but HBase still uses signature as a dimension to generate unique row key, this will lead to different samples treated as same one. Message id should be used in stead of message signature, because id will always exist and also unique. Change-Id: I47cdce59c9934573076cf609ce1a0c37aea75c44 Closes-Bug: #1445227
This commit is contained in:
parent
c9a42be186
commit
15a92ec1ef
@ -55,7 +55,7 @@ class Connection(hbase_base.Connection, base.Connection):
|
|||||||
|
|
||||||
- meter (describes sample actually):
|
- meter (describes sample actually):
|
||||||
|
|
||||||
- row-key: consists of reversed timestamp, meter and a message signature
|
- row-key: consists of reversed timestamp, meter and a message uuid
|
||||||
for purposes of uniqueness
|
for purposes of uniqueness
|
||||||
- Column Families:
|
- Column Families:
|
||||||
|
|
||||||
@ -175,9 +175,9 @@ class Connection(hbase_base.Connection, base.Connection):
|
|||||||
resource, ts)
|
resource, ts)
|
||||||
|
|
||||||
# Rowkey consists of reversed timestamp, meter and a
|
# Rowkey consists of reversed timestamp, meter and a
|
||||||
# message signature for purposes of uniqueness
|
# message uuid for purposes of uniqueness
|
||||||
row = hbase_utils.prepare_key(data['counter_name'], rts,
|
row = hbase_utils.prepare_key(data['counter_name'], rts,
|
||||||
data['message_signature'])
|
data['message_id'])
|
||||||
record = hbase_utils.serialize_entry(
|
record = hbase_utils.serialize_entry(
|
||||||
data, **{'source': data['source'], 'rts': rts,
|
data, **{'source': data['source'], 'rts': rts,
|
||||||
'message': data, 'recorded_at': timeutils.utcnow()})
|
'message': data, 'recorded_at': timeutils.utcnow()})
|
||||||
|
@ -553,9 +553,8 @@ class RawSampleTest(DBTestBase,
|
|||||||
def test_get_samples_by_resource(self):
|
def test_get_samples_by_resource(self):
|
||||||
f = storage.SampleFilter(user='user-id', resource='resource-id')
|
f = storage.SampleFilter(user='user-id', resource='resource-id')
|
||||||
results = list(self.conn.get_samples(f))
|
results = list(self.conn.get_samples(f))
|
||||||
self.assertIsNotEmpty(results)
|
self.assertEqual(2, len(results))
|
||||||
meter = results[1]
|
d = results[1].as_dict()
|
||||||
d = meter.as_dict()
|
|
||||||
self.assertEqual(timeutils.utcnow(), d['recorded_at'])
|
self.assertEqual(timeutils.utcnow(), d['recorded_at'])
|
||||||
del d['recorded_at']
|
del d['recorded_at']
|
||||||
self.assertEqual(self.msgs[0], d)
|
self.assertEqual(self.msgs[0], d)
|
||||||
|
Loading…
Reference in New Issue
Block a user