Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:25:15+00:00 2026-06-12T12:25:15+00:00

I found some callback signature such as data_completion_t , string_completion_t . But I wonder

  • 0

I found some callback signature such as data_completion_t, string_completion_t. But I wonder how zookeeper call those functions in asynchronous APIs.

Does it use a single thread to receive response from zookeeper? So I have to add mutex to protect user_data in callback. Or does it check callbacks every time another asyn API has been called?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:25:16+00:00Added an answer on June 12, 2026 at 12:25 pm

    I tested the C mt library, and found that zookeeper created another 2 threads for IO and completion, the completion function is called in the completion thread, so that those functions should be called sequentially.

    2012-10-09 15:35:36,904:60028(0x7fff7d0f7180):ZOO_INFO@zookeeper_init@786: Initiating client connection, host=127.0.0.1:3000 sessionTimeout=5000 watcher=0x0 sessionId=0 sessionPasswd=<null> context=0x0 flags=0
    2012-10-09 15:35:36,904:60028(0x7fff7d0f7180):ZOO_DEBUG@start_threads@221: starting threads...
    2012-10-09 15:35:36,905:60028(0x10af45000):ZOO_DEBUG@do_completion@459: started completion thread
    2012-10-09 15:35:36,905:60028(0x10aec2000):ZOO_DEBUG@do_io@367: started IO thread
    2012-10-09 15:35:36,905:60028(0x7fff7d0f7180):ZOO_DEBUG@zoo_aset@2700: Sending request xid=0x5073d3c9 for path [/mm/mmidc] to 127.0.0.1:3000
    2012-10-09 15:35:36,905:60028(0x10aec2000):ZOO_INFO@check_events@1703: initiated connection to server [127.0.0.1:3000]
    2012-10-09 15:35:36,909:60028(0x10aec2000):ZOO_INFO@check_events@1750: session establishment complete on server [127.0.0.1:3000], sessionId=0x13a43632d85000f, negotiated timeout=5000
    2012-10-09 15:35:36,909:60028(0x10aec2000):ZOO_DEBUG@check_events@1756: Calling a watcher for a ZOO_SESSION_EVENT and the state=ZOO_CONNECTED_STATE
    2012-10-09 15:35:36,909:60028(0x10af45000):ZOO_DEBUG@process_completions@2107: Calling a watcher for node [], type = -1 event=ZOO_SESSION_EVENT
    2012-10-09 15:35:36,910:60028(0x10aec2000):ZOO_DEBUG@process_sync_completion@1868: Processing sync_completion with type=1 xid=0x5073d3c9 rc=-101
    zoo_set2: no node
    

    the very simple code for the test, the zookeeper server is a standalone listening localhost:3000

      int main()
      {
    
        zoo_set_debug_level(ZOO_LOG_LEVEL_DEBUG);
    
        const char* host = "127.0.0.1:3000";
    
        zhandle_t *zh;
        clientid_t myid;
        zh = zookeeper_init(host, NULL, 5000, &myid, NULL, 0);
    
        struct Stat stat;
        const char* line = "/test";
        const char* ptr = "hello, world";
        int ret = zoo_set2(zh, line, ptr, strlen(ptr), -1, &stat);
        printf("zoo_set2: %s\n", zerror(ret));
    
      }
    

    Actually, these are explained in the document. http://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html

    C Binding


    The C binding has a single-threaded and multi-threaded library. The multi-threaded library is easiest to use and is most similar to the Java API. This library will create an IO thread and an event dispatch thread for handling connection maintenance and callbacks. The single-threaded library allows ZooKeeper to be used in event driven applications by exposing the event loop used in the multi-threaded library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found some classes designed for debugging in package com.sun.jdi like VirtualMachine , but
Could someone explain, why do we use callback in JavaScript? I found examples, but
I found some lovely websites - http://www.mini.jp/event_campaign/big-point/ , http://www.twenty8twelve.com/ and http://www.scozzese.com - all vertical
I found some problems when implementing Jake Wharton 's ViewPagerIndicator . These are what
I found some things I want to submit a pull request for in the
I found some old Python code that was doing something like: if type(var) is
I found some really great code from Matt Gallagher for use with making Undo
I found some old code which I'm not sure I understand completely. The folowing
I found some mapkit code on the internet that looks like this: - (void)recenterMap
I found some information about this on Scott Hanselmans Blog Does anybody exactly know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.