3

ubuntu vmで実行されているZookeeper v3.3.3 + dfsg2-1ubuntu1を使用しています。(VM は NAT ネットワーク接続で実行されています)

私の開発マシン (windows 7) で実行するzkCli.cmd -server 10.10.135.19:2181と、正常に接続されcreate、s、gets などを実行できます。

Org.Apache.ZooKeeper v1.0.0.0 に NuGet 依存関係を持つ C# 4 アプリケーションがあります。

私は次の方法でそれを使用しています:

  class watcher : IWatcher
  {
     private readonly ManualResetEventSlim _connected = new ManualResetEventSlim(false);
     private WatchedEvent _event;

     public void WaitUntilConnected()
     {
        _connected.Wait();

        if (_event == null) throw new ApplicationException("bad state");
        if (_event.State != KeeperState.SyncConnected)
           throw new ApplicationException("cannot connect");
     }

     public void Process(WatchedEvent @event)
     {
        _event = @event;
        _connected.Set();
     }
  }

  ...

  public void TestZooKeeper()
  {
     _countdownWatcher = new watcher();
     _zk = new ZooKeeper(
        Settings.Default.ZookeeperConnectionString, // 10.10.135.19:2181
        new TimeSpan(Settings.Default.ZookeeperConnectionTimeout), // 10000
        _countdownWatcher);
     _countdownWatcher.WaitUntilConnected();
  }

問題は、これがハングすることです。Zookeeper のログには、次のように表示されます。

2012-04-05 08:12:21,376 - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket         connection from /10.0.2.2:51057
2012-04-05 08:12:21,379 - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@777] - Client attempting to establish new session at /10.0.2.2:51057
2012-04-05 08:12:21,383 - INFO  [SyncThread:0:NIOServerCnxn@1580] - Established session 0x1367c91bf580047 with negotiated timeout 4000 for client /10.0.2.2:51057
2012-04-05 08:12:22,500 - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn$Factory@251] - Accepted socket connection from /10.0.2.2:51059
2012-04-05 08:12:22,502 - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@777] - Client attempting to establish new session at /10.0.2.2:51059
2012-04-05 08:12:22,505 - INFO  [SyncThread:0:NIOServerCnxn@1580] - Established session 0x1367c91bf580048 with negotiated timeout 4000 for client /10.0.2.2:51059
2012-04-05 08:12:26,000 - INFO  [SessionTracker:ZooKeeperServer@314] - Expiring session 0x1367c91bf580047, timeout of 4000ms exceeded
2012-04-05 08:12:26,001 - INFO  [ProcessThread:-1:PrepRequestProcessor@387] - Processed session termination for sessionid: 0x1367c91bf580047
2012-04-05 08:12:26,004 - INFO  [SyncThread:0:NIOServerCnxn@1435] - Closed socket connection for client /10.0.2.2:51057 which had sessionid 0x1367c91bf580047
2012-04-05 08:12:28,001 - INFO  [SessionTracker:ZooKeeperServer@314] - Expiring session 0x1367c91bf580048, timeout of 4000ms exceeded
2012-04-05 08:12:28,002 - INFO  [ProcessThread:-1:PrepRequestProcessor@387] - Processed session termination for sessionid: 0x1367c91bf580048
2012-04-05 08:12:28,004 - INFO  [SyncThread:0:NIOServerCnxn@1435] - Closed socket connection for client /10.0.2.2:51059 which had sessionid 0x1367c91bf580048

そして、これは手動でプロセスを強制終了するまで続きます。つまり、WaitUntilConnected()メソッドは決して戻りません。(デバッグで確認済み)

クライアント接続がサーバーに正常に到達したように見えますが、Watcher はこれを認識せず、そのチャネルでそれ以上何も起こらず、クライアントが再試行するためだけにサーバーが接続を切断します。ここで私が間違っていることはありますか?

4

1 に答える 1

6

ZooKeeper の C# クライアント ライブラリの標準バージョンはhttps://github.com/ExactTargetDev/zookeeper/tree/et-developにあり、ZooKeeper wiki が指すものとは異なります。

  • ソースを github から取得してビルドします。必ずet-developブランチを取得してください。
  • ant最上位で実行中 (これにより が呼び出さjuteれ、C# プロジェクトで使用される RPC クラスが生成されます)
  • src/dotnetフォルダーとそこにあるソリューションを開き、
  • それを構築する

ローカルの ZooKeeper に接続する単体テストを実行したところ、正常に実行されました。

于 2012-05-03T08:26:43.297 に答える