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

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

  1. log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"));
  使用:
  1. 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连接初始化指定根路径
    连接到自己需要的路径。
     

  1. ZooKeeperNet.ZooKeeper zookeeper = new ZooKeeperNet.ZooKeeper("192.168.1.120:2181/datamip",
  2. TimeSpan.FromSeconds(),
  3. new ZookeeperWatcher());
  4.  
  5. //通过wait函数,等待ZookeeperWatcher 回调函数执行成功
  6. ZookeeperWatcher.countdownEvent.Wait();
  7. 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. 黄聪:C#多线程教程(1):BeginInvoke和EndInvoke方法,解决主线程延时Thread.sleep柱塞问题(转)

    开发语言:C#3.0 IDE:Visual Studio 2008 本系列教程主要包括如下内容: 1.  BeginInvoke和EndInvoke方法 2.  Thread类 3. 线程池 4. 线 ...

  2. 十三.jQuery源码解析之$.type()

    512行:出现了一个class2type. 在jQuery中全局搜索这个变量. 这段代码的意思是将一串字符串通过空格分割成数组,并且使用each遍历数组来初始化class2type. 最终的结果应该是 ...

  3. 精《Linux内核精髓:精通Linux内核必会的75个绝技》一HACK #5 使用checkpatch.pl检查补丁的格式

    HACK #5 使用checkpatch.pl检查补丁的格式 本节介绍发布前检查补丁格式的方法.Linux内核是由多个开发者进行开发的.因此,为了保持补丁评估与源代码的可读性,按照统一的规则进行编写是 ...

  4. 新的方法(Set<T>)实现mvc的crud

    model层的属性为: public partial class UserInfo { public int Uid { get; set; } public string UName { get; ...

  5. 【CentOS 6.5】安装gcc-4.8.2和Qt5.2

    因为CentOS6.5中gcc版本比较低.安装Qt5.2前先升级gcc. 首先下载gcc,附上百度盘地址:http://pan.baidu.com/s/1jGibvqY 解压安装包,并进入到解压文件夹 ...

  6. 「小程序JAVA实战」小程序查看视频发布者信息(64)

    转自:https://idig8.com/2018/09/24/xiaochengxujavashizhanxiaochengxuchakanshipinfabuzhexinxi63/ 当我们点击右下 ...

  7. WordPress无法发送电子邮件,可能原因:您的主机禁用了mail()函数解决方案

    体验更优排版请移步原文:http://blog.kwin.wang/website/wp-cant-send-email-solution.html 最近折腾了下WordPress,给米表 搭了个论坛 ...

  8. IDEA 实用注册码自动生成

    将以下代码保存成keygen.java java开发者一看就明白什么意思! import java.math.BigInteger; import java.util.Date; import jav ...

  9. python中numpy计算数组的行列式numpy.linalg.det()

    numpy.linalg.det numpy.linalg.det(a)[source] 计算任何一个数组a的行列式,但是这里要求数组的最后两个维度必须是方阵. 参数: a : (..., M, M) ...

  10. 前端开发之jQuery篇--选择器

    主要内容: 1.jQuery简介 2.jQuery文件的引入 3.jQuery选择器 4.jQuery对象与DOM对象的转换 一.jQuery简介 1.介绍 jQuery是一个JavaScript库: ...