private void assertChrootPath(String expected, ConnectStringParser parser){ Assert.assertEquals(expected, parser.getChrootPath()); } }
hostProvider = aHostProvider; cnxn = new ClientCnxn(connectStringParser.getChrootPath(), hostProvider, sessionTimeout, this, watchManager, getClientCnxnSocket(), sessionId, sessionPasswd, canBeReadOnly);
hostProvider = aHostProvider; cnxn = createConnection(connectStringParser.getChrootPath(), hostProvider, sessionTimeout, this, watchManager, getClientCnxnSocket(), canBeReadOnly);
HostProvider hostProvider = new StaticHostProvider( connectStringParser.getServerAddresses()); cnxn = new ClientCnxn(connectStringParser.getChrootPath(), hostProvider, sessionTimeout, this, watchManager, getClientCnxnSocket(), sessionId, sessionPasswd, canBeReadOnly);
HostProvider hostProvider = new StaticHostProvider( connectStringParser.getServerAddresses()); cnxn = new ClientCnxn(connectStringParser.getChrootPath(), hostProvider, sessionTimeout, this, watchManager, getClientCnxnSocket(), canBeReadOnly);
@Override public String getConnectionString() { StringBuilder connectStringBuilder = new StringBuilder(); SortedSet<String> addresses = new TreeSet<>(); for (InetSocketAddress hostAndPort : _connectStringParser.getServerAddresses()) { try { for (InetAddress address : _resolver.lookupAllHostAddr(hostAndPort.getHostName())) { addresses.add(HostAndPort.fromParts(address.getHostAddress(), hostAndPort.getPort()).toString()); } } catch (UnknownHostException e) { // Leave unresolvable host in connect string as-is. addresses.add(hostAndPort.toString()); } } Joiner.on(',').appendTo(connectStringBuilder, addresses); if (_connectStringParser.getChrootPath() != null) { connectStringBuilder.append(_connectStringParser.getChrootPath()); } return connectStringBuilder.toString(); }
/** * 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)) { 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); } } }
/** * 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)) { 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); } } }
/** * 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)) { 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); } } }
/** * 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)) { 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); } } }
/** * 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)) { 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); } } }