class StateMachineLog[A] extends DelegateLog[A]
Invokes a function when log entries are committed
- Alphabetic
- By Inheritance
- StateMachineLog
- DelegateLog
- RaftLog
- RaftLogOps
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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
-
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
- DelegateLog → RaftLogOps
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
cached(): CachingLog[A]
- returns
a caching version of this log -- an optimisation for keeping in-memory the latestCommit and latestAppended
- Definition Classes
- RaftLogOps
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
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
- StateMachineLog → DelegateLog → RaftLogOps
-
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
-
def
containsIndex(index: LogCoords): Boolean
- Attributes
- protected
- Definition Classes
- RaftLogOps
-
final
def
coordsForIndex(index: LogIndex): Option[LogCoords]
- Definition Classes
- RaftLogOps
-
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
-
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
- DelegateLog → RaftLogOps
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
latestAppended(): LogCoords
- Definition Classes
- DelegateLog → RaftLogOps
-
def
latestCommit(): LogIndex
- Definition Classes
- DelegateLog → RaftLogOps
-
def
logState(): LogState
- returns
the latest appended entry LogState (term and index)
- Definition Classes
- RaftLogOps
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
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
-
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
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
termForIndex(index: LogIndex): Option[Term]
- returns
the log term for the latest index
- Definition Classes
- DelegateLog → RaftLogOps
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
val
underlying: RaftLog[A]
- Definition Classes
- StateMachineLog → DelegateLog
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )