@Test
  public void testLatchExpires() {
    final String latchId = "testLatchExpires";
    final int latchSize = 3;

    Latch latch = new ZkProcessorLatch(latchSize, latchId, "test", testZkUtils);
    try {
      latch.countDown();
      latch.await(5, TimeUnit.SECONDS);
    } catch (TimeoutException e) {
      // expected
    } catch (Exception e) {
      Assert.fail(String.format("Expected only TimeoutException! Received %s", e));
    }

  }
The ZkProcessorLatch uses a shared Znode as a latch. Each participant await existence of a target znode under the
shared latch, which is a persistent, sequential target znode with value (latchSize - 1). latchSize is the minimum
number of participants that need to join the latch.
samza-core/src/test/java/org/apache/samza/zk/TestZkProcessorLatch.java