Fix warnings and javadocs in sal-akka-raft
[controller.git] / opendaylight / md-sal / sal-akka-raft / src / main / java / org / opendaylight / controller / cluster / raft / ReplicatedLog.java
index ffa4cb117231f3f603e2cd8a51db3853fd9b2fe8..2b527db174300d593126c112b6ce491b06da8235 100644 (file)
@@ -26,20 +26,28 @@ public interface ReplicatedLog {
      * @return the ReplicatedLogEntry if found, otherwise null if the adjusted index less than 0 or
      * greater than the size of the in-memory journal.
      */
-    @Nullable ReplicatedLogEntry get(long index);
+    @Nullable
+    ReplicatedLogEntry get(long index);
 
     /**
      * Return the last replicated log entry in the log or null of not found.
+     *
+     * @return the last replicated log entry in the log or null of not found.
      */
-    @Nullable ReplicatedLogEntry last();
+    @Nullable
+    ReplicatedLogEntry last();
 
     /**
      * Return the index of the last entry in the log or -1 if the log is empty.
+     *
+     * @return the index of the last entry in the log or -1 if the log is empty.
      */
     long lastIndex();
 
     /**
      * Return the term of the last entry in the log or -1 if the log is empty.
+     *
+     * @return the term of the last entry in the log or -1 if the log is empty.
      */
     long lastTerm();
 
@@ -58,15 +66,18 @@ public interface ReplicatedLog {
      * reconstruct the state of the in-memory replicated log
      *
      * @param index the index of the first log entry to remove
+     * @return
      */
-    void removeFromAndPersist(long index);
+    boolean removeFromAndPersist(long index);
 
     /**
      * Appends an entry to the log.
      *
      * @param replicatedLogEntry the entry to append
+     * @return true if the entry was successfully appended, false otherwise. An entry can fail to append if
+     *         the index is already included in the log.
      */
-    void append(ReplicatedLogEntry replicatedLogEntry);
+    boolean append(ReplicatedLogEntry replicatedLogEntry);
 
     /**
      * Optimization method to increase the capacity of the journal log prior to appending entries.
@@ -82,6 +93,12 @@ public interface ReplicatedLog {
      */
     void appendAndPersist(final ReplicatedLogEntry replicatedLogEntry);
 
+    /**
+     * Appends an entry to the in-memory log and persists it as well.
+     *
+     * @param replicatedLogEntry the entry to append
+     * @param callback the Procedure to be notified when persistence is complete.
+     */
     void appendAndPersist(ReplicatedLogEntry replicatedLogEntry, Procedure<ReplicatedLogEntry> callback);
 
     /**
@@ -179,14 +196,16 @@ public interface ReplicatedLog {
     void snapshotRollback();
 
     /**
-     * Size of the data in the log (in bytes)
+     * Returns the size of the data in the log (in bytes)
+     *
+     * @return the size of the data in the log (in bytes).
      */
     int dataSize();
 
     /**
-     * We decide if snapshot need to be captured based on the count/memory consumed.
-     * @param replicatedLogEntry
+     * Determines if a snapshot need to be captured based on the count/memory consumed.
+     *
+     * @param replicatedLogEntry the last log entry.
      */
     void captureSnapshotIfReady(ReplicatedLogEntry replicatedLogEntry);
-
 }