Quantcast
Channel: Apache Timeline
Viewing all articles
Browse latest Browse all 5648

very strange behavior - data is not written in ZK

$
0
0
Hi,

I have following function which sets a value to a znode as 1 or 0. However,
the value is not getting set in Zookeeper ( data version is being changed
though). This piece of code used to work, until I upgraded the cluster to
latest zookeeper version.

Any idea what is going wrong? Your help is much appreciated !!

zk_map_status

*zk_map_lock(zk_map *zkm) { *

struct Stat *stats = (struct Stat *)xcalloc(1,sizeof(struct Stat));

int lock, size;

*int rc,zrc = zoo_get(zkm->zk, zkm->path, 0, (char *)隇
눬?쭚); * /*/getting the lock value from ZK*

if(zrc ==ZOK) {

//here we need to grab the lock

if(lock == 0) {

printf("\n zk_map_lock %s lock:%d version:%d"
,zkm->path,lock,stats->version);fflush(stdout);

lock=1;

int zrc2 = *zoo_set(zkm->zk, zkm->path,(char *)隇
sizeof(int),stats->version); //if zero setting to 1*

if(zrc2 == ZOK){

printf("\n Returning Success");fflush(stdout);

rc = ZK_MAP_SUCCESS;

} else

rc = ZK_MAP_FAILURE;

else

rc = ZK_MAP_FAILURE;

else if(zrc == ZNONODE)

rc = ZK_MAP_ENOENT;

else

rc = ZK_MAP_FAILURE;

//testing need to be removed later on

lock=0;

*zrc = zoo_get(zkm->zk, zkm->path, 0, (char *)隇 눬?쭚);
//retrieving the value and it is still 0 -->very strange*

printf("\n zrc:%d zk_map_lock %s lock:%d version:%d"
,zrc,zkm->path,lock,stats->version);fflush(stdout);

free(stats);

return rc;

=======

output

*Printf1: zk_map_lock /dir/6549211657075368907 lock:0 version:0*

*Printf2: zrc:0 zk_map_lock /dir/6549211657075368907 lock:0 version:1*

Thanks, Mudit

Viewing all articles
Browse latest Browse all 5648

Trending Articles