一: 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. java Long

    1. Long.valueOf(b) 返回的是对象 public static Long valueOf(String s) throws NumberFormatException { )); } ...

  2. 一些部署django用到的linux命令

    mv untitled45/ /1601F/wang/ 将XXXX移动到XXX,也可以用于给XXX重新命名 zip -r -q -o hello.zip  /1601F/3/untitled45 安静 ...

  3. UI“三重天”之Selenium(一)

    关注一下UI自动化,记一记笔记. UI自动化的优缺点: 关于UI自动化的优缺点想来大家都有了解,优点:解放人力(并不是完全解放),用机器(涵盖工具.脚本等)代替人工完成测试工作,将测试用例转化为脚本实 ...

  4. Oracle VM Virtualbox基础知识

    修改硬盘的UUID VBoxManage internalcommands sethduuid <filename>

  5. C#使用UUID生成ID

    tring id = System.Guid.NewGuid().ToString(); 一句话即可,但此时id中有“-”符号存在,使用下面语句可变为纯字母+数字. string id = Syste ...

  6. 如何解决JSP页面显示乱码问题

    一.JSP页面显示乱码 下面的显示JSP页面(display.jsp)就出现乱码: <html> <head> <title>JSP的中文处理</title& ...

  7. query简洁弹出层代码

    <!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content=&q ...

  8. 【转】TCP、UDP数据包大小的限制

    来自:https://blog.csdn.net/caoshangpa/article/details/51530685 1.概述 首先要看TCP/IP协议,涉及到四层:链路层,网络层,传输层,应用层 ...

  9. js获取当前项目根路径URL (转自CSDN 红领巾-sunlight)

    /** * //获取当前项目根路径 * @return {TypeName} */ function getRootPath(){ //获取当前网址,如: http://localhost:8083/ ...

  10. 微信小程序通讯录首字母索引效果,车辆品牌选择列表

    效果图: wxml代码: <block wx:for="{{list}}"> <view class='letter' id="letter{{inde ...