Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Threaded View
Zookeeper >> mail # user >> Time issue in zookeeper client


Copy link to this message
-
Re: Time issue in zookeeper client
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 [EMAIL PROTECTED]
Reply: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: June 20, 2014 at 8:42:54 AM
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
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  

 
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB