一: C# 的Drivers
 
  1. nuget上下载 zookeeper.Net
  
 
  IWatcher是什么?:
    client 连接到 server 后,会在server上面注册一个watcher[handler]
    如果server connection完成之后,反向通知client。(sendresponse)
    client会收到这个 handler
    client会利用这个handler找到这个注册的watcher,执行回调函数
     

 IWatcher接口的实现
    public class ZookeeperWatcher : IWatcher
{
public static CountdownEvent countdownEvent = new CountdownEvent();
public void Process(WatchedEvent @event)
{
Console.WriteLine("path={0},state={1},type={2}", @event.Path, @event.State, @event.Type);
countdownEvent.Signal();
}
}
    可以把IWatcher理解成一个 Observer 观察者,注册到 zookeeper中
 
    zookeeper初始化是一个异步的过程。
     【sendthread,eventthread】
       sendthread =》 zookeeper server
       eventthread =》 专门处理server返回的watcher通知
 
  2. Refletor 反编译DLL
 
  3. 【长连接 + watcher 模式】
    心跳: timeout/3
 
  4. 配置log4net.config
  注册:
  

  log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
           
  使用:
  private static log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
 
  5. 客户端和server交互(心跳检测)
    client < = > server 【返回sessionid】
    syncConnect 同步成功 【网络正常】
    disconnect 失去连接等待重连 【网络断线】
    expired 断网后重连, Server会返回session过期 (一直保持重连,知道网络正常)
 
    为什么重连后,server会把sessionid抹掉?
      【临时节点概念,当网络断线后,datamip会被清空】
      你的当前zkCli.sh节点是属于那个sessionid的
 
 
  6. zookeeper连接初始化指定根路径
    连接到自己需要的路径。
     

  ZooKeeperNet.ZooKeeper zookeeper = new ZooKeeperNet.ZooKeeper("192.168.1.120:2181/datamip",
TimeSpan.FromSeconds(),
new ZookeeperWatcher()); //通过wait函数,等待ZookeeperWatcher 回调函数执行成功
ZookeeperWatcher.countdownEvent.Wait();
var list = zookeeper.GetChildren("/", false);
 
 
 
 
 
 
 
 
 
 

6.nuget安装C#Driver驱动ZooKeeperNet的更多相关文章

  1. 通过NuGet安装和配置ODP.NET(Oracle Data Provider for .NET)

    前言 本文涉及ODP.NET.ODP.NET的托管(managed)驱动.Entity Framework的托管驱动 这三部分的下载.安装.配置. 1.简介 NuGet 是.NET的软件开发包管理工具 ...

  2. CentOS6.5菜鸟之旅:安装ATI显卡驱动

    一.前言 自从安装了CentOS,我的显卡就没消停过,一直在彪高温而且噪音特别大,于是决定上网搜索解决办法.下面记录下来以供日后查阅. 二.安装fglrx driver(ATI/AMD 显卡的linu ...

  3. Linux编译安装RTL8192CU芯片驱动,使用TP_LINK wn823n无线网卡

    前几天给自己的台式电脑安装了Window 7+CentOS 6.4 Linux双系统,发现在Windows 7下面可以正常使用TP_LINK wn823n无线网卡来连接无线网络,但是在Linux下面, ...

  4. Ubuntu下安装nvidia显卡驱动

    layout: post title: Ubuntu下安装nvidia显卡驱动 date: 2015-10-02 17:19:06 categories: 常用命令 tags: 显卡 驱动 最近一直在 ...

  5. AHCI模式安装XP以及驱动下载

    一.准备AHCI驱动 1.关于AHCI基础知识,请参考<AHCI模式的驱动下载.安装及蓝屏问题综合>一文. 2.安装AHCI驱动之前,请先确认桌面上.系统盘没有重要的东西需要备份,因为如果 ...

  6. Thinkpad W520 + Ubuntu 12.04LTS, 13.10, 14.04LTS安装Nvidia显卡驱动设置

    Thinkpad W520 + Ubuntu 12.04LTS, 13.10, 14.04LTS安装Nvidia显卡驱动设置 http://henzhai.com/tech/2012/07/w520- ...

  7. Ubuntu中安装NVIDIA显卡驱动

    1.参考: https://blog.csdn.net/xunan003/article/details/81665835 https://www.cnblogs.com/luofeel/p/8654 ...

  8. 在Ubuntu上安装Chrome Driver和Firefox Driver

    在Ubuntu上安装Chrome Driver和Firefox Driver 此文章只介绍Chrome Driver(Firefox Driver和该步骤相同) 下载链接:http://chromed ...

  9. Ubuntu16.04安装NVIDIA显卡驱动

    1.下载官方驱动程序 http://www.geforce.cn/drivers 如果我们直接安装驱动的话,往往会报错:ERROR: The Nouveau kernel driver is curr ...

随机推荐

  1. 学习blus老师js(6)--js运动基础

    运动基础 一.匀速运动 运动框架 在开始运动时,关闭已有定时器 把运动和停止隔开(if/else) <!DOCTYPE HTML> <html> <head> &l ...

  2. postman全方位讲解(有空看下)

    Postman 接口测试神器 Postman 是一个接口测试和 http 请求的神器,非常好用. 官方 github 地址: https://github.com/postmanlabs Postma ...

  3. JMS消息模型

    消息机制: 系统之间通信的中介,作为一台单独的服务器部署,大多数使用多个系统之间协作,是系统解耦的常见解决方案. 基于CS架构 作用:多个系统之间解耦,项目可以分开开发,满足显示的高可用(也可以说是异 ...

  4. 接口自动化(六)--使用QQ邮箱发送邮件

    接口测试执行完发送一个邮件,这里使用QQ邮箱发送,先要拿到QQ邮箱授权码,方法自行百度 # coding=utf-8 import smtplib from email.mime.text impor ...

  5. HyberLedger Fabric学习(4)-chaincode学习(操作人员)

    参考:http://hyperledger-fabric.readthedocs.io/en/latest/chaincode4noah.html chaincode也能被称作“智能合约”,一般情况下 ...

  6. uva-11044-水题

    #include <iostream> #include<memory.h> #include<stdio.h> using namespace std; int ...

  7. 重新设定McAfee Agent的菜单语言

    默认安装的McAfee Agent,语言会根据系统中的设置,自动选择了语言. 有时想更换语言,却又不想重装McAfee Agent (以前叫 ePO Agent) 其实可以直接运行下面的命令进行重新设 ...

  8. BloomFilter

    [BloomFilter] 错误率估计.最优哗哈希函数个数.位数组的大小 尚未细看.以看补上. 参考:http://blog.csdn.net/jiaomeng/article/details/149 ...

  9. Could not load TestContextBootstrapper [null]

    在对SpringBoot进行单元测试时,报错“Could not load TestContextBootstrapper [null]” 错误原因: Maven的pom.xml中某些SpringBo ...

  10. xshell评估过期解决办法

    1.登录网景官网的下载页面: https://www.netsarang.com/download/down_form.html?code=522 2.直接在页面中有红色*号的地方输入个人信息,lic ...