class RaftNode[A] extends RaftMessageHandler[A] with TimerCallback[RaftNodeResult[A]] with AutoCloseable

The place where the different pieces which represent a Raft Node come together -- the glue code.

I've looked at this a few different ways, but ultimately found this abstraction here to be the most readable, and follows most closely what's laid out in the raft spec.

It's not too generic/abstracted, but quite openly just orchestrates the pieces/interactions of the inputs into a raft node.

Self Type
RaftNode[A]
Linear Supertypes
AutoCloseable, TimerCallback[RaftNodeResult[A]], RaftMessageHandler[A], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. RaftNode
  2. AutoCloseable
  3. TimerCallback
  4. RaftMessageHandler
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new RaftNode(persistentState: PersistentState, log: RaftLog[A], timers: Timers, cluster: RaftCluster, initialState: NodeState, maxAppendSize: Int, initialTimerCallback: TimerCallback[_] = null, roleCallback: RoleCallback = RoleCallback.NoOp)

Type Members

  1. type Result = RaftNodeResult[A]
    Definition Classes
    RaftMessageHandler

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 appendIfLeader(data: Array[A]): NodeAppendResult[A]

    Exposes this as a means for generating an AddressedRequest of messages together with the append result from the leader's log

    Exposes this as a means for generating an AddressedRequest of messages together with the append result from the leader's log

    data

    the data to append

    returns

    the append result coupled w/ the append request to send if this node is the leader

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def cancelReceiveHeartbeat(): Unit
  7. def cancelSendHeartbeat(): Unit
  8. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  9. def close(): Unit
    Definition Classes
    RaftNode → AutoCloseable
  10. val cluster: RaftCluster
  11. final def createAppendFor(data: A, theRest: A*)(implicit tag: ClassTag[A]): Result
  12. def currentTerm(): Term
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def handleMessage(from: NodeId, msg: RequestOrResponse[A]): Result

    Applies requests and responses coming to the node state and replies w/ any resulting messages

    Applies requests and responses coming to the node state and replies w/ any resulting messages

    from

    the node from which this message is received

    msg

    the Raft message

    returns

    and resulting messages (requests or responses)

  18. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  19. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  20. val log: RaftLog[A]
  21. val maxAppendSize: Int
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. def nodeId: NodeId

    returns

    the ID of this node in the cluster

    Definition Classes
    RaftNodeRaftMessageHandler
  24. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  26. def onAppendData[P[_]](request: AppendData[A, P]): NodeAppendResult[A]
  27. def onAppendEntries(from: NodeId, append: AppendEntries[A]): AppendEntriesResponse
  28. def onAppendEntriesResponse(from: NodeId, appendResponse: AppendEntriesResponse): LeaderCommittedResult[A]

    We're either the leader and should update our peer view/commit log, or aren't and should ignore it

    We're either the leader and should update our peer view/commit log, or aren't and should ignore it

    returns

    the committed log coords resulting from having applied this response and the state output (either a no-op or a subsequent AppendEntries request)

  29. def onBecomeCandidateOrLeader(): AddressedRequest[A]
  30. def onBecomeFollower(newLeader: Option[NodeId], newTerm: Term): Unit
  31. def onBecomeLeader(): AddressedRequest[A]
  32. def onMessage(input: RaftMessage[A]): Result

    returns

    the response

    Definition Classes
    RaftNodeRaftMessageHandler
  33. def onReceiveHeartbeatTimeout(): AddressedRequest[A]
    Definition Classes
    RaftNodeTimerCallback
  34. def onRequest(from: NodeId, request: RaftRequest[A]): RaftResponse
  35. def onRequestVote(from: NodeId, forRequest: RequestVote): RequestVoteResponse

    Create a reply to the given vote request.

    Create a reply to the given vote request.

    NOTE: Whatever the actual node 'A' is, it is expected that, upon a successful reply, it updates it's own term and writes down (remembers) that it voted in this term so as not to double-vote should this node crash.

    forRequest

    the data from the vote request

    returns

    the RequestVoteResponse

  36. def onRequestVoteResponse(from: NodeId, voteResponse: RequestVoteResponse): Result
  37. def onResponse(from: NodeId, reply: RaftResponse): Result

    Handle a response coming from 'from'

    Handle a response coming from 'from'

    from

    the originating node

    reply

    the response

    returns

    any messages resulting from having processed this response

  38. def onSendHeartbeatTimeout(): Result
    Definition Classes
    RaftNodeTimerCallback
  39. def onTimerMessage(timeout: TimerMessage): Result
  40. val persistentState: PersistentState
  41. def resetReceiveHeartbeat(): CancelT

    This is NOT intended to be called directly, but is managed internally

    This is NOT intended to be called directly, but is managed internally

    returns

    the cancellable timer result.

  42. val roleCallback: RoleCallback
  43. def state(): NodeState
  44. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  45. val timerCallback: TimerCallback[_1] forSome {type _1 >: _$1 with RaftNodeResult[A], type _$1}
  46. val timers: Timers
  47. def toString(): String
    Definition Classes
    RaftNode → AnyRef → Any
  48. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  49. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  50. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  51. def withCluster(newCluster: RaftCluster): RaftNode[A]

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    a convenience builder method to create a new raft node w/ the given cluster

    returns

    a new node state

  52. def withLog(newLog: RaftLog[A]): RaftNode[A]

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    a convenience builder method to create a new raft node w/ the given raft log

    returns

    a new node state

  53. def withRoleCallback(newRoleCallback: RoleCallback): RaftNode[A]

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    Adds the given callback to this node to be invoked whenever a RoleEvent takes place

    returns

    a new RaftNode w/ the given callback added

  54. def withRoleCallback(f: (RoleEvent) ⇒ Unit): RaftNode[A]

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    A convenience method for exposing 'withRoleCallback' with a function instead of a RoleCallback, so users can invoke via:

    val initial : RaftNode[T] = ...
    initial.withRoleCallback { event =>
      // do something w/ the event here
      println(event)
    }
    f

    the callback function

    returns

    a new RaftNode w/ the given callback added

  55. def withTimerCallback(newTimerCallback: TimerCallback[_]): RaftNode[A]

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    As this function returns a new node, care should be taken that it is used correctly in setting up the raft cluster; 'correctly' meaning that the returned instance is the one used to to communicate w/ the other nodes, as opposed to an old reference.

    newTimerCallback

    the timer callback

    returns

    a copy of thew RaftNode which uses the given timer callback

Inherited from AutoCloseable

Inherited from TimerCallback[RaftNodeResult[A]]

Inherited from RaftMessageHandler[A]

Inherited from AnyRef

Inherited from Any

Ungrouped