{"id":823,"date":"2018-07-20T08:35:10","date_gmt":"2018-07-20T00:35:10","guid":{"rendered":"https:\/\/blog.jsjs.org\/?p=823"},"modified":"2018-07-20T08:35:10","modified_gmt":"2018-07-20T00:35:10","slug":"%e3%80%90%e5%88%86%e5%b8%83%e5%bc%8f%e3%80%91zookeeper%e5%ae%a2%e6%88%b7%e7%ab%af","status":"publish","type":"post","link":"https:\/\/blog.jsjs.org\/?p=823","title":{"rendered":"\u3010\u5206\u5e03\u5f0f\u3011Zookeeper\u5ba2\u6237\u7aef"},"content":{"rendered":"<p><strong>\u4e00\u3001\u524d\u8a00<\/strong><\/p>\n<p>\u524d\u7bc7\u535a\u5ba2\u5206\u6790\u4e86Zookeeper\u7684\u5e8f\u5217\u5316\u548c\u901a\u4fe1\u534f\u8bae\uff0c\u63a5\u7740\u7ee7\u7eed\u5b66\u4e60\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u662f\u5f00\u53d1\u4eba\u5458\u4f7f\u7528Zookeeper\u6700\u4e3b\u8981\u7684\u9014\u5f84\uff0c\u5f88\u6709\u5fc5\u8981\u5f04\u61c2\u5ba2\u6237\u7aef\u662f\u5982\u4f55\u4e0e\u670d\u52a1\u7aef\u901a\u4fe1\u7684\u3002<\/p>\n<p><strong>\u4e8c\u3001\u5ba2\u6237\u7aef<\/strong><\/p>\n<p>2.1 \u5ba2\u6237\u7aef\u7ec4\u6210<\/p>\n<p>Zookeeper\u5ba2\u6237\u7aef\u4e3b\u8981\u7531\u5982\u4e0b\u6838\u5fc3\u90e8\u4ef6\u6784\u6210\u3002<\/p>\n<p>1.\u00a0<strong>Zookeeper\u5b9e\u4f8b<\/strong>\uff0c\u5ba2\u6237\u7aef\u5165\u53e3\u3002<\/p>\n<p>2.\u00a0<strong>ClientWatchManager<\/strong>\uff0c \u5ba2\u6237\u7aefWatcher\u7ba1\u7406\u5668\u3002<\/p>\n<p>3.\u00a0<strong>HostProvider<\/strong>\uff0c\u5ba2\u6237\u7aef\u5730\u5740\u5217\u8868\u7ba1\u7406\u5668\u3002<\/p>\n<p>4.\u00a0<strong>ClientCnxn<\/strong>\uff0c\u5ba2\u6237\u7aef\u6838\u5fc3\u7ebf\u7a0b\uff0c\u5185\u90e8<strong>\u5305\u542b\u4e86SendThread\u548cEventThread\u4e24\u4e2a\u7ebf\u7a0b<\/strong>\uff0cSendThread\u4e3aI\/O\u7ebf\u7a0b\uff0c\u4e3b\u8981\u8d1f\u8d23Zookeeper\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u7f51\u7edcI\/O\u901a\u4fe1\uff1bEventThread\u4e3a\u4e8b\u4ef6\u7ebf\u7a0b\uff0c\u4e3b\u8981\u8d1f\u8d23\u5bf9\u670d\u52a1\u7aef\u4e8b\u4ef6\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201611\/616953-20161124170014471-1163146559.png\" alt=\"\" \/>\u3000\u3000Zookeeper\u5ba2\u6237\u7aef\u521d\u59cb\u5316\u4e0e\u542f\u52a8\u73af\u8282\uff0c\u5c31\u662fZookeeper\u5bf9\u8c61\u7684\u5b9e\u4f8b\u5316\u8fc7\u7a0b\u3002\u5ba2\u6237\u7aef\u5728\u521d\u59cb\u5316\u548c\u542f\u52a8\u8fc7\u7a0b\u4e2d\u5927\u4f53\u53ef\u4ee5\u5206\u4e3a\u5982\u4e0b3\u4e2a\u6b65\u9aa4<\/p>\n<p>1. \u8bbe\u7f6e\u9ed8\u8ba4Watcher<\/p>\n<p>2. \u8bbe\u7f6eZookeeper\u670d\u52a1\u5668\u5730\u5740\u5217\u8868<\/p>\n<p>3. \u521b\u5efaClientCnxn\u3002<\/p>\n<p>\u82e5\u5728Zookeeper\u6784\u9020\u65b9\u6cd5\u4e2d\u4f20\u5165Watcher\u5bf9\u8c61\u65f6\uff0c\u90a3\u4e48Zookeeper\u5c31\u4f1a\u5c06\u8be5Watcher\u5bf9\u8c61\u4fdd\u5b58\u5728ZKWatcherManager\u7684defaultWatcher\u4e2d\uff0c\u5e76\u4f5c\u4e3a\u6574\u4e2a\u5ba2\u6237\u7aef\u4f1a\u8bdd\u671f\u95f4\u7684\u9ed8\u8ba4Watcher\u3002<\/p>\n<p>2.2 \u4f1a\u8bdd\u7684\u521b\u5efa<\/p>\n<p>\u4e0b\u56fe\u8868\u793a\u4e86\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4f1a\u8bdd\u5efa\u7acb\u7684\u6574\u4e2a\u8fc7\u7a0b\uff0c\u5305\u62ec\u521d\u59cb\u5316\u9636\u6bb5\uff08\u7b2c\u4e00\u9636\u6bb5\uff09\u3001\u4f1a\u8bdd\u521b\u5efa\u9636\u6bb5\uff08\u7b2c\u4e8c\u9636\u6bb5\uff09\u3001\u54cd\u5e94\u5904\u7406\u9636\u6bb5\uff08\u7b2c\u4e09\u9636\u6bb5\uff09\u4e09\u4e2a\u9636\u6bb5\u3002<img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201611\/616953-20161124205059237-613598814.png\" alt=\"\" \/><\/p>\n<p>2.3 \u670d\u52a1\u5668\u5730\u5740\u5217\u8868<\/p>\n<p>\u5728\u5b9e\u4f8b\u5316Zookeeper\u65f6\uff0c\u7528\u6237\u4f20\u5165Zookeeper\u670d\u52a1\u5668\u5730\u5740\u5217\u8868\uff0c\u5982192.168.0.1:2181,192.168.0.2:2181,192.168.0.3:2181\uff0c\u6b64\u65f6\uff0cZookeeper\u5ba2\u6237\u7aef\u5728\u8fde\u63a5\u670d\u52a1\u5668\u7684\u8fc7\u7a0b\u4e2d\uff0c\u662f\u5982\u4f55\u4ece\u8fd9\u4e2a\u670d\u52a1\u5668\u5217\u8868\u4e2d\u9009\u62e9\u670d\u52a1\u5668\u7684\u5462\uff1fZookeeper\u6536\u5230\u670d\u52a1\u5668\u5730\u5740\u5217\u8868\u540e\uff0c\u4f1a\u89e3\u6790\u51fachrootPath\u548c\u4fdd\u5b58\u670d\u52a1\u5668\u5730\u5740\u5217\u8868\u3002<\/p>\n<p>1.\u00a0<strong>Chroot<\/strong>\uff0c\u6bcf\u4e2a\u5ba2\u6237\u7aef\u53ef\u4ee5\u8bbe\u7f6e\u81ea\u5df1\u7684\u547d\u540d\u7a7a\u95f4\uff0c\u82e5\u5ba2\u6237\u7aef\u8bbe\u7f6e\u4e86Chroot\uff0c\u6b64\u65f6\uff0c\u8be5\u5ba2\u6237\u7aef\u5bf9\u670d\u52a1\u5668\u7684\u4efb\u4f55\u64cd\u4f5c\u90fd\u5c06\u88ab\u9650\u5236\u5728\u81ea\u5df1\u7684\u547d\u540d\u7a7a\u95f4\u4e0b\uff0c\u5982\u8bbe\u7f6eChoot\u4e3a\/app\/X\uff0c\u90a3\u4e48\u8be5\u5ba2\u6237\u7aef\u7684\u6240\u6709\u8282\u70b9\u8def\u5f84\u90fd\u662f\u4ee5\/app\/X\u4e3a\u6839\u8282\u70b9\u3002<\/p>\n<p>2.\u00a0<strong>\u5730\u5740\u5217\u8868\u7ba1\u7406<\/strong>\uff0cZookeeper\u4f7f\u7528StaticHostProvider\u6253\u6563\u670d\u52a1\u5668\u5730\u5740\uff08shuffle\uff09\uff0c\u5e76\u5c06\u670d\u52a1\u5668\u5730\u5740\u5f62\u6210\u4e00\u4e2a\u73af\u5f62\u5faa\u73af\u961f\u5217\uff0c\u7136\u540e\u518d\u4f9d\u6b21\u53d6\u51fa\u670d\u52a1\u5668\u5730\u5740\u3002<\/p>\n<p>2.4 \u7f51\u7edcI\/O<\/p>\n<p>ClientCnxn\u662fZookeeper\u5ba2\u6237\u7aef\u4e2d\u8d1f\u8d23\u7ef4\u62a4\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u7684\u7f51\u7edc\u8fde\u63a5\u5e76\u8fdb\u884c\u4e00\u7cfb\u5217\u7f51\u7edc\u901a\u4fe1\u7684\u6838\u5fc3\u5de5\u4f5c\u7c7b\uff0cPacket\u662fClientCnxn\u5185\u90e8\u5b9a\u4e49\u7684\u4e00\u4e2a\u5806\u534f\u8bae\u5c42\u7684\u5c01\u88c5\uff0c\u7528\u4f5cZookeeper\u4e2d\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u8f7d\u4f53\u3002Packet\u5305\u542b\u4e86\u8bf7\u6c42\u5934\uff08requestHeader\uff09\u3001\u54cd\u5e94\u5934\uff08replyHeader\uff09\u3001\u8bf7\u6c42\u4f53\uff08request\uff09\u3001\u54cd\u5e94\u4f53\uff08response\uff09\u3001\u8282\u70b9\u8def\u5f84\uff08clientPath\/serverPath\uff09\u3001\u6ce8\u518c\u7684Watcher\uff08watchRegistration\uff09\u7b49\u4fe1\u606f\uff0c\u7136\u800c\uff0c<strong>\u5e76\u975ePacket\u4e2d\u6240\u6709\u7684\u5c5e\u6027\u90fd\u5728\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u8fdb\u884c\u7f51\u7edc\u4f20\u8f93\uff0c\u53ea\u4f1a\u5c06requestHeader\u3001request\u3001readOnly\u4e09\u4e2a\u5c5e\u6027\u5e8f\u5217\u5316\uff0c\u5e76\u751f\u6210\u53ef\u7528\u4e8e\u5e95\u5c42\u7f51\u7edc\u4f20\u8f93\u7684ByteBuffer\uff0c\u5176\u4ed6\u5c5e\u6027\u90fd\u4fdd\u5b58\u5728\u5ba2\u6237\u7aef\u7684\u4e0a\u4e0b\u6587\u4e2d\uff0c\u4e0d\u4f1a\u8fdb\u884c\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u7684\u7f51\u7edc\u4f20\u8f93<\/strong>\u3002<\/p>\n<p>ClientCnxn\u7ef4\u62a4\u7740<strong>outgoingQueue<\/strong>\uff08\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u53d1\u9001\u961f\u5217\uff09\u548c<strong>pendingQueue<\/strong>\uff08\u670d\u52a1\u7aef\u54cd\u5e94\u7684\u7b49\u5f85\u961f\u5217\uff09\uff0coutgoingQueue\u4e13\u95e8\u7528\u4e8e\u5b58\u50a8\u90a3\u4e9b\u9700\u8981\u53d1\u9001\u5230\u670d\u52a1\u7aef\u7684Packet\u96c6\u5408\uff0cpendingQueue\u7528\u4e8e\u5b58\u50a8\u90a3\u4e9b\u5df2\u7ecf\u4ece\u5ba2\u6237\u7aef\u53d1\u9001\u5230\u670d\u52a1\u7aef\u7684\uff0c\u4f46\u662f\u9700\u8981\u7b49\u5f85\u670d\u52a1\u7aef\u54cd\u5e94\u7684Packet\u96c6\u5408\u3002<\/p>\n<p>\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0c\u4f1a\u4eceoutgoingQueue\u4e2d\u53d6\u51fa\u4e00\u4e2a\u53ef\u53d1\u9001\u7684Packet\u5bf9\u8c61\uff0c\u540c\u65f6\u751f\u6210\u4e00\u4e2a\u5ba2\u6237\u7aef\u8bf7\u6c42\u5e8f\u53f7XID\u5e76\u5c06\u5176\u8bbe\u7f6e\u5230Packet\u8bf7\u6c42\u5934\u4e2d\u53bb\uff0c\u7136\u540e\u5e8f\u5217\u5316\u540e\u518d\u53d1\u9001\uff0c\u8bf7\u6c42\u53d1\u9001\u5b8c\u6bd5\u540e\uff0c\u4f1a\u7acb\u5373\u5c06\u8be5Packet\u4fdd\u5b58\u5230pendingQueue\u4e2d\uff0c\u4ee5\u4fbf\u7b49\u5f85\u670d\u52a1\u7aef\u54cd\u5e94\u8fd4\u56de\u540e\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/images2015.cnblogs.com\/blog\/616953\/201611\/616953-20161124211747487-571974849.png\" alt=\"\" \/><\/p>\n<p>\u5ba2\u6237\u7aef\u83b7\u53d6\u5230\u6765\u81ea\u670d\u52a1\u7aef\u7684\u5b8c\u6574\u54cd\u5e94\u6570\u636e\u540e\uff0c\u6839\u636e\u4e0d\u540c\u7684\u5ba2\u6237\u7aef\u8bf7\u6c42\u7c7b\u578b\uff0c\u4f1a\u8fdb\u884c\u4e0d\u540c\u7684\u5904\u7406\u3002<\/p>\n<p>1. \u82e5\u68c0\u6d4b\u5230\u6b64\u65f6\u5ba2\u6237\u7aef\u5c1a\u672a\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u90a3\u4e48\u8bf4\u660e\u5f53\u524d\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u6b63\u5728\u8fdb\u884c\u4f1a\u8bdd\u521b\u5efa\uff0c\u76f4\u63a5\u5c06\u63a5\u6536\u7684ByteBuffer\u5e8f\u5217\u5316\u6210ConnectResponse\u5bf9\u8c61\u3002<\/p>\n<p>2. \u82e5\u5f53\u524d\u5ba2\u6237\u7aef\u5df2\u7ecf\u5904\u4e8e\u6b63\u5e38\u4f1a\u8bdd\u5468\u671f\uff0c\u5e76\u4e14\u63a5\u6536\u5230\u670d\u52a1\u7aef\u54cd\u5e94\u662f\u4e00\u4e2a\u4e8b\u4ef6\uff0c\u90a3\u4e48\u5c06\u63a5\u6536\u7684ByteBuffer\u5e8f\u5217\u5316\u6210WatcherEvent\u5bf9\u8c61\uff0c\u5e76\u5c06\u8be5\u4e8b\u4ef6\u653e\u5165\u5f85\u5904\u7406\u961f\u5217\u4e2d\u3002<\/p>\n<p>3. \u82e5\u662f\u4e00\u4e2a\u5e38\u89c4\u8bf7\u6c42\uff08Create\u3001GetData\u3001Exist\u7b49\uff09\uff0c\u90a3\u4e48\u4ecependingQueue\u961f\u5217\u4e2d\u53d6\u51fa\u4e00\u4e2aPacket\u6765\u8fdb\u884c\u76f8\u5e94\u5904\u7406\u3002\u9996\u5148\u4f1a\u68c0\u9a8c\u54cd\u5e94\u4e2d\u7684XID\u6765\u786e\u4fdd\u8bf7\u6c42\u5904\u7406\u7684\u987a\u5e8f\u6027\uff0c\u7136\u540e\u518d\u5c06\u63a5\u6536\u5230\u7684ByteBuffer\u5e8f\u5217\u5316\u6210Response\u5bf9\u8c61\u3002<\/p>\n<p><strong>SendThread\u662f\u5ba2\u6237\u7aefClientCnxn\u5185\u90e8\u7684\u4e00\u4e2a\u6838\u5fc3I\/O\u8c03\u5ea6\u7ebf\u7a0b<\/strong>\uff0c\u7528\u4e8e\u7ba1\u7406\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u7684\u6240\u6709\u7f51\u7edcI\/O\u64cd\u4f5c\uff0c\u5728Zookeeper\u5ba2\u6237\u7aef\u5b9e\u9645\u8fd0\u884c\u4e2d\uff0cSendThread\u7684\u4f5c\u7528\u5982\u4e0b\uff1a<\/p>\n<p>1. \u7ef4\u62a4\u4e86\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u7684\u4f1a\u8bdd\u751f\u547d\u5468\u671f\uff08\u901a\u8fc7\u4e00\u5b9a\u5468\u671f\u9891\u7387\u5185\u5411\u670d\u52a1\u7aef\u53d1\u9001PING\u5305\u68c0\u6d4b\u5fc3\u8df3\uff09\uff0c\u5982\u679c\u4f1a\u8bdd\u5468\u671f\u5185\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u51fa\u73b0TCP\u8fde\u63a5\u65ad\u5f00\uff0c\u90a3\u4e48\u5c31\u4f1a\u81ea\u52a8\u4e14\u900f\u660e\u5730\u5b8c\u6210\u91cd\u8fde\u64cd\u4f5c\u3002<\/p>\n<p>2. \u7ba1\u7406\u4e86\u5ba2\u6237\u7aef\u6240\u6709\u7684\u8bf7\u6c42\u53d1\u9001\u548c\u54cd\u5e94\u63a5\u6536\u64cd\u4f5c\uff0c\u5176\u5c06\u4e0a\u5c42\u5ba2\u6237\u7aefAPI\u64cd\u4f5c\u8f6c\u6362\u6210\u76f8\u5e94\u7684\u8bf7\u6c42\u534f\u8bae\u5e76\u53d1\u9001\u5230\u670d\u52a1\u7aef\uff0c\u5e76\u5b8c\u6210\u5bf9\u540c\u6b65\u8c03\u7528\u7684\u8fd4\u56de\u548c\u5f02\u6b65\u8c03\u7528\u7684\u56de\u8c03\u3002<\/p>\n<p>3. \u5c06\u6765\u81ea\u670d\u52a1\u7aef\u7684\u4e8b\u4ef6\u4f20\u9012\u7ed9EventThread\u53bb\u5904\u7406\u3002<\/p>\n<p><strong>EventThread\u662f\u5ba2\u6237\u7aefClientCnxn\u5185\u90e8\u7684\u4e00\u4e2a\u4e8b\u4ef6\u5904\u7406\u7ebf\u7a0b<\/strong>\uff0c\u8d1f\u8d23\u5ba2\u6237\u7aef\u7684\u4e8b\u4ef6\u5904\u7406\uff0c\u5e76\u89e6\u53d1\u5ba2\u6237\u7aef\u6ce8\u518c\u7684Watcher\u76d1\u542c\u3002EventThread\u4e2d\u7684watingEvents\u961f\u5217\u7528\u4e8e\u4e34\u65f6\u5b58\u653e\u90a3\u4e9b\u9700\u8981\u88ab\u89e6\u53d1\u7684Object\uff0c\u5305\u62ec\u5ba2\u6237\u7aef\u6ce8\u518c\u7684Watcher\u548c\u5f02\u6b65\u63a5\u53e3\u4e2d\u6ce8\u518c\u7684\u56de\u8c03\u5668AsyncCallback\u3002\u540c\u65f6\uff0cEventThread\u4f1a\u4e0d\u65ad\u5730\u4ecewatingEvents\u4e2d\u53d6\u51faObject\uff0c\u8bc6\u522b\u5177\u4f53\u7c7b\u578b\uff08Watcher\u6216AsyncCallback\uff09\uff0c\u5e76\u5206\u522b\u8c03\u7528process\u548cprocessResult\u63a5\u53e3\u65b9\u6cd5\u6765\u5b9e\u73b0\u5bf9\u4e8b\u4ef6\u7684\u89e6\u53d1\u548c\u56de\u8c03\u3002<\/p>\n<p><strong>\u4e09\u3001\u603b\u7ed3<\/strong><\/p>\n<p>\u672c\u7bc7\u535a\u6587\u8bb2\u89e3\u4e86\u5ba2\u6237\u7aef\u7684\u76f8\u5173\u7ec6\u8282\uff0c\u5185\u5bb9\u8f83\u4e3a\u7b80\u5355\u6613\u61c2\uff0c\u8be5\u6a21\u5757\u77e5\u8bc6\u4f1a\u4e3a\u4e4b\u540e\u5206\u6790\u6e90\u7801\u6253\u4e0b\u597d\u7684\u57fa\u7840\uff0c\u8c22\u8c22\u5404\u4f4d\u56ed\u53cb\u89c2\u770b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u524d\u8a00 \u524d\u7bc7\u535a\u5ba2\u5206\u6790\u4e86Zookeeper\u7684\u5e8f\u5217\u5316\u548c\u901a\u4fe1\u534f\u8bae\uff0c\u63a5\u7740\u7ee7\u7eed\u5b66\u4e60\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u662f\u5f00\u53d1\u4eba\u5458\u4f7f\u7528Zookeeper\u6700\u4e3b\u8981\u7684\u9014\u5f84\uff0c\u5f88\u6709\u5fc5\u8981\u5f04\u61c2\u5ba2\u6237\u7aef\u662f\u5982\u4f55\u4e0e\u670d\u52a1\u7aef\u901a\u4fe1\u7684\u3002 \u4e8c\u3001\u5ba2\u6237\u7aef 2.1 \u5ba2\u6237\u7aef\u7ec4\u6210 Zookeeper\u5ba2\u6237\u7aef\u4e3b\u8981\u7531\u5982\u4e0b\u6838\u5fc3\u90e8\u4ef6\u6784\u6210\u3002 1.\u00a0Zookeeper\u5b9e\u4f8b\uff0c\u5ba2\u6237\u7aef\u5165\u53e3\u3002 2.\u00a0ClientWatchManager\uff0c \u5ba2\u6237\u7aefWatcher\u7ba1\u7406\u5668\u3002 3.\u00a0HostProvider\uff0c\u5ba2\u6237\u7aef\u5730\u5740\u5217\u8868\u7ba1\u7406\u5668\u3002 4.\u00a0ClientCnxn\uff0c\u5ba2\u6237\u7aef\u6838\u5fc3\u7ebf\u7a0b\uff0c\u5185\u90e8\u5305\u542b\u4e86SendThread\u548cEventThread\u4e24\u4e2a\u7ebf\u7a0b\uff0cSendThread\u4e3aI\/O\u7ebf\u7a0b\uff0c\u4e3b\u8981\u8d1f\u8d23Zookeeper\u5ba2\u6237\u7aef\u548c\u670d\u52a1\u5668\u4e4b\u95f4\u7684\u7f51\u7edcI\/O\u901a\u4fe1\uff1bEventThread\u4e3a\u4e8b\u4ef6\u7ebf\u7a0b\uff0c\u4e3b\u8981\u8d1f\u8d23\u5bf9\u670d\u52a1\u7aef\u4e8b\u4ef6\u8fdb\u884c\u5904\u7406\u3002 \u3000\u3000Zookeeper\u5ba2\u6237\u7aef\u521d\u59cb\u5316\u4e0e\u542f\u52a8\u73af\u8282\uff0c\u5c31\u662fZookeeper\u5bf9\u8c61\u7684\u5b9e\u4f8b\u5316\u8fc7\u7a0b\u3002\u5ba2\u6237\u7aef\u5728\u521d\u59cb\u5316\u548c\u542f\u52a8\u8fc7\u7a0b\u4e2d\u5927\u4f53\u53ef\u4ee5\u5206\u4e3a\u5982\u4e0b3\u4e2a\u6b65\u9aa4 1. \u8bbe\u7f6e\u9ed8\u8ba4Watcher 2. \u8bbe\u7f6eZookeeper\u670d\u52a1\u5668\u5730\u5740\u5217\u8868 3. \u521b\u5efaClientCnxn\u3002 \u82e5\u5728Zookeeper\u6784\u9020\u65b9\u6cd5\u4e2d\u4f20\u5165Watcher\u5bf9\u8c61\u65f6\uff0c\u90a3\u4e48Zookeeper\u5c31\u4f1a\u5c06\u8be5Watcher\u5bf9\u8c61\u4fdd\u5b58\u5728ZKWatcherManager\u7684defaultWatcher\u4e2d\uff0c\u5e76\u4f5c\u4e3a\u6574\u4e2a\u5ba2\u6237\u7aef\u4f1a\u8bdd\u671f\u95f4\u7684\u9ed8\u8ba4Watcher\u3002 2.2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[1],"tags":[],"class_list":["post-823","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/823","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=823"}],"version-history":[{"count":0,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=\/wp\/v2\/posts\/823\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=823"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=823"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jsjs.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=823"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}