class StateMachineLog[A] extends DelegateLog[A]

Invokes a function when log entries are committed

Linear Supertypes
DelegateLog[A], RaftLog[A], RaftLogOps[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. StateMachineLog
  2. DelegateLog
  3. RaftLog
  4. RaftLogOps
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StateMachineLog(underlying: RaftLog[A], onCommitted: (LogEntry[A]) ⇒ Unit)

    underlying

    the wrapped RaftLog

    onCommitted

    the side-effectful state-machine function

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def append(coords: LogCoords, data: A, theRest: A*)(implicit classTag: ClassTag[A]): LogAppendResult

    Append the given log entry w/ the given coords (term and index)

    Append the given log entry w/ the given coords (term and index)

    coords

    the log term and index against which this log should be appended

    returns

    the append result

    Definition Classes
    RaftLogOps
  5. def appendAll(fromIndex: LogIndex, data: Array[LogEntry[A]]): LogAppendResult

    Append all the data entries

    Append all the data entries

    fromIndex

    the index of the first data element

    data

    the entries (term + data) to append

    returns

    the result from appending the data

    Definition Classes
    DelegateLogRaftLogOps
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def cached(): CachingLog[A]

    returns

    a caching version of this log -- an optimisation for keeping in-memory the latestCommit and latestAppended

    Definition Classes
    RaftLogOps
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  9. def commit(index: LogIndex): Seq[LogCoords]

    Commit all the entries up to the given index.

    Commit all the entries up to the given index.

    It is the responsibility of the node to determine whether this should be called, knowing that this log is safe to commit

    index

    the index to commit

    returns

    the coordinates of all entries committed

    Definition Classes
    StateMachineLogDelegateLogRaftLogOps
  10. def contains(entry: LogCoords): Boolean

    entry

    the entry to check

    returns

    true if there is a log entry for the given coords

    Definition Classes
    RaftLogOps
  11. def containsIndex(index: LogCoords): Boolean
    Attributes
    protected
    Definition Classes
    RaftLogOps
  12. final def coordsForIndex(index: LogIndex): Option[LogCoords]
    Definition Classes
    RaftLogOps
  13. def entriesFrom(firstIndex: LogIndex, max: Int = Int.MaxValue): Array[LogEntry[A]]

    firstIndex

    the matching log index, WHICH IS ONE-BASED

    max

    the maximum entries to return

    returns

    the log entries from the given match index

    Definition Classes
    RaftLogOps
  14. def entryForIndex(index: LogIndex): Option[LogEntry[A]]

    index

    the index for which the log entry should be retrieved

    returns

    the LogEntry at the given index, if it exists

    Definition Classes
    DelegateLogRaftLogOps
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  17. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  20. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  21. def latestAppended(): LogCoords
    Definition Classes
    DelegateLogRaftLogOps
  22. def latestCommit(): LogIndex
    Definition Classes
    DelegateLogRaftLogOps
  23. def logState(): LogState

    returns

    the latest appended entry LogState (term and index)

    Definition Classes
    RaftLogOps
  24. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  25. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  27. def onAppend(currentTerm: Term, request: AppendEntries[A]): AppendEntriesResponse

    append the entry to the log.

    append the entry to the log.

    If the log entry matches _any_ of this raft node's log entries then this is successful, and the match index will be set to the request previous index + 1.

    returns

    the AppendEntriesResponse

    Definition Classes
    RaftLogOps
  28. def onCommit(applyToStateMachine: (LogEntry[A]) ⇒ Unit): StateMachineLog[A]

    This function may server as the main domain logic hook for of the Raft cluster -- it applies the provided function to the LogEntry[A] once the entry is committed.

    This function may server as the main domain logic hook for of the Raft cluster -- it applies the provided function to the LogEntry[A] once the entry is committed. It is up to the application what to do with the side-effectful function.

    You can chain these methods to do multiple things, but notice that this method returns a NEW log, and so all of this should be done prior to creating the RaftNode which will handle the cluster events.

    For example:

    def businessLogicOnCommit(json : Json) = ...
    
    val raftNode : RaftNode[String, Json] = {
       val dataDir : Path = ...
       val node = RaftNode[Json](dataDir)
       node.withLog(node.log.onCommit { entry =>
          businessLogicOnCommit(entry.data)
      }
    }
    
    // put the raft node behind some REST routes of some framework....
    val routes = createWebRouts(raftNode)
    Http.bind(8080, routes)
    returns

    a log which applies the given function when the given log entry is committed.

    Definition Classes
    RaftLogOps
  29. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  30. def termForIndex(index: LogIndex): Option[Term]

    returns

    the log term for the latest index

    Definition Classes
    DelegateLogRaftLogOps
  31. def toString(): String
    Definition Classes
    AnyRef → Any
  32. val underlying: RaftLog[A]
    Definition Classes
    StateMachineLogDelegateLog
  33. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  34. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  35. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from DelegateLog[A]

Inherited from RaftLog[A]

Inherited from RaftLogOps[A]

Inherited from AnyRef

Inherited from Any

Ungrouped