/*
 * 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;

/**
 * State machine executor.
 *
 * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
 */
public interface StateMachine {

  /**
   * Takes a snapshot of the state machine state.
   *
   * @return The state machine state.
   */
  default byte[] takeSnapshot() {
    return null;
  }

  /**
   * Installs a snapshot of the state machine state.
   *
   * @param snapshot A snapshot of the state machine state.
   */
  default void installSnapshot(byte[] snapshot) {
  }

}

@@ -657,342 +657,2516 @@
 ine 
-executor.%0A *%0A * @author %3Ca href=%22http://github.com/kuujo%22%3EJordan Halterman%3C/a%3E%0A */%0Apublic interface StateMachine %7B%0A%0A  /**%0A   * Takes a snapshot of the state machine state.%0A   *%0A   * @return The state machine state.%0A   */%0A  default byte%5B%5D takeSnapshot() %7B%0A    return null;%0A  %7D%0A%0A  /**%0A   * Installs a snapshot of the state machine state
+identifier interface.%3Cp%3E%0A *%0A * Users must implement this interface in order to provide a state machine implementation to a%0A * Copycat cluster. Because Copycat guarantees deterministic state, state machine implementations%0A * must be deterministic, meaning given the same set of commands in the same order, the state%0A * machine should always arrive at the same state with the same output.%3Cp%3E%0A *%0A * Copycat calls methods on the state machine implementation based on submissions to the Copycat%0A * cluster. Copycat supports two different types of operations - commands and queries - and while%0A * Copycat handles their behavior internally, there are some requirements of implementing each%0A * operation type.%3Cp%3E%0A *%0A * Commands are methods that alter the state machine's state. Commands are annotated with the%0A * %7B@link net.kuujo.copycat.Command%7D annotation. Command submissions will  always be forwarded%0A * through the cluster leader and replicated before being applied to the state machine.%3Cp%3E%0A *%0A * Queries are methods that do not alter the state machine's tate. Queries are annotated with%0A * the %7B@link net.kuujo.copycat.Query%7D annotation. Query submissions do not have to be logged%0A * or replicated and can optionally be performed on follower nodes.%3Cp%3E%0A *%0A * All state machine implementations support snapshotting. Snapshot support methods are default%0A * methods of the %7B@code StateMachine%7D interface. To implement snapshot support, simply override%0A * the %7B@link StateMachine#takeSnapshot()%7D and %7B@link StateMachine#installSnapshot(byte%5B%5D)%7D methods.%0A *%0A * @author %3Ca href=%22http://github.com/kuujo%22%3EJordan Halterman%3C/a%3E%0A */%0Apublic interface StateMachine %7B%0A%0A  /**%0A   * Takes a snapshot of the state machine state.%3Cp%3E%0A   *%0A   * This method should be overridden by state machine implementations to provide a snapshot of the%0A   * state machine state. When the replicated log grows too large, Copycat will take a snapshot of%0A   * the state machine, persist the snapshot, and wipe old entries from the log.%0A   *%0A   * @return The state machine state.%0A   */%0A  default byte%5B%5D takeSnapshot() %7B%0A    return null;%0A  %7D%0A%0A  /**%0A   * Installs a snapshot of the state machine state.%3Cp%3E%0A   *%0A   * This method should be overridden by state machine implementations to provide snapshot support.%0A   * When a Copycat replica recovers from failure, it may use the snapshot to recover lost state%0A   * prior to replaying its log. Similarly, the snapshot may be used to replicate state to followers%0A   * that have fallen too far out of sync
 .%0A  

Add StateMachine documentation.