private static HostProvider createDefaultHostProvider(String connectString) { return new StaticHostProvider( new ConnectStringParser(connectString).getServerAddresses()); }
private byte[] createSaslToken() throws SaslException { saslState = SaslState.INTERMEDIATE; return createSaslToken(saslToken); }
/** * Send the 4letterword * @param host the destination host * @param port the destination port * @param cmd the 4letterword * @return server response * @throws java.io.IOException * @throws SSLContextException */ public static String send4LetterWord(String host, int port, String cmd) throws IOException, SSLContextException { return send4LetterWord(host, port, cmd, false, DEFAULT_SOCKET_TIMEOUT); }
@Test public void testSingleServerChrootPath(){ String chrootPath = "/hallo/welt"; String servers = "10.10.10.1"; assertChrootPath(chrootPath, new ConnectStringParser(servers+chrootPath)); servers = "[2001:db8:1::242:ac11:2]"; assertChrootPath(chrootPath, new ConnectStringParser(servers+chrootPath)); }
private void assertChrootPath(String expected, ConnectStringParser parser){ Assert.assertEquals(expected, parser.getChrootPath()); } }
public boolean tunnelAuthInProgress() { // 1. SASL client is disabled. if (!clientConfig.isSaslClientEnabled()) { return false; } // 2. SASL login failed. if (saslLoginFailed == true) { return false; } // 3. SendThread has not created the authenticating object yet, // therefore authentication is (at the earliest stage of being) in progress. if (zooKeeperSaslClient == null) { return true; } // 4. authenticating object exists, so ask it for its progress. return zooKeeperSaslClient.clientTunneledAuthenticationInProgress(); }
public synchronized InetSocketAddress getServerAtCurrentIndex() { return getServerAtIndex(currentIndex); }
/** * Constructs a SimpleHostSet. This constructor is used from StaticHostProviderTest to produce deterministic test results * by initializing sourceOfRandomness with the same seed * * @param serverAddresses * possibly unresolved ZooKeeper server addresses * @param randomnessSeed a seed used to initialize sourceOfRandomnes * @throws IllegalArgumentException * if serverAddresses is empty or resolves to an empty list */ public StaticHostProvider(Collection<InetSocketAddress> serverAddresses, long randomnessSeed) { init(serverAddresses, randomnessSeed, new Resolver() { @Override public InetAddress[] getAllByName(String name) throws UnknownHostException { return InetAddress.getAllByName(name); } }); }
private void logStartConnect(InetSocketAddress addr) { String msg = "Opening socket connection to server " + addr; if (zooKeeperSaslClient != null) { msg += ". " + zooKeeperSaslClient.getConfigStatus(); } LOG.info(msg); }
/** * Initialize all the ZooKeeper client properties which are configurable as * java system property */ private void initFromJavaSystemProperties() { setProperty(ZOOKEEPER_REQUEST_TIMEOUT, System.getProperty(ZOOKEEPER_REQUEST_TIMEOUT)); }
/** * Returns true if the SASL client is enabled. By default, the client is * enabled but can be disabled by setting the system property * <code>zookeeper.sasl.client</code> to <code>false</code>. See * ZOOKEEPER-1657 for more information. * * @return true if the SASL client is enabled. */ public boolean isSaslClientEnabled() { return Boolean.valueOf(getProperty(ENABLE_CLIENT_SASL_KEY, ENABLE_CLIENT_SASL_DEFAULT)); }
MockCnxn() throws IOException { super(new ZKClientConfig()); }
public ZKClientConfig() { super(); initFromJavaSystemProperties(); }
@Test public void testMultipleServersChrootPath(){ String chrootPath = "/hallo/welt"; String servers = "10.10.10.1,10.10.10.2"; assertChrootPath(chrootPath, new ConnectStringParser(servers+chrootPath)); servers = "[2001:db8:1::242:ac11:2]:2181,[2001:db8:85a3:8d3:1319:8a2e:370:7348]:5678"; assertChrootPath(chrootPath, new ConnectStringParser(servers+chrootPath)); }
/** * Send the 4letterword * @param host the destination host * @param port the destination port * @param cmd the 4letterword * @param secure whether to use SSL * @return server response * @throws java.io.IOException * @throws SSLContextException */ public static String send4LetterWord(String host, int port, String cmd, boolean secure) throws IOException, SSLContextException { return send4LetterWord(host, port, cmd, secure, DEFAULT_SOCKET_TIMEOUT); }
private byte[] createSaslToken() throws SaslException { saslState = SaslState.INTERMEDIATE; return createSaslToken(saslToken); }
/** * Send the 4letterword * @param host the destination host * @param port the destination port * @param cmd the 4letterword * @return server response * @throws java.io.IOException */ public static String send4LetterWord(String host, int port, String cmd) throws IOException { return send4LetterWord(host, port, cmd, DEFAULT_SOCKET_TIMEOUT); } /**
private String sendRequest(String cmd) throws IOException, SSLContextException { return send4LetterWord(HOST, PORT, cmd); }
private String sendRequest(String cmd) throws IOException, SSLContextException { HostPort hpobj = ClientBase.parseHostPortList(hostPort).get(0); return send4LetterWord(hpobj.host, hpobj.port, cmd); } private String sendRequest(String cmd, int timeout) throws IOException, SSLContextException {
private String sendRequest(String cmd, int timeout) throws IOException, SSLContextException { HostPort hpobj = ClientBase.parseHostPortList(hostPort).get(0); return send4LetterWord(hpobj.host, hpobj.port, cmd, false, timeout); }