anchor.diff:  init() ->
     application:ensure_started(inets),
     case ensure_registered() of
  -    ok    -> ensure_clustered();
  -    error -> ok
  +    {ok, DiscoveryNodes} -> ensure_clustered(DiscoveryNodes);
  +    error ->
  +      autocluster_log:info("Error in ensuring clustered"),
  +      ok
     end.
   
   
  
positive.code: %% @end
  %%
  join_cluster(Nodes) ->
    Alive = filter_dead_nodes(Nodes),
    autocluster_log:debug("Joining existing cluster: ~p", [Alive]),
    application:stop(rabbit),
    mnesia:stop(),
    rabbit_mnesia:reset(),
    rabbit_mnesia:join_cluster(lists:nth(1, Alive), disc),
    mnesia:start(),
    rabbit:start(),
    autocluster_log:info("Cluster joined"),
    ok.
  
negative.code: %% @doc Check to see if the node is already defined in a cluster, joining if required
  %% @end
  %%
  ensure_clustered(DiscoveryNodes) ->
    Discovery = sets:del_element(node(), sets:from_list(DiscoveryNodes)),
    Nodes = rabbit_mnesia:cluster_nodes(all),
    case length(Nodes) of
      1 ->
        autocluster_log:debug("Node is only node in the cluster"),
        DNodes = sets:to_list(Discovery),
        case DNodes of
          [] ->
            autocluster_log:info("Node appears to be the first in the cluster"),
            ok;
          _ ->
            join_cluster(DNodes)
        end;
      _ ->
        case lists:member(node(), Nodes) of
          true ->
            autocluster_log:info("Node is already in the cluster"),
            ok;
          false -> join_cluster(Nodes)
        end
    end.
  