You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Techy Teck <co...@gmail.com> on 2013/11/13 06:51:51 UTC
Znode Timestamp?
When we create any znode or update znode's data then is there any
timestamps related with znode?
Basically I am interested in getting the znode timestamp when that node got
created or when it got updated?
I am using apache curator library -
CuratorFramework client =
CuratorClient.createSimple("localhost:2181");
client.start();
Any thoughts?
Re: Znode Timestamp?
Posted by Techy Teck <co...@gmail.com>.
Thanks
On Tue, Nov 12, 2013 at 10:22 PM, Cameron McKenzie
<mc...@gmail.com>wrote:
> Yep, the Stat object will be null if the zNode doesn't exist.
>
>
> On Wed, Nov 13, 2013 at 5:21 PM, Techy Teck <co...@gmail.com>wrote:
>
>> one silly question.. If we need to check whether any znode exists or not,
>> then we need to do something like below - right?
>>
>> if(client.checkExists().forPath(/path_to_znode) != null) {
>> // do something here
>> }
>>
>>
>> This works fine.. But just wanted to make sure if there is any better way
>> of doing it..
>> Thanks.
>>
>>
>>
>>
>> On Tue, Nov 12, 2013 at 10:19 PM, Techy Teck <co...@gmail.com>wrote:
>>
>>> cool. Thanks.. Got that working..
>>>
>>>
>>> On Tue, Nov 12, 2013 at 10:15 PM, Cameron McKenzie <
>>> mckenzie.cam@gmail.com> wrote:
>>>
>>>> If you execute a checkExists() on the zNode, it will tell you the
>>>> creation time (ctime) and the modification time (mtime)
>>>>
>>>> Stat stat = client.checkExists().forPath("/path_to_znode");
>>>>
>>>> stat.getCtime();
>>>> stat.getMtime();
>>>>
>>>>
>>>>
>>>> On Wed, Nov 13, 2013 at 4:51 PM, Techy Teck <co...@gmail.com>wrote:
>>>>
>>>>> When we create any znode or update znode's data then is there any
>>>>> timestamps related with znode?
>>>>>
>>>>> Basically I am interested in getting the znode timestamp when that
>>>>> node got created or when it got updated?
>>>>>
>>>>> I am using apache curator library -
>>>>>
>>>>> CuratorFramework client =
>>>>> CuratorClient.createSimple("localhost:2181");
>>>>> client.start();
>>>>>
>>>>> Any thoughts?
>>>>>
>>>>
>>>>
>>>
>>
>
Re: Znode Timestamp?
Posted by Cameron McKenzie <mc...@gmail.com>.
Yep, the Stat object will be null if the zNode doesn't exist.
On Wed, Nov 13, 2013 at 5:21 PM, Techy Teck <co...@gmail.com> wrote:
> one silly question.. If we need to check whether any znode exists or not,
> then we need to do something like below - right?
>
> if(client.checkExists().forPath(/path_to_znode) != null) {
> // do something here
> }
>
>
> This works fine.. But just wanted to make sure if there is any better way
> of doing it..
> Thanks.
>
>
>
>
> On Tue, Nov 12, 2013 at 10:19 PM, Techy Teck <co...@gmail.com>wrote:
>
>> cool. Thanks.. Got that working..
>>
>>
>> On Tue, Nov 12, 2013 at 10:15 PM, Cameron McKenzie <
>> mckenzie.cam@gmail.com> wrote:
>>
>>> If you execute a checkExists() on the zNode, it will tell you the
>>> creation time (ctime) and the modification time (mtime)
>>>
>>> Stat stat = client.checkExists().forPath("/path_to_znode");
>>>
>>> stat.getCtime();
>>> stat.getMtime();
>>>
>>>
>>>
>>> On Wed, Nov 13, 2013 at 4:51 PM, Techy Teck <co...@gmail.com>wrote:
>>>
>>>> When we create any znode or update znode's data then is there any
>>>> timestamps related with znode?
>>>>
>>>> Basically I am interested in getting the znode timestamp when that node
>>>> got created or when it got updated?
>>>>
>>>> I am using apache curator library -
>>>>
>>>> CuratorFramework client =
>>>> CuratorClient.createSimple("localhost:2181");
>>>> client.start();
>>>>
>>>> Any thoughts?
>>>>
>>>
>>>
>>
>
Re: Znode Timestamp?
Posted by Techy Teck <co...@gmail.com>.
one silly question.. If we need to check whether any znode exists or not,
then we need to do something like below - right?
if(client.checkExists().forPath(/path_to_znode) != null) {
// do something here
}
This works fine.. But just wanted to make sure if there is any better way
of doing it..
Thanks.
On Tue, Nov 12, 2013 at 10:19 PM, Techy Teck <co...@gmail.com>wrote:
> cool. Thanks.. Got that working..
>
>
> On Tue, Nov 12, 2013 at 10:15 PM, Cameron McKenzie <mckenzie.cam@gmail.com
> > wrote:
>
>> If you execute a checkExists() on the zNode, it will tell you the
>> creation time (ctime) and the modification time (mtime)
>>
>> Stat stat = client.checkExists().forPath("/path_to_znode");
>>
>> stat.getCtime();
>> stat.getMtime();
>>
>>
>>
>> On Wed, Nov 13, 2013 at 4:51 PM, Techy Teck <co...@gmail.com>wrote:
>>
>>> When we create any znode or update znode's data then is there any
>>> timestamps related with znode?
>>>
>>> Basically I am interested in getting the znode timestamp when that node
>>> got created or when it got updated?
>>>
>>> I am using apache curator library -
>>>
>>> CuratorFramework client =
>>> CuratorClient.createSimple("localhost:2181");
>>> client.start();
>>>
>>> Any thoughts?
>>>
>>
>>
>
Re: Znode Timestamp?
Posted by Techy Teck <co...@gmail.com>.
cool. Thanks.. Got that working..
On Tue, Nov 12, 2013 at 10:15 PM, Cameron McKenzie
<mc...@gmail.com>wrote:
> If you execute a checkExists() on the zNode, it will tell you the creation
> time (ctime) and the modification time (mtime)
>
> Stat stat = client.checkExists().forPath("/path_to_znode");
>
> stat.getCtime();
> stat.getMtime();
>
>
>
> On Wed, Nov 13, 2013 at 4:51 PM, Techy Teck <co...@gmail.com>wrote:
>
>> When we create any znode or update znode's data then is there any
>> timestamps related with znode?
>>
>> Basically I am interested in getting the znode timestamp when that node
>> got created or when it got updated?
>>
>> I am using apache curator library -
>>
>> CuratorFramework client =
>> CuratorClient.createSimple("localhost:2181");
>> client.start();
>>
>> Any thoughts?
>>
>
>
Re: Znode Timestamp?
Posted by Cameron McKenzie <mc...@gmail.com>.
If you execute a checkExists() on the zNode, it will tell you the creation
time (ctime) and the modification time (mtime)
Stat stat = client.checkExists().forPath("/path_to_znode");
stat.getCtime();
stat.getMtime();
On Wed, Nov 13, 2013 at 4:51 PM, Techy Teck <co...@gmail.com> wrote:
> When we create any znode or update znode's data then is there any
> timestamps related with znode?
>
> Basically I am interested in getting the znode timestamp when that node
> got created or when it got updated?
>
> I am using apache curator library -
>
> CuratorFramework client =
> CuratorClient.createSimple("localhost:2181");
> client.start();
>
> Any thoughts?
>
Re: Znode Timestamp?
Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
No need to get the ZooKeeper reference. Curator wraps all ZooKeeper methods. There’s a Curator analog to all ZooKeeper methods. Using the Curator method has the advantage of connection management.
-Jordan
On Nov 12, 2013, at 10:55 PM, kishore g <g....@gmail.com> wrote:
> You can definitely get this directly from zookeeper.
>
> http://zookeeper.apache.org/doc/r3.4.5/api/org/apache/zookeeper/data/Stat.html
>
> See exists and getData
>
> http://zookeeper.apache.org/doc/r3.3.2/api/org/apache/zookeeper/ZooKeeper.html
>
> Not sure about curator but i am guessing there would be some way to get
> zookeeper reference from curatorFramework object.
>
>
>
>
> On Tue, Nov 12, 2013 at 9:51 PM, Techy Teck <co...@gmail.com> wrote:
>
>> When we create any znode or update znode's data then is there any
>> timestamps related with znode?
>>
>> Basically I am interested in getting the znode timestamp when that node got
>> created or when it got updated?
>>
>> I am using apache curator library -
>>
>> CuratorFramework client =
>> CuratorClient.createSimple("localhost:2181");
>> client.start();
>>
>> Any thoughts?
>>
Re: Znode Timestamp?
Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
No need to get the ZooKeeper reference. Curator wraps all ZooKeeper methods. There’s a Curator analog to all ZooKeeper methods. Using the Curator method has the advantage of connection management.
-Jordan
On Nov 12, 2013, at 10:55 PM, kishore g <g....@gmail.com> wrote:
> You can definitely get this directly from zookeeper.
>
> http://zookeeper.apache.org/doc/r3.4.5/api/org/apache/zookeeper/data/Stat.html
>
> See exists and getData
>
> http://zookeeper.apache.org/doc/r3.3.2/api/org/apache/zookeeper/ZooKeeper.html
>
> Not sure about curator but i am guessing there would be some way to get
> zookeeper reference from curatorFramework object.
>
>
>
>
> On Tue, Nov 12, 2013 at 9:51 PM, Techy Teck <co...@gmail.com> wrote:
>
>> When we create any znode or update znode's data then is there any
>> timestamps related with znode?
>>
>> Basically I am interested in getting the znode timestamp when that node got
>> created or when it got updated?
>>
>> I am using apache curator library -
>>
>> CuratorFramework client =
>> CuratorClient.createSimple("localhost:2181");
>> client.start();
>>
>> Any thoughts?
>>
Re: Znode Timestamp?
Posted by kishore g <g....@gmail.com>.
You can definitely get this directly from zookeeper.
http://zookeeper.apache.org/doc/r3.4.5/api/org/apache/zookeeper/data/Stat.html
See exists and getData
http://zookeeper.apache.org/doc/r3.3.2/api/org/apache/zookeeper/ZooKeeper.html
Not sure about curator but i am guessing there would be some way to get
zookeeper reference from curatorFramework object.
On Tue, Nov 12, 2013 at 9:51 PM, Techy Teck <co...@gmail.com> wrote:
> When we create any znode or update znode's data then is there any
> timestamps related with znode?
>
> Basically I am interested in getting the znode timestamp when that node got
> created or when it got updated?
>
> I am using apache curator library -
>
> CuratorFramework client =
> CuratorClient.createSimple("localhost:2181");
> client.start();
>
> Any thoughts?
>