use of org.apache.zookeeper.client.ConnectStringParser in project samza by apache.
the class ZkCoordinationUtilsFactory method validateZkNameSpace.
/**
* if ZkConnectString contains namespace path at the end, but it does not exist we should fail
* @param zkConnect - connect string
* @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)) {
// no namespace path
return;
}
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);
}
}
Aggregations