@Test(expected = IllegalStateException.class) public void testInitializedNotCalledAdvertise() throws Exception { ZooAuthenticationKeyDistributor distributor = new ZooAuthenticationKeyDistributor(zrw, baseNode); distributor.advertise(new AuthenticationKey(1, 0L, 5L, keyGen.generateKey())); }
public synchronized void advertise(AuthenticationKey newKey) throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); requireNonNull(newKey); String path = qualifyPath(newKey); if (zk.exists(path)) { log.warn("AuthenticationKey with ID '{}' already exists in ZooKeeper", newKey.getKeyId()); return; } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); try { newKey.write(new DataOutputStream(baos)); } catch (IOException e) { throw new AssertionError("Should not get exception writing to in-memory buffer", e); } byte[] serializedKey = baos.toByteArray(); log.debug("Advertising AuthenticationKey with keyId {} in ZooKeeper at {}", newKey.getKeyId(), path); zk.putPrivatePersistentData(path, serializedKey, NodeExistsPolicy.FAIL); }
ZooAuthenticationKeyDistributor { public synchronized void advertise(AuthenticationKey newKey) throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); requireNonNull(newKey); String path = qualifyPath(newKey); if (zk.exists(path)) { log.warn("AuthenticationKey with ID '{}' already exists in ZooKeeper", newKey.getKeyId()); return; } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); try { newKey.write(new DataOutputStream(baos)); } catch (IOException e) { throw new AssertionError("Should not get exception writing to in-memory buffer", e); } byte[] serializedKey = baos.toByteArray(); log.debug("Advertising AuthenticationKey with keyId {} in ZooKeeper at {}", newKey.getKeyId(), path); zk.putPrivatePersistentData(path, serializedKey, NodeExistsPolicy.FAIL); } }
ZooAuthenticationKeyDistributor { public synchronized void advertise(AuthenticationKey newKey) throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); requireNonNull(newKey); String path = qualifyPath(newKey); if (zk.exists(path)) { log.warn("AuthenticationKey with ID '{}' already exists in ZooKeeper", newKey.getKeyId()); return; } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); try { newKey.write(new DataOutputStream(baos)); } catch (IOException e) { throw new AssertionError("Should not get exception writing to in-memory buffer", e); } byte[] serializedKey = baos.toByteArray(); log.debug("Advertising AuthenticationKey with keyId {} in ZooKeeper at {}", newKey.getKeyId(), path); zk.putPrivatePersistentData(path, serializedKey, NodeExistsPolicy.FAIL); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); }
ZooAuthenticationKeyDistributor { public synchronized void advertise(AuthenticationKey newKey) throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); requireNonNull(newKey); String path = qualifyPath(newKey); if (zk.exists(path)) { log.warn("AuthenticationKey with ID '{}' already exists in ZooKeeper", newKey.getKeyId()); return; } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); try { newKey.write(new DataOutputStream(baos)); } catch (IOException e) { throw new AssertionError("Should not get exception writing to in-memory buffer", e); } byte[] serializedKey = baos.toByteArray(); log.debug("Advertising AuthenticationKey with keyId {} in ZooKeeper at {}", newKey.getKeyId(), path); zk.putPrivatePersistentData(path, serializedKey, NodeExistsPolicy.FAIL); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key); }
ZooAuthenticationKeyDistributor { public synchronized void advertise(AuthenticationKey newKey) throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); requireNonNull(newKey); String path = qualifyPath(newKey); if (zk.exists(path)) { log.warn("AuthenticationKey with ID '{}' already exists in ZooKeeper", newKey.getKeyId()); return; } ByteArrayOutputStream baos = new ByteArrayOutputStream(4096); try { newKey.write(new DataOutputStream(baos)); } catch (IOException e) { throw new AssertionError("Should not get exception writing to in-memory buffer", e); } byte[] serializedKey = baos.toByteArray(); log.debug("Advertising AuthenticationKey with keyId {} in ZooKeeper at {}", newKey.getKeyId(), path); zk.putPrivatePersistentData(path, serializedKey, NodeExistsPolicy.FAIL); } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key);  }