简体   繁体   English

Zookeeper Java用户名密码

[英]Zookeeper java username password

My Zookeeper instance is running on a server host:port 我的Zookeeper实例在服务器主机上运行:端口

If I want to access it via web browser I first have to login via username/password and then only able to access my Zookeeper instance. 如果要通过Web浏览器访问它,我首先必须通过用户名/密码登录,然后只能访问我的Zookeeper实例。

However in java, when I try this: 但是在Java中,当我尝试这样做时:

    String hostPort = "host:port";
    System.out.println("Trying to connect");
    ZooKeeper zk = new ZooKeeper(hostPort, 3000, this);
    String data = "some byte data";
    try {
        zk.create("/a/b", data.getBytes(), null, CreateMode.PERSISTENT);
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }

I get the following output: 我得到以下输出:

Trying to connect
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
KeeperErrorCode = ConnectionLoss for /a/b

I am sure that it is because I am not able to provide username/password for server authentication. 我确定这是因为我无法提供服务器验证的用户名/密码。 How can I achieve what I want to in java? 如何在Java中实现我想要的?

There was no server authentication required. 不需要服务器身份验证。 In fact I was connecting via incorrect interface which needed authentication. 实际上,我是通过不正确的接口连接的,需要身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM