Documentation ¶
Overview ¶
Package manage implements protocols used when setting up and testing a tree.
The count-protocol returns the number of nodes in the tree that are reachable. It also sets up all necessary connections, so if you want to do time-measurements without including the setup-time, you can ran a count-protocol first.
The broadcast-protocol connects every node of the tree to every other node and waits for all connections to be set up.
The close_all-protocol sends a 'terminate'-message to all nodes which will close down everything.
Index ¶
- func NewBroadcastProtocol(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
- func NewCloseAll(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
- func NewCount(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
- func NewSimulation(config string) (sda.Simulation, error)
- type Broadcast
- type Close
- type CloseMsg
- type ContactNodes
- type Count
- type CountMsg
- type Done
- type NodeIsUp
- type PrepareClose
- type PrepareCloseMsg
- type PrepareCount
- type ProtocolCloseAll
- type ProtocolCount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewBroadcastProtocol ¶
func NewBroadcastProtocol(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
NewBroadcastProtocol returns a new Broadcast protocol
func NewCloseAll ¶
func NewCloseAll(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
NewCloseAll will create a new protocol
func NewCount ¶
func NewCount(n *sda.TreeNodeInstance) (sda.ProtocolInstance, error)
NewCount returns a new protocolInstance
func NewSimulation ¶
func NewSimulation(config string) (sda.Simulation, error)
NewSimulation returns the new simulation, where all fields are initialised using the config-file
Types ¶
type Broadcast ¶
type Broadcast struct { *sda.TreeNodeInstance // contains filtered or unexported fields }
Broadcast ensures that all nodes are connected to each other. If you need a confirmation once everything is set up, you can register a callback-function using RegisterOnDone()
func (*Broadcast) RegisterOnDone ¶
func (b *Broadcast) RegisterOnDone(fn func())
RegisterOnDone takes a function that will be called once all connections are set up.
type ContactNodes ¶
type ContactNodes struct{}
ContactNodes is sent from the root to ALL other nodes
type Count ¶
type Count struct {
Children int
}
Count sends the number of children to the parent node.
type NodeIsUp ¶
type NodeIsUp struct{}
NodeIsUp - if it is received by the root it will reset the counter.
type PrepareCloseMsg ¶
type PrepareCloseMsg struct { *sda.TreeNode PrepareClose }
PrepareCloseMsg is the wrapper for the PrepareClose message
type PrepareCount ¶
type PrepareCount struct {
Timeout int
}
PrepareCount is sent so that every node can contact the root to say the counting is still going on.
type ProtocolCloseAll ¶
type ProtocolCloseAll struct { *sda.TreeNodeInstance // Done receives a 'true' once the protocol is done. Done chan bool }
ProtocolCloseAll is the structure used to hold the Done-channel
func (*ProtocolCloseAll) FuncClose ¶
func (p *ProtocolCloseAll) FuncClose(c []CloseMsg)
FuncClose is called from the leafs to the parents and up the tree. Everybody receiving all `Close`-messages from all children will close down all network communication.
func (*ProtocolCloseAll) FuncPrepareClose ¶
func (p *ProtocolCloseAll) FuncPrepareClose(pc PrepareCloseMsg)
FuncPrepareClose sends a `PrepareClose`-message down the tree.
func (*ProtocolCloseAll) Start ¶
func (p *ProtocolCloseAll) Start() error
Start the protocol and waits for the `Close`-message to arrive back at the root-node.
type ProtocolCount ¶
type ProtocolCount struct { *sda.TreeNodeInstance Replies int Count chan int Quit chan bool PrepareCountChan chan struct { *sda.TreeNode PrepareCount } CountChan chan []CountMsg NodeIsUpChan chan struct { *sda.TreeNode NodeIsUp } // contains filtered or unexported fields }
ProtocolCount holds all channels. If a timeout occurs or the counting is done, the Count-channel receives the number of nodes reachable in the tree.
func (*ProtocolCount) Dispatch ¶
func (p *ProtocolCount) Dispatch() error
Dispatch listens for all channels and waits for a timeout in case nothing happens for a certain duration
func (*ProtocolCount) FuncC ¶
func (p *ProtocolCount) FuncC(cc []CountMsg)
FuncC creates a Count-message that will be received by all parents and count the total number of children
func (*ProtocolCount) FuncPC ¶
func (p *ProtocolCount) FuncPC()
FuncPC handles PrepareCount messages. These messages go down the tree and every node that receives one will reply with a 'NodeIsUp'-message
func (*ProtocolCount) SetTimeout ¶
func (p *ProtocolCount) SetTimeout(t int)
SetTimeout sets the new timeout
func (*ProtocolCount) Timeout ¶
func (p *ProtocolCount) Timeout() int
Timeout returns the current timeout