@Override
  public void start(Collection<? extends Location> locations) {
    super.start(locations);
    connectSensors();

    Time.sleep(getConfig(DELAY_BEFORE_ADVERTISING_CLUSTER));

    // FIXME: add a quorum to tolerate failed nodes before setting on fire.
    Optional<Entity> anyNode =
        Iterables.tryFind(
            getMembers(),
            new Predicate<Entity>() {

              @Override
              public boolean apply(@Nullable Entity entity) {
                return (entity instanceof RiakNode
                    && hasMemberJoinedCluster(entity)
                    && entity.getAttribute(RiakNode.SERVICE_UP));
              }
            });

    if (anyNode.isPresent()) {
      log.info(
          "Planning and Committing cluster changes on node: {}, cluster: {}",
          anyNode.get().getId(),
          getId());
      Entities.invokeEffector(this, anyNode.get(), RiakNode.COMMIT_RIAK_CLUSTER);
      setAttribute(IS_CLUSTER_INIT, true);
    } else {
      log.warn("No Riak Nodes are found on the cluster: {}. Initialization Failed", getId());
      setAttribute(SERVICE_STATE, Lifecycle.ON_FIRE);
    }
  }
  @Test
  public void testCancelled() throws InterruptedException, ExecutionException {
    Task<List<?>> t =
        Tasks.sequential(sayTask("1"), sayTask("2a", Duration.THIRTY_SECONDS, "2b"), sayTask("3"));
    ec.submit(t);
    synchronized (messages) {
      while (messages.size() <= 1) messages.wait();
    }
    Assert.assertEquals(messages, Arrays.asList("1", "2a"));
    Time.sleep(Duration.millis(50));
    t.cancel(true);
    Assert.assertTrue(t.isDone());
    // 2 should get cancelled, and invoke the cancellation semaphore
    // 3 should get cancelled and not run at all
    Assert.assertEquals(messages, Arrays.asList("1", "2a"));

    // Need to ensure that 2 has been started; race where we might cancel it before its run method
    // is even begun. Hence doing "2a; pause; 2b" where nothing is interruptable before pause.
    Assert.assertTrue(cancellations.tryAcquire(10, TimeUnit.SECONDS));

    Iterator<Task<?>> ci = ((HasTaskChildren) t).getChildren().iterator();
    Assert.assertEquals(ci.next().get(), "1");
    Task<?> task2 = ci.next();
    Assert.assertTrue(task2.isBegun());
    Assert.assertTrue(task2.isDone());
    Assert.assertTrue(task2.isCancelled());

    Task<?> task3 = ci.next();
    Assert.assertFalse(task3.isBegun());
    Assert.assertTrue(task2.isDone());
    Assert.assertTrue(task2.isCancelled());

    // but we do _not_ get a mutex from task3 as it does not run (is not interrupted)
    Assert.assertEquals(cancellations.availablePermits(), 0);
  }