zookeeper-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lahiru Gunathilake <glah...@gmail.com>
Subject Re: Time issue in zookeeper client
Date Fri, 20 Jun 2014 14:13:32 GMT
Hi Jordan,

I am going to use Curator to select the leader when I implement my workers.
At this point I am just registering my workers and any worker can register
without a leader when they start them. I understood what are you saying, so
at this point I will listen to SyncConnected event and then proceed.

Thanks a lot for the response.

Regards
Lahiru


On Fri, Jun 20, 2014 at 9:52 AM, Jordan Zimmerman <
jordan@jordanzimmerman.com> wrote:

> When you allocate a ZooKeeper instance, you must wait for
> the SyncConnected event. If you try to create a node before you receive
> this event you’ll get a connection error. It’s because of this (and many
> other reasons) that I wrote Curator. If you’re using ZooKeeper in the JVM I
> encourage you to use Apache Curator: http://curator.apache.org
>
> -Jordan
>
>
> From: Lahiru Gunathilake glahiru@gmail.com
> Reply: user@zookeeper.apache.org user@zookeeper.apache.org
> Date: June 20, 2014 at 8:42:54 AM
> To: user@zookeeper.apache.org user@zookeeper.apache.org
> Subject:  Time issue in zookeeper client
>
> Hi All,
>
> I am using zookeeper to register cluster nodes. In my system the default
> scenario we have multiple thrift services(different services and default
> mode 1 thrift service for each in a single jvm ) registering them selves
> (default try out mode), In that case one service makes parent nodes others
> just checks the existence of parent and in-case it doesn't exist they will
> make the parent nodes and register with the ephemaral node.
>
> When I start my jvm I see the last thrift service always consistently fail
> and when I add a thread sleep it worked. When I start the last service in
> a
> separate jvm it works. Is there anything I am doing wrong.
>
> Code looks as below for failing service. Other services does the same.
>
> zk = new ZooKeeper(zkhostPort, 6000, this); // no watcher is required,
> this will only use to store some data
> String gfacServer =
> ServerSettings.getSetting(Constants.ZOOKEEPER_GFAC_SERVER_NODE);
> Thread.sleep(1000); // this fixed my issue but not sure why
> its failing
> Stat zkStat = zk.exists(gfacServer, false);
> if (zkStat == null) {
> zk.create(gfacServer, new byte[0],
> ZooDefs.Ids.OPEN_ACL_UNSAFE,
> CreateMode.PERSISTENT);
> }
> String instantNode = gfacServer + File.separator +
> String.valueOf(new Random().nextInt(Integer.MAX_VALUE));
> zkStat = zk.exists(instantNode, false);
> if (zkStat == null) {
> zk.create(instantNode,
> airavataServerHostPort.getBytes(),
> ZooDefs.Ids.OPEN_ACL_UNSAFE,
> CreateMode.EPHEMERAL); // other component
> will watch these childeren creation deletion to monitor the status of the
> node
> }
>
> Am I doing anything wrong ?
>
> Regards
> Lahiru
> --
> System Analyst Programmer
> PTI Lab
> Indiana University
>
>


-- 
System Analyst Programmer
PTI Lab
Indiana University

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message