/*
 * Copyright 2014 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.kuujo.copycat.cluster;

import net.kuujo.copycat.spi.Protocol;

import java.util.Set;
import java.util.concurrent.CompletableFuture;

/**
 * Internal cluster manager.
 *
 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
 */
public interface ClusterManager {

  /**
   * Returns the cluster protocol.
   *
   * @return The cluster protocol.
   */
  Protocol protocol();

  /**
   * Returns the underlying cluster.
   *
   * @return The underlying cluster.
   */
  Cluster cluster();

  /**
   * Returns a set of all nodes in the cluster.
   *
   * @return A set of all nodes in the cluster.
   */
  Set<Member> nodes();

  /**
   * Returns the local cluster node.
   *
   * @return The local cluster node.
   */
  LocalMember localNode();

  /**
   * Returns a set of all remote nodes in the cluster.
   *
   * @return A set of all remote nodes in the cluster.
   */
  Set<RemoteMember> remoteNodes();

  /**
   * Polls the members of the cluster.
   *
   * @return A completable future indicating whether the local node was elected.
   */
  CompletableFuture<Boolean> poll();

  /**
   * Pings all members, performing a consistency check.
   *
   * @param index The index for which to perform the consistency check.
   * @return A completable future to be completed once a quorum of nodes have been pinged.
   */
  CompletableFuture<Long> ping(long index);

  /**
   * Commits all log entries up to the given index.
   *
   * @param index The index up to which to commit entries.
   * @return A completable future to be completed once the entries have been committed.
   */
  CompletableFuture<Long> commit(long index);

}

@@ -1136,36 +1136,38 @@
 ns a set of all 
-node
+member
 s in the cluster
@@ -1199,20 +1199,22 @@
  of all 
-node
+member
 s in the
@@ -1243,20 +1243,22 @@
 Member%3E 
-node
+member
 s();%0A%0A  
@@ -1288,28 +1288,30 @@
 cal cluster 
-node
+member
 .%0A   *%0A   * 
@@ -1336,20 +1336,22 @@
 cluster 
-node
+member
 .%0A   */%0A
@@ -1369,20 +1369,22 @@
 er local
-Node
+Member
 ();%0A%0A  /
@@ -1411,36 +1411,38 @@
 t of all remote 
-node
+member
 s in the cluster
@@ -1481,20 +1481,22 @@
  remote 
-node
+member
 s in the
@@ -1541,12 +1541,14 @@
 mote
-Node
+Member
 s();

Refactor ClusterManager interface to rename 'nodes' to 'members'