controller

package
v6.5.1-rc1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2019 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllAgree string = `` /* 297-byte string literal not displayed */
View Source
var HorizontalFlipflop string = `` /* 434-byte string literal not displayed */
View Source
var Scenarios = make(map[string]string)

Functions

This section is empty.

Types

type Controller

type Controller struct {
	AuthSet *testhelper.AuthSetHelper

	RoutingElections []*election.RoutingElection
	Elections        []*election.Election
	Volunteers       []*messages.VolunteerMessage

	// Can be all 0s for now
	primitives.ProcessListLocation

	Buffer        *MessageBuffer
	GlobalDisplay *election.Display

	Router          *Router
	OutputsToRouter bool

	BufferingMessages bool
	BufferedMessages  []*DirectedMessage

	PrintingTrace bool

	History []string
	// contains filtered or unexported fields
}

Controller will be able to route messages to a set of nodes and control various communication patterns

func NewController

func NewController(feds, auds int) *Controller

NewController creates all the elections and initial volunteer messages

func (*Controller) AddLeaderLevelMessageToRouter

func (c *Controller) AddLeaderLevelMessageToRouter(from int, level int) bool

func (*Controller) AddLeaderSetLevelMessageToRouter

func (c *Controller) AddLeaderSetLevelMessageToRouter(from []int, level int) bool

func (*Controller) Complete

func (c *Controller) Complete() bool

func (*Controller) ElectionStatus

func (c *Controller) ElectionStatus(node int) string

func (*Controller) RouteLeaderLevelMessage

func (c *Controller) RouteLeaderLevelMessage(from int, level int, to []int) bool

func (*Controller) RouteLeaderSetLevelMessage

func (c *Controller) RouteLeaderSetLevelMessage(from []int, level int, to []int) bool

func (*Controller) RouteLeaderSetVoteMessage

func (c *Controller) RouteLeaderSetVoteMessage(from []int, vol int, to []int) bool

func (*Controller) RouteLeaderVoteMessage

func (c *Controller) RouteLeaderVoteMessage(from int, vol int, to []int) bool

func (*Controller) RouteMessage

func (c *Controller) RouteMessage(msg imessage.IMessage, nodes []int)

RouteMessage will execute message on all nodes given and add the messages returned to the buffer

func (*Controller) RouteVolunteerMessage

func (c *Controller) RouteVolunteerMessage(vol int, nodes []int)

func (*Controller) SendOutputsToRouter

func (c *Controller) SendOutputsToRouter(set bool)

type ControllerInterpreter

type ControllerInterpreter struct {
	*Controller

	*priminterpreter.Primitives
}

func NewControllerInterpreter

func NewControllerInterpreter(feds, auds int) *ControllerInterpreter

func (*ControllerInterpreter) InitInterpreter

func (c *ControllerInterpreter) InitInterpreter()

func (*ControllerInterpreter) PrimPrintMessages

func (c *ControllerInterpreter) PrimPrintMessages()

func (*ControllerInterpreter) PrimPrintMessagesAll

func (c *ControllerInterpreter) PrimPrintMessagesAll()

func (*ControllerInterpreter) PrimPrintNodeStack

func (c *ControllerInterpreter) PrimPrintNodeStack()

func (*ControllerInterpreter) PrimPrintNodeStackAll

func (c *ControllerInterpreter) PrimPrintNodeStackAll()

func (*ControllerInterpreter) PrimPrintRoutingInfo

func (c *ControllerInterpreter) PrimPrintRoutingInfo()

func (*ControllerInterpreter) PrimPrintState

func (c *ControllerInterpreter) PrimPrintState()

func (*ControllerInterpreter) PrimPrintStateAll

func (c *ControllerInterpreter) PrimPrintStateAll()

func (*ControllerInterpreter) PrimPrintVoteState

func (c *ControllerInterpreter) PrimPrintVoteState()

func (*ControllerInterpreter) PrimPrintVoteStateAll

func (c *ControllerInterpreter) PrimPrintVoteStateAll()

func (*ControllerInterpreter) PrimRouteLevelMessage

func (c *ControllerInterpreter) PrimRouteLevelMessage()
From   Level    To

{ 1 2 } 1 { 0 2 } <-o

Route level 1 from (0, 2) to (1, 2)

func (*ControllerInterpreter) PrimRouteStep

func (c *ControllerInterpreter) PrimRouteStep()

func (*ControllerInterpreter) PrimRouteStepN

func (c *ControllerInterpreter) PrimRouteStepN()

func (*ControllerInterpreter) PrimRouteVolunteerMessage

func (c *ControllerInterpreter) PrimRouteVolunteerMessage()

Vol To

 1 { 1 2 }<-v
		Route vol 1 to 1, and 2

func (*ControllerInterpreter) PrimRouteVoteMessage

func (c *ControllerInterpreter) PrimRouteVoteMessage()
From    Vote    To

{ 1 2 } 1 { 0 2 } <-o

Route vote 1 from (0, 2) to (1, 2)

func (*ControllerInterpreter) PrimSelectLeaders

func (c *ControllerInterpreter) PrimSelectLeaders() []int

func (*ControllerInterpreter) PrimToggleBuffering

func (c *ControllerInterpreter) PrimToggleBuffering()

func (*ControllerInterpreter) PrimToggleControllerPrinting

func (c *ControllerInterpreter) PrimToggleControllerPrinting()

func (*ControllerInterpreter) PrimToggleRouterPrinting

func (c *ControllerInterpreter) PrimToggleRouterPrinting()

func (*ControllerInterpreter) PrimToggleRouting

func (c *ControllerInterpreter) PrimToggleRouting()

func (*ControllerInterpreter) Reset

func (c *ControllerInterpreter) Reset()

func (*ControllerInterpreter) RunScenario

func (c *ControllerInterpreter) RunScenario()

func (*ControllerInterpreter) SetController

func (c *ControllerInterpreter) SetController()

type MessageBuffer

type MessageBuffer struct {
	// A list of all messages, it's an ever growing set, trimming the front
	// keeps the index the same by using the 'base' field.
	Messages []imessage.IMessage
	Base     int

	// When looking for a message by someone, this helps searching
	MessagesMap map[primitives.Identity][]int
}

MessageBuffer will manage all messages in the message list

func NewMessageBuffer

func NewMessageBuffer() *MessageBuffer

func (*MessageBuffer) Add

func (b *MessageBuffer) Add(msg imessage.IMessage)

func (*MessageBuffer) RetrieveIndex

func (b *MessageBuffer) RetrieveIndex(index int) (imessage.IMessage, error)

func (*MessageBuffer) RetrieveLeaderLevelMessageByLevel

func (b *MessageBuffer) RetrieveLeaderLevelMessageByLevel(leader primitives.Identity, level int) imessage.IMessage

func (*MessageBuffer) RetrieveLeaderVoteMessage

func (b *MessageBuffer) RetrieveLeaderVoteMessage(leader primitives.Identity, vol primitives.Identity) imessage.IMessage

RetrieveLeaderVoteMessage takes a vol too as multiple vote 0s can be sent out

type Router

type Router struct {
	// Number of messages consumed
	Consumed       []int
	Generated      []int
	ElectionQueues []chan imessage.IMessage
	RepeatedFilter []map[imessage.IMessage]struct{}
	Elections      []*election.RoutingElection

	Printing bool
}

Router helps keep route patterns for returning messages Each election has a queue, and each step consumes 1 message from the queue and adds to some number of queues

func NewRouter

func NewRouter(elections []*election.RoutingElection) *Router

func (*Router) NodeStack

func (r *Router) NodeStack(node int) string

NodeStack will return the messages in the node's input queue

func (*Router) PrintMode

func (r *Router) PrintMode(active bool)

func (*Router) Run

func (r *Router) Run()

func (*Router) Status

func (r *Router) Status() string

func (*Router) Step

func (r *Router) Step() bool

func (*Router) StepN

func (r *Router) StepN(step int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL