从 Zookeeper 中的 AuthenticationProvider 连接到 Zookeeper

Making connection to Zookeeper from AuthenticationProvider in Zookeeper

我正在 AuthenticationProvider 在身份验证期间连接到 Zookeeper(与 运行 相同)并检查节点是否此用户提供了正确的密码。

基本上流程看起来像这样:

@Override
public KeeperException.Code handleAuthentication(ServerCnxn cnxn, byte[] authData) {
        final String usernameColonPassword = new String(authData);
        String[] split = usernameColonPassword.split(":");
        final String username = split[0];
        final String password = split[1];

        byte[] binary = curator.getData().forPath(ATUH_NODE); // here error is thrown
        // check is password is correct
}

问题是当策展人获取数据时,我一直在排队 KeeperErrorCode = ConnectionLoss。这种行为的原因是什么?在身份验证期间,不允许我连接到正在授权客户端的 Zookeeper?

完整堆栈跟踪下方:

    org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for XXX
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:99)
        at org.apache.zookeeper.KeeperException.create(KeeperException.java:51)
        at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:1045)
        at org.apache.curator.framework.imps.ExistsBuilderImpl.call(ExistsBuilderImpl.java:172)
        at org.apache.curator.framework.imps.ExistsBuilderImpl.call(ExistsBuilderImpl.java:161)
        at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:107)
        at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:157)
        at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:148)
        at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:36)

我发现这是不可能的。此时 zookeeper 有某种 lock/semaphore 并且他不接受来自该线程的新连接。