package com.atlassian.stash.internal.cluster;

import javax.annotation.Nonnull;
import java.io.IOException;

/**
 * Manages the initial establishment of connections between nodes in the cluster
 *
 * @see com.atlassian.stash.internal.hazelcast.ClusterJoinSocketInterceptor
 * @since 3.3
 */
public interface ClusterJoinManager {
    /**
     * Validate a joining node for the cluster the current node is a part of
     *
     * @param request the join request
     * @throws IOException if the join negotiation failed, or a communication breakdown occurs
     */
    void accept(@Nonnull ClusterJoinRequest request) throws IOException;

    /**
     * Attempt to join an existing cluster
     *
     * @param request the join request
     * @throws IOException if the join negotiation failed, or a communication breakdown occurs
     */
    void connect(@Nonnull ClusterJoinRequest request) throws IOException;
}
