anchor.diff:    ok.
   
   
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Filter the list of nodes specified by the backend and ensure that
  +%% this node can communicate with them.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec filter_dead_nodes([node()]) -> list().
  -%% @private
  -%% @doc Filter the list of nodes specified by the backend and ensure that
  -%%      this node can communicate with them.
  -%% @end
  -%%
   filter_dead_nodes(Nodes) ->
     lists:filter(fun(N) -> net_adm:ping(N) =:= pong end, Nodes).
   
  +
   %% Startup Failure Methods
   
  +
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Lookup the configuration value for autocluster failures, returning
  +%% the appropriate value to have the application startup pass or fail.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec startup_failure() -> ok | error.
  -%% @private
  -%% @doc Lookup the configuration value for autocluster failures, returning
  -%%      the appropriate value to have the application startup pass or fail.
  -%% @end
  -%%
   startup_failure() ->
     startup_failure_result(autocluster_config:get(autocluster_failure)).
   
  +
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Evaluate the configuration value for autocluster failures and
  +%% return the appropriate value to have the application startup pass
  +%% or fail.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec startup_failure_result(atom()) -> ok | error.
  -%% @private
  -%% @doc Evaluate the configuration value for autocluster failures and
  -%%      return the appropriate value to have the application startup pass or
  -%%      fail.
  -%% @end
  -%%
   startup_failure_result(stop) -> error;
   startup_failure_result(ignore) -> ok;
   startup_failure_result(Value) ->
     autocluster_log:error("Invalid startup failure setting: ~p~n", [Value]),
     ok.
   
  +
   %% Startup Delay Methods
   
  +
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Get the configuration for the maximum startup delay in seconds and
  +%% then sleep a random amount.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec maybe_delay_startup() -> ok.
  -%% @private
  -%% @doc Get the configuration for the maximum startup delay in seconds and then
  -%%      sleep a random amount.
  -%% @end
  -%%
   maybe_delay_startup() ->
     startup_delay(autocluster_config:get(startup_delay) * 1000).
   
   
  +%%--------------------------------------------------------------------
  +%% @private
  +%% @doc
  +%% Sleep a random number of seconds determined between 0 and the
  +%% maximum value specified.
  +%% @end
  +%%--------------------------------------------------------------------
   -spec startup_delay(integer()) -> ok.
  -%% @private
  -%% @doc Sleep a random number of seconds determined between 0 and the maximum
  -%%      value specified.
  -%% @end
  -%%
   startup_delay(0) -> ok;
   startup_delay(Max) ->
     <<A:32, B:32, C:32>> = crypto:rand_bytes(12),
  
positive.code:   maybe_join_existing_cluster(lists:member(node(), Nodes), Nodes).
  
  
  -spec maybe_join_discovery_nodes([node()]) -> ok | error.
  %% @doc Step 10: If there are discovery nodes to cluster with, have the node
  %%      join the cluster.
  %% @end
  %%
  maybe_join_discovery_nodes([]) ->
    autocluster_log:debug("No other nodes are registed with service discovery."),
    ok;
  maybe_join_discovery_nodes(Nodes) ->
    join_cluster(Nodes).
  
  
  -spec maybe_join_existing_cluster(true | false, [node()]) -> ok | error.
  %% @doc Step 11: Evaluate the check to see if the node is already in the cluster
  %%      info returned by RabbitMQ and if not, join the cluster.
  %% @end
  %%
  maybe_join_existing_cluster(true, _) ->
    autocluster_log:debug("Node is already in the cluster"),
    ok;
  maybe_join_existing_cluster(false, Nodes) ->
    join_cluster(Nodes).
  
  
  -spec join_cluster([node()]) -> ok | error.
  %% @private
  %% @doc Step 12: Filter any nodes that this node can not communicate with and
  %%      pass the list on to Step 13.
  %% @end
  %%
  join_cluster(Nodes) ->
    join_cluster_nodes(filter_dead_nodes(Nodes)).
  
  
  -spec join_cluster_nodes([node()]) -> ok | error.
  %% @private
  %% @doc Step 13: Join the node to the existing nodes in the cluster unless there
  %%      are no nodes that it could not commuicate with.
  %% @end
  %%
  join_cluster_nodes([]) ->
    autocluster_log:warning("Can not communicate with cluster nodes."),
    startup_failure();
  join_cluster_nodes(Nodes) ->
    autocluster_log:debug("Joining the cluster."),
    application:stop(rabbit),
  
negative.code:   maybe_register(Nodes, Name, Module).
  
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Step 4: evaluate the node list to determine if the node should be
  %% registered, passing the info off to step five if so.
  %% @end
  %%--------------------------------------------------------------------
  -spec maybe_register({ok, [node()]} | {error, atom()},
    Name :: atom(),
    Module :: module()) -> ok | error.
  maybe_register({ok, Nodes}, Name, Module) ->
    maybe_register_non_member_node(lists:member(node(), Nodes),
                                   Name, Module, Nodes);
  maybe_register({error, Reason}, _, Module) ->
    autocluster_log:error("Could not fetch node list from ~p: ~p.",
                          [Module, Reason]),
    error.
  
  
  %%--------------------------------------------------------------------
  %% @private
  %% @doc
  %% Step 5: If the node is already registered, move on to the next
  %% phase, if not, register it with the backend passing the response
  %% to step six.
  %% @end
  %%--------------------------------------------------------------------
  -spec maybe_register_non_member_node(true | false,
    Name :: atom(),
    Module :: module(),
    Nodes :: [node()]) -> ok | error.
  maybe_register_non_member_node(true, _, _, Nodes) ->
    {ok, Nodes};
  maybe_register_non_member_node(false, Name, Module, Nodes) ->
  