|
|
Shelley, Ryan 2012-02-22, 00:45
Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK directory-like layout is perfect for what I'm working on, for record storage, with one caveat. I'm curious if there's a way to set it up to return default records in the event a specific record isn't available (I'm attempting to reduce the number of round-trips to retrieve some data).
For example:
I create a node named "foo" with the data "lorem_ipsum": create /foo lorem_ipsum
Then I create a node named "bar" under "foo" with the data "baz": create /foo/bar baz
If I get "/foo/bar" obviously I'll get "baz", however, if I try to get "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly suspect as a design pattern, but there's a method to the madness. We want to create records that can be overridden by sub-records (like "/foo/bar"), but in the event that sub-record doesn't exist, I'd get back the next concrete record.
Any thoughts? Thanks!
-Ryan
Ted Dunning 2012-02-22, 01:07
ZK doesn't do this out of the box, but it is very easy to wrap up ZK primitives to get this behavior.
On Wed, Feb 22, 2012 at 12:45 AM, Shelley, Ryan <[EMAIL PROTECTED]>wrote:
> Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK > directory-like layout is perfect for what I'm working on, for record > storage, with one caveat. I'm curious if there's a way to set it up to > return default records in the event a specific record isn't available (I'm > attempting to reduce the number of round-trips to retrieve some data). > > For example: > > I create a node named "foo" with the data "lorem_ipsum": > create /foo lorem_ipsum > > Then I create a node named "bar" under "foo" with the data "baz": > create /foo/bar baz > > If I get "/foo/bar" obviously I'll get "baz", however, if I try to get > "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly suspect as > a design pattern, but there's a method to the madness. We want to create > records that can be overridden by sub-records (like "/foo/bar"), but in the > event that sub-record doesn't exist, I'd get back the next concrete record. > > Any thoughts? Thanks! > > -Ryan >
Henry Robinson 2012-02-22, 01:19
It seems like the multi-txn API might be helpful here. Since each path is of known length, you could have a multi-op query that is
get(/a/b/c/d), get(/a/b/c), get(/a/b), get(/a)
and then check the results of each in order.
Henry
On 21 February 2012 16:45, Shelley, Ryan <[EMAIL PROTECTED]> wrote:
> Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK > directory-like layout is perfect for what I'm working on, for record > storage, with one caveat. I'm curious if there's a way to set it up to > return default records in the event a specific record isn't available (I'm > attempting to reduce the number of round-trips to retrieve some data). > > For example: > > I create a node named "foo" with the data "lorem_ipsum": > create /foo lorem_ipsum > > Then I create a node named "bar" under "foo" with the data "baz": > create /foo/bar baz > > If I get "/foo/bar" obviously I'll get "baz", however, if I try to get > "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly suspect as > a design pattern, but there's a method to the madness. We want to create > records that can be overridden by sub-records (like "/foo/bar"), but in the > event that sub-record doesn't exist, I'd get back the next concrete record. > > Any thoughts? Thanks! > > -Ryan >
-- Henry Robinson Software Engineer Cloudera 415-994-6679
Shelley, Ryan 2012-02-22, 17:27
Great input folks! Thanks so much for your suggestions. I'm going to fiddle with this a bit today and go from there. Thanks again!
-Ryan
On 2/21/12 5:19 PM, "Henry Robinson" <[EMAIL PROTECTED]> wrote:
>It seems like the multi-txn API might be helpful here. Since each path is >of known length, you could have a multi-op query that is > >get(/a/b/c/d), get(/a/b/c), get(/a/b), get(/a) > >and then check the results of each in order. > >Henry > >On 21 February 2012 16:45, Shelley, Ryan <[EMAIL PROTECTED]> wrote: > >> Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK >> directory-like layout is perfect for what I'm working on, for record >> storage, with one caveat. I'm curious if there's a way to set it up to >> return default records in the event a specific record isn't available >>(I'm >> attempting to reduce the number of round-trips to retrieve some data). >> >> For example: >> >> I create a node named "foo" with the data "lorem_ipsum": >> create /foo lorem_ipsum >> >> Then I create a node named "bar" under "foo" with the data "baz": >> create /foo/bar baz >> >> If I get "/foo/bar" obviously I'll get "baz", however, if I try to get >> "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly >>suspect as >> a design pattern, but there's a method to the madness. We want to create >> records that can be overridden by sub-records (like "/foo/bar"), but in >>the >> event that sub-record doesn't exist, I'd get back the next concrete >>record. >> >> Any thoughts? Thanks! >> >> -Ryan >> > > > >-- >Henry Robinson >Software Engineer >Cloudera >415-994-6679
Shelley, Ryan 2012-02-22, 19:52
Would the multi-txn API docs be somewhere I can peruse? I haven't found anything on the site or via Google, and the sources don't seem to have JavaDocs on them. All I can seem to find on the usage of the Java API are the Java examples, and those don't have an example of doing a multi-op.
-Ryan
On 2/21/12 5:19 PM, "Henry Robinson" <[EMAIL PROTECTED]> wrote:
>It seems like the multi-txn API might be helpful here. Since each path is >of known length, you could have a multi-op query that is > >get(/a/b/c/d), get(/a/b/c), get(/a/b), get(/a) > >and then check the results of each in order. > >Henry > >On 21 February 2012 16:45, Shelley, Ryan <[EMAIL PROTECTED]> wrote: > >> Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK >> directory-like layout is perfect for what I'm working on, for record >> storage, with one caveat. I'm curious if there's a way to set it up to >> return default records in the event a specific record isn't available >>(I'm >> attempting to reduce the number of round-trips to retrieve some data). >> >> For example: >> >> I create a node named "foo" with the data "lorem_ipsum": >> create /foo lorem_ipsum >> >> Then I create a node named "bar" under "foo" with the data "baz": >> create /foo/bar baz >> >> If I get "/foo/bar" obviously I'll get "baz", however, if I try to get >> "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly >>suspect as >> a design pattern, but there's a method to the madness. We want to create >> records that can be overridden by sub-records (like "/foo/bar"), but in >>the >> event that sub-record doesn't exist, I'd get back the next concrete >>record. >> >> Any thoughts? Thanks! >> >> -Ryan >> > > > >-- >Henry Robinson >Software Engineer >Cloudera >415-994-6679
nileader 2012-02-28, 07:49
Yeah, i also find the problem of "Java Sample" Anyone has the permissions to create some?
2012/2/23 Shelley, Ryan <[EMAIL PROTECTED]>
> Would the multi-txn API docs be somewhere I can peruse? I haven't found > anything on the site or via Google, and the sources don't seem to have > JavaDocs on them. All I can seem to find on the usage of the Java API are > the Java examples, and those don't have an example of doing a multi-op. > > -Ryan > > On 2/21/12 5:19 PM, "Henry Robinson" <[EMAIL PROTECTED]> wrote: > > >It seems like the multi-txn API might be helpful here. Since each path is > >of known length, you could have a multi-op query that is > > > >get(/a/b/c/d), get(/a/b/c), get(/a/b), get(/a) > > > >and then check the results of each in order. > > > >Henry > > > >On 21 February 2012 16:45, Shelley, Ryan <[EMAIL PROTECTED]> wrote: > > > >> Hi folks. Very new to ZooKeeper and evaluating it for a project. The ZK > >> directory-like layout is perfect for what I'm working on, for record > >> storage, with one caveat. I'm curious if there's a way to set it up to > >> return default records in the event a specific record isn't available > >>(I'm > >> attempting to reduce the number of round-trips to retrieve some data). > >> > >> For example: > >> > >> I create a node named "foo" with the data "lorem_ipsum": > >> create /foo lorem_ipsum > >> > >> Then I create a node named "bar" under "foo" with the data "baz": > >> create /foo/bar baz > >> > >> If I get "/foo/bar" obviously I'll get "baz", however, if I try to get > >> "/foo/blah" I'd like to get "lorem_ipsum." I know this is highly > >>suspect as > >> a design pattern, but there's a method to the madness. We want to create > >> records that can be overridden by sub-records (like "/foo/bar"), but in > >>the > >> event that sub-record doesn't exist, I'd get back the next concrete > >>record. > >> > >> Any thoughts? Thanks! > >> > >> -Ryan > >> > > > > > > > >-- > >Henry Robinson > >Software Engineer > >Cloudera > >415-994-6679 > >
|
|