Skip to content

Siblings, and other bugs #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 9, 2013
Merged

Siblings, and other bugs #243

merged 10 commits into from
May 9, 2013

Conversation

seancribbs
Copy link

Three commits, huge and IMO beneficial changes, messages repeated here for your benefit. What can I say, a long plane ride is great for coding.

Refactor model and handling of siblings.

In order to...

  1. Better detect deleted objects and sibling tombstones
  2. Reduce server roundtrips to fetch object siblings (which was an inconsistency between HTTP and PBC).

...this refactor introduces breaking changes.

This introduces the RiakContent class which models a single sibling. An RiakObject that is NOT in conflict will appear to have one "sibling". Objects that are strictly "not found" will have ZERO siblings. Otherwise, the object will have as many siblings as are returned by Riak. This is more consistent with Riak's model of objects (values).

Most existing methods and properties that were on RiakObject have been proxied in such a manner that if the object is not in conflict, the corresponding property or method on the solitary sibling will be invoked. When in conflict, these properties and methods with raise the new riak.ConflictError exception. Except in the case of conflict, this will ease transition of existing code to the new behavior.

The get_sibling method and behavior has been broken to reflect the fact that all siblings are always requested and handled appropriately. The method now produces a deprecation warning and simply returns the requested sibling already in the object. The HTTP transport no longer supports retrieving the "text" format of objects in conflict.

This commit also completes a refactoring of the HTTP transport to break-out transport codec methods into a separate class/file, for clarity and consistency with the PBC transport.

Correct usage and handling of last_modified metadata.

HTTP and PBC both handled the "Last-Modified" metadatum differently, and RiakObject (now RiakContent) did not expose it properly. Now both transports convert the metadatum into a floating-point UNIX timestamp (UTC). Additionally, the "ETag" metadatum is now consistently named and exposed.

Normalize handling of vector clocks across transports.

This addresses the possibility that an object might be fetched from one interface/transport and stored in the other. Instead, we wrap the raw value in an object that can handle decoding and encoding the format that the transport requires.

Unfinished business

  • Remove put_new method, since it is equivalent to put now.
  • Ensure PB responses that return only metadata don't clobber existing siblings
  • Decide whether the transport should return RiakLink when decoding links or just plain tuples, normalize
  • Correct documentation string on RiakObject.exists, when in conflict it returns True

Sean Cribbs added 3 commits April 28, 2013 05:26
In order to...

1. Better detect deleted objects and sibling tombstones
2. Reduce server roundtrips to fetch object siblings (which was an
   inconsistency between HTTP and PBC).

...this refactor introduces breaking changes.

This introduces the `RiakContent` class which models a single sibling.
An `RiakObject` that is NOT in conflict will appear to have one
"sibling". Objects that are strictly "not found" will have ZERO
siblings. Otherwise, the object will have as many siblings as are
returned by Riak. This is more consistent with Riak's model of
objects (values).

Most existing methods and properties that were on `RiakObject` have
been proxied in such a manner that if the object is not in conflict,
the corresponding property or method on the solitary sibling will be
invoked. When in conflict, these properties and methods with raise the
new `riak.ConflictError` exception. Except in the case of conflict,
this will ease transition of existing code to the new behavior.

The `get_sibling` method and behavior has been broken to reflect the
fact that all siblings are always requested and handled appropriately.
The method now produces a deprecation warning and simply returns the
requested sibling already in the object. The HTTP transport no longer
supports retrieving the "text" format of objects in conflict.

This commit also completes a refactoring of the HTTP transport to
break-out transport codec methods into a separate class/file, for
clarity and consistency with the PBC transport.
This addresses the possibility that an object might be fetched from
one interface/transport and stored in the other. Instead, we wrap the
raw value in an object that can handle decoding and encoding the
format that the transport requires.
if robj.key is None:
response = self._request('POST', url, headers, content)
expect = [201]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 200 also a valid return status if return_body = True?

Also does idiomatic python suggest that we should use a tuple instead of a list? (This is probably not that important, however)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should test the return_body parameter here and add 200 to the list.

I'm not sure about which is more idiomatic; to me, tuples seem most appropriate when position matters, but here it doesn't. Is there some performance/garbage-related reason to use tuples?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing the code again, the return_body / 200 case is already handled.

@seancribbs
Copy link
Author

So, thanks to @javajolt and @reiddraper I have a plan for how to add sibling-resolution functions to the mix, but I'm not sure this is the appropriate PR to do it in. Thoughts?

@hazen
Copy link

hazen commented May 1, 2013

Seems like there is already plenty going on in this PR. Maybe the sibling-resolution stuff should be broken out? That said, I'm sure it would be dependent upon this one.

@shuhaowu
Copy link
Contributor

shuhaowu commented May 2, 2013

👍 for the change. Proposed roughly the same method under my riak-python-client2 experiment.

When can we see this merged?

@seancribbs
Copy link
Author

Thanks @shuhaowu. I think if we can get @javajolt and/or @evanmcc to give it the once-over, I'll merge.

Sean Cribbs added 3 commits May 3, 2013 11:36
@seancribbs
Copy link
Author

@javajolt Added a test for tombstones that exist as siblings. It turns out that when resolving values internally, Riak will collapse all tombstones into a single one.

@hazen
Copy link

hazen commented May 9, 2013

Latest commits look good. 👍

seancribbs pushed a commit that referenced this pull request May 9, 2013
@seancribbs seancribbs merged commit 0ac0050 into master May 9, 2013
@seancribbs seancribbs deleted the sdc-refactor-siblings branch May 9, 2013 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants