@Test public void testCredentials() throws Exception { String path = "/test"; ZooKeeperClient authenticatedClient = createZkClient("creator", "creator"); assertEquals(path, authenticatedClient.get().create(path, "42".getBytes(), ZooKeeperUtils.EVERYONE_READ_CREATOR_ALL, CreateMode.PERSISTENT)); ZooKeeperClient unauthenticatedClient = createZkClient(); assertEquals("42", getData(unauthenticatedClient, path)); try { setData(unauthenticatedClient, path, "37"); fail("Expected unauthenticated write attempt to fail"); } catch (NoAuthException e) { assertEquals("42", getData(unauthenticatedClient, path)); } ZooKeeperClient nonOwnerClient = createZkClient("nonowner", "nonowner"); assertEquals("42", getData(nonOwnerClient, path)); try { setData(nonOwnerClient, path, "37"); fail("Expected non owner write attempt to fail"); } catch (NoAuthException e) { assertEquals("42", getData(nonOwnerClient, path)); } ZooKeeperClient authenticatedClient2 = createZkClient("creator", "creator"); setData(authenticatedClient2, path, "37"); assertEquals("37", getData(authenticatedClient2, path)); }
public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } }
ZooKeeperClient { public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } } }
ZooKeeperClient { public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } } ZooKeeperClient(Amount<Integer, Time> sessionTimeout, InetSocketAddress zooKeeperServer,
      InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      InetSocketAddress zooKeeperServer, InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Optional<Credentials> credentials,
      Optional<String> chrootPath, Iterable<InetSocketAddress> zooKeeperServers); }
ZooKeeperClient { public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } } ZooKeeperClient(Amount<Integer, Time> sessionTimeout, InetSocketAddress zooKeeperServer,
      InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      InetSocketAddress zooKeeperServer, InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Optional<Credentials> credentials,
      Optional<String> chrootPath, Iterable<InetSocketAddress> zooKeeperServers); synchronized ZooKeeper get(); synchronized ZooKeeper get(Amount<Long, Time> connectionTimeout); Watcher registerExpirationHandler(final Command onExpired); void register(Watcher watcher); boolean unregister(Watcher watcher); boolean shouldRetry(KeeperException e); synchronized void close(); }
ZooKeeperClient { public synchronized ZooKeeper get() throws ZooKeeperConnectionException, InterruptedException { try { return get(WAIT_FOREVER); } catch (TimeoutException e) { InterruptedException interruptedException = new InterruptedException("Got an unexpected TimeoutException for 0 wait"); interruptedException.initCause(e); throw interruptedException; } } ZooKeeperClient(Amount<Integer, Time> sessionTimeout, InetSocketAddress zooKeeperServer,
      InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      InetSocketAddress zooKeeperServer, InetSocketAddress... zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Credentials credentials,
      Iterable<InetSocketAddress> zooKeeperServers);  ZooKeeperClient(Amount<Integer, Time> sessionTimeout, Optional<Credentials> credentials,
      Optional<String> chrootPath, Iterable<InetSocketAddress> zooKeeperServers); synchronized ZooKeeper get(); synchronized ZooKeeper get(Amount<Long, Time> connectionTimeout); Watcher registerExpirationHandler(final Command onExpired); void register(Watcher watcher); boolean unregister(Watcher watcher); boolean shouldRetry(KeeperException e); synchronized void close();  }