Example usage for org.apache.zookeeper.client ConnectStringParser getChrootPath

List of usage examples for org.apache.zookeeper.client ConnectStringParser getChrootPath

Introduction

In this page you can find the example usage for org.apache.zookeeper.client ConnectStringParser getChrootPath.

Prototype

public String getChrootPath() 

Source Link

Usage

From source file:org.apache.samza.zk.ZkCoordinationServiceFactory.java

License:Apache License

/**
 * if ZkConnectString contains namespace path at the end, but it does not exist we should fail
 * @param zkConnect - connect string//  w ww. j  a va  2  s. c o  m
 * @param zkClient - zkClient object to talk to the ZK
 */
public static void validateZkNameSpace(String zkConnect, ZkClient zkClient) {
    ConnectStringParser parser = new ConnectStringParser(zkConnect);

    String path = parser.getChrootPath();
    if (Strings.isNullOrEmpty(path)) {
        return; // no namespace path
    }

    LOG.info("connectString = " + zkConnect + "; path =" + path);

    // if namespace specified (path above) but "/" does not exists, we will fail
    if (!zkClient.exists("/")) {
        throw new SamzaException("Zookeeper namespace: " + path + " does not exist for zk at " + zkConnect);
    }
}