@Override
  public void prepare() {
    boolean isCollectorSealed = collectorSealed.compareAndSet(true, false);
    checkState(
        isCollectorSealed,
        "Failed to prepare the collector. Collector needs to be sealed before prepare() is invoked.");
  }
@Test
  public void testMultiplePrepareCallsWithoutFinishThrowsException() {
    futureCollector.prepare();

    try {
      futureCollector.prepare();
      Assert.fail("Second invocation of prepare should throw IllegalStateException");
    } catch (IllegalStateException ex) {
    }
  }