Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge "ceph: fix write emulation"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Aug 21, 2016
2 parents 9c0a918 + fc38382 commit 7a40269
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions gnocchi/carbonara.py
Expand Up @@ -415,12 +415,6 @@ def offset_from_split(self):
return int((self.first.value - split) // (self.sampling * 10e8)
* self.SERIAL_LEN)

@staticmethod
def padding(offset):
offset = offset // AggregatedTimeSerie.SERIAL_LEN
pad = [False] * offset * 2
return struct.pack('<' + '?d' * offset, *pad)

def _truncate(self, quick=False):
"""Truncate the timeserie."""
if self.max_size is not None:
Expand Down
7 changes: 1 addition & 6 deletions gnocchi/storage/ceph.py
Expand Up @@ -257,12 +257,7 @@ def _store_metric_measures(self, metric, timestamp_key, aggregation,
granularity, data, offset=0, version=3):
name = self._get_object_name(metric, timestamp_key,
aggregation, granularity, version)
try:
self.ioctx.write(name, data, offset=offset)
except rados.ObjectNotFound:
# first time writing data
self.ioctx.write_full(
name, carbonara.AggregatedTimeSerie.padding(offset) + data)
self.ioctx.write(name, data, offset=offset)
self.ioctx.set_xattr("gnocchi_%s_container" % metric.id, name, "")

def _delete_metric_measures(self, metric, timestamp_key, aggregation,
Expand Down
8 changes: 4 additions & 4 deletions gnocchi/tests/base.py
Expand Up @@ -140,11 +140,11 @@ def write(self, key, value, offset):
self._validate_key(key)
try:
current = self.kvs[key]
if len(current) < offset:
current += b'\x00' * (offset - len(current))
self.kvs[key] = current[:offset] + value
except KeyError:
raise FakeRadosModule.ObjectNotFound
current = b""
if len(current) < offset:
current += b'\x00' * (offset - len(current))
self.kvs[key] = current[:offset] + value

def stat(self, key):
self._validate_key(key)
Expand Down

0 comments on commit 7a40269

Please sign in to comment.