首页 新闻 会员 周边

在.net里使用Zookeeper,程序无法往下继续执行

0
悬赏园豆:10 [待解决问题]
        static void Main(string[] args)
        {

            //创建一个Zookeeper实例,第一个参数为目标服务器地址和端口,第二个参数为Session超时时间,第三个为节点变化时的回调方法 
            using (ZooKeeper zk = new ZooKeeper("127.0.0.1:2181", new TimeSpan(0, 0, 0, 50000), new Watcher()))
            {
                var stat = zk.Exists("/root", true);

                ////创建一个节点root,数据是mydata,不进行ACL权限控制,节点为永久性的(即客户端shutdown了也不会消失) 
                //zk.Create("/root", "mydata".GetBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent);

                //在root下面创建一个childone znode,数据为childone,不进行ACL权限控制,节点为永久性的 
                zk.Create("/root/childone", "childone".GetBytes(), Ids.OPEN_ACL_UNSAFE, CreateMode.Persistent);
                //取得/root节点下的子节点名称,返回List<String> 
                zk.GetChildren("/root", true);
                //取得/root/childone节点下的数据,返回byte[] 
                zk.GetData("/root/childone", true, null);

                //修改节点/root/childone下的数据,第三个参数为版本,如果是-1,那会无视被修改的数据版本,直接改掉
                zk.SetData("/root/childone", "childonemodify".GetBytes(), -1);
                //删除/root/childone这个节点,第二个参数为版本,-1的话直接删除,无视版本 
                zk.Delete("/root/childone", -1);
            }
        }
var stat = zk.Exists("/root", true); 执行的时候,程序就停在这里,请问是什么原因呢?
提伯斯的主页 提伯斯 | 初学一级 | 园豆:38
提问于:2018-05-21 16:38
< >
分享
所有回答(1)
0

telnet 127.0.0.1 2181 能连上吗?

dudu | 园豆:30994 (高人七级) | 2018-05-21 17:43

我使用客户端工具,无法连接到,使用zkCli.cmd,可以连接到

支持(0) 反对(0) 提伯斯 | 园豆:38 (初学一级) | 2018-05-21 17:47

输入telnet 127.0.0.1 2181 后,控制台没内容

支持(0) 反对(0) 提伯斯 | 园豆:38 (初学一级) | 2018-05-21 17:52

@提伯斯: 用的是哪个 .NET 客户端?

支持(0) 反对(0) dudu | 园豆:30994 (高人七级) | 2018-05-21 17:55

@dudu: zookeeper-dev-ZooInspector

支持(0) 反对(0) 提伯斯 | 园豆:38 (初学一级) | 2018-05-21 17:57

@提伯斯: 我指的是 C# 中引用的程序集

支持(0) 反对(0) dudu | 园豆:30994 (高人七级) | 2018-05-21 18:02

@dudu: ZooKeeperNet

支持(0) 反对(0) 提伯斯 | 园豆:38 (初学一级) | 2018-05-21 18:03

@提伯斯: 先改为 var stat = zk.Exists("/root", fasle); 试试

/// If the watch is true and the call is successful (no exception is thrown),
/// a watch will be left on the node with the given path. The watch will be
/// triggered by a successful operation that creates/delete the node or sets
/// the data on the node.
支持(1) 反对(0) dudu | 园豆:30994 (高人七级) | 2018-05-21 18:14

@dudu: 已经解决了,是防火墙问题,还有我最开始在csdn上面下的客户端有问题,从新下了一个可以正常连接了

支持(0) 反对(0) 提伯斯 | 园豆:38 (初学一级) | 2018-05-22 09:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册