@Test(expected = IllegalStateException.class) public void testInitializedNotCalledCurrentKeys() throws Exception { ZooAuthenticationKeyDistributor distributor = new ZooAuthenticationKeyDistributor(zrw, baseNode); distributor.getCurrentKeys(); }
public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; }
ZooAuthenticationKeyDistributor { public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; } }
ZooAuthenticationKeyDistributor { public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); }
ZooAuthenticationKeyDistributor { public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key); }
ZooAuthenticationKeyDistributor { public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key);  }