Do not use BufferOverflowException for EOF signalling
[controller.git] / atomix-storage / src / main / java / io / atomix / storage / journal / JournalWriter.java
index b8acf1e5937f2194c4485e23e2845e3244742aea..1462463e9d68c8049f68f85ea34fdfbb4734144a 100644 (file)
  */
 package io.atomix.storage.journal;
 
+import org.eclipse.jdt.annotation.NonNull;
+
 /**
  * Log writer.
  *
  * @author <a href="http://github.com/kuujo">Jordan Halterman</a>
  */
 public interface JournalWriter<E> {
-  /**
-   * Returns the last written index.
-   *
-   * @return The last written index.
-   */
-  long getLastIndex();
+    /**
+     * Returns the last written index.
+     *
+     * @return The last written index.
+     */
+    long getLastIndex();
 
-  /**
-   * Returns the last entry written.
-   *
-   * @return The last entry written.
-   */
-  Indexed<E> getLastEntry();
+    /**
+     * Returns the last entry written.
+     *
+     * @return The last entry written.
+     */
+    Indexed<E> getLastEntry();
 
-  /**
-   * Returns the next index to be written.
-   *
-   * @return The next index to be written.
-   */
-  long getNextIndex();
+    /**
+     * Returns the next index to be written.
+     *
+     * @return The next index to be written.
+     */
+    long getNextIndex();
 
-  /**
-   * Appends an entry to the journal.
-   *
-   * @param entry The entry to append.
-   * @return The appended indexed entry.
-   */
-  <T extends E> Indexed<T> append(T entry);
+    /**
+     * Appends an entry to the journal.
+     *
+     * @param entry The entry to append.
+     * @return The appended indexed entry.
+     */
+    <T extends E> @NonNull Indexed<T> append(T entry);
 
-  /**
-   * Commits entries up to the given index.
-   *
-   * @param index The index up to which to commit entries.
-   */
-  void commit(long index);
+    /**
+     * Commits entries up to the given index.
+     *
+     * @param index The index up to which to commit entries.
+     */
+    void commit(long index);
 
-  /**
-   * Resets the head of the journal to the given index.
-   *
-   * @param index the index to which to reset the head of the journal
-   */
-  void reset(long index);
+    /**
+     * Resets the head of the journal to the given index.
+     *
+     * @param index the index to which to reset the head of the journal
+     */
+    void reset(long index);
 
-  /**
-   * Truncates the log to the given index.
-   *
-   * @param index The index to which to truncate the log.
-   */
-  void truncate(long index);
+    /**
+     * Truncates the log to the given index.
+     *
+     * @param index The index to which to truncate the log.
+     */
+    void truncate(long index);
 
-  /**
-   * Flushes written entries to disk.
-   */
-  void flush();
+    /**
+     * Flushes written entries to disk.
+     */
+    void flush();
 }