一: 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. 转转转![Spring MVC] - 500/404错误处理-SimpleMappingExceptionResolver

    参考博客: http://www.cnblogs.com/dongying/p/6129937.html http://www.cnblogs.com/rollenholt/archive/2012/ ...

  2. 关于Class.getResource和ClassLoader.getResource的路径问题(转)

    参考博客:http://www.cnblogs.com/yejg1212/p/3270152.html Class.getResource(String path) 当path以/开头,如/a/b/c ...

  3. pandas 的操作表单

    最近做点东西,发现pandas处理表单那点东西都忘得差不多了,又花了半个小时过了一遍 import pandas as pdimport numpy as np data = pd.ExcelFile ...

  4. Lifecycle of an ASP.NET Web API Message

    ASP.NET Web API, as we know now, is a framework that helps build Services over HTTP. Web API was int ...

  5. Oracle表空间知识

    Oracle表空间知识 一,创建临时表空间 CREATE temporary TABLESPACE TEMP_PNLREPORT tempfile '/oradata2/ORCL/temp_pnlre ...

  6. canvas基础动画示例

    canvas基础动画示例 本文主要用最简单的例子,展示canvas动画效果是如何实现的 动画效果,是一个球绕着一点旋转 const canvas = document.getElementById(' ...

  7. 常用的ubantu操作命令

    Ubuntu软件操作的相关命令 sudo apt-get update 更新源 sudo apt-get install package 安装包 sudo apt-get remove package ...

  8. javascript的中的new

    考察 ECMAScript 语言规范中 new 运算符的定义: The new Operator The production NewExpression : new NewExpression is ...

  9. selenium webdriver——JS操作日历控件

    一般的日期控件都是input标签下弹出来的,如果使用webdriver 去设置日期, 1. 定位到该input 2. 使用sendKeys 方法 比如 但是,有的日期控件是readonly的 比如12 ...

  10. Git----远程仓库01

    到目前为止,我们已经掌握了如何在Git仓库里对一个文件进行时光穿梭,你再也不用担心文件备份或者丢失的问题了 可是用过集中式版本控制系统SVN的童鞋们会站出来说,这些功能在SVN里早就有了,没看出Git ...