Documentation ¶
Index ¶
- type EndSnapshot
- type Link
- type LogEvent
- type Logger
- type MarkerMessage
- type PassTokenEvent
- type Queue
- type ReceivedMessageEvent
- type SendMessageEvent
- type SentMessageEvent
- type Server
- type Simulator
- func (sim *Simulator) AddForwardLink(src string, dest string)
- func (sim *Simulator) AddServer(id string, tokens int)
- func (sim *Simulator) CollectSnapshot(snapshotId int) *SnapshotState
- func (sim *Simulator) GetReceiveTime() int
- func (sim *Simulator) InjectEvent(event interface{})
- func (sim *Simulator) NotifySnapshotComplete(serverId string, snapshotId int)
- func (sim *Simulator) StartSnapshot(serverId string)
- func (sim *Simulator) Tick()
- type SnapshotEvent
- type SnapshotMessage
- type SnapshotState
- type StartSnapshot
- type SyncMap
- type TokenMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EndSnapshot ¶
type EndSnapshot struct {
// contains filtered or unexported fields
}
A message that signifies the end of the snapshot process on a particular server. This is used only for debugging that is not sent between servers.
func (EndSnapshot) String ¶
func (m EndSnapshot) String() string
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
A unidirectional communication channel between two servers Each link contains an event queue (as opposed to a packet queue)
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func (*Logger) PrettyPrint ¶
func (log *Logger) PrettyPrint()
func (*Logger) RecordEvent ¶
type MarkerMessage ¶
type MarkerMessage struct {
// contains filtered or unexported fields
}
A message sent from one server to another during the chandy-lamport algorithm. This is expected to be encapsulated within a `sendMessageEvent`.
func (MarkerMessage) String ¶
func (m MarkerMessage) String() string
type PassTokenEvent ¶
type PassTokenEvent struct {
// contains filtered or unexported fields
}
An event parsed from the .event files that represent the passing of tokens from one server to another
type Queue ¶
type Queue struct {
// contains filtered or unexported fields
}
Define a queue -- simple implementation over List
type ReceivedMessageEvent ¶
type ReceivedMessageEvent struct {
// contains filtered or unexported fields
}
A message that signifies receiving of a message on a particular server This is used only for debugging that is not sent between servers
func (ReceivedMessageEvent) String ¶
func (m ReceivedMessageEvent) String() string
type SendMessageEvent ¶
type SendMessageEvent struct {
// contains filtered or unexported fields
}
An event that represents the sending of a message. This is expected to be queued in `link.events`.
type SentMessageEvent ¶
type SentMessageEvent struct {
// contains filtered or unexported fields
}
A message that signifies sending of a message on a particular server This is used only for debugging that is not sent between servers
func (SentMessageEvent) String ¶
func (m SentMessageEvent) String() string
type Server ¶
The main participant of the distributed snapshot protocol. Servers exchange token messages and marker messages among each other. Token messages represent the transfer of tokens from one server to another. Marker messages represent the progress of the snapshot process. The bulk of the distributed protocol is implemented in `HandlePacket` and `StartSnapshot`.
func (*Server) AddOutboundLink ¶
Add a unidirectional link to the destination server
func (*Server) HandlePacket ¶
Callback for when a message is received on this server. When the snapshot algorithm completes on this server, this function should notify the simulator by calling `sim.NotifySnapshotComplete`.
func (*Server) SendToNeighbors ¶
func (server *Server) SendToNeighbors(message interface{})
Send a message on all of the server's outbound links
func (*Server) SendTokens ¶
Send a number of tokens to a neighbor attached to this server
func (*Server) StartSnapshot ¶
Start the chandy-lamport snapshot algorithm on this server. This should be called only once per server.
type Simulator ¶
type Simulator struct {
// contains filtered or unexported fields
}
Simulator is the entry point to the distributed snapshot application.
It is a discrete time simulator, i.e. events that happen at time t + 1 come strictly after events that happen at time t. At each time step, the simulator examines messages queued up across all the links in the system and decides which ones to deliver to the destination.
The simulator is responsible for starting the snapshot process, inducing servers to pass tokens to each other, and collecting the snapshot state after the process has terminated.
func NewSimulator ¶
func NewSimulator() *Simulator
func (*Simulator) AddForwardLink ¶
Add a unidirectional link between two servers
func (*Simulator) AddServer ¶
Add a server to this simulator with the specified number of starting tokens
func (*Simulator) CollectSnapshot ¶
func (sim *Simulator) CollectSnapshot(snapshotId int) *SnapshotState
Collect and merge snapshot state from all the servers. This function blocks until the snapshot process has completed on all servers.
func (*Simulator) GetReceiveTime ¶
Return the receive time of a message after adding a random delay. Note: since we only deliver one message to a given server at each time step, the message may be received *after* the time step returned in this function.
func (*Simulator) InjectEvent ¶
func (sim *Simulator) InjectEvent(event interface{})
Run an event in the system
func (*Simulator) NotifySnapshotComplete ¶
Callback for servers to notify the simulator that the snapshot process has completed on a particular server
func (*Simulator) StartSnapshot ¶
Start a new snapshot process at the specified server
type SnapshotEvent ¶
type SnapshotEvent struct {
// contains filtered or unexported fields
}
An event parsed from the .event files that represent the initiation of the chandy-lamport snapshot algorithm
type SnapshotMessage ¶
type SnapshotMessage struct {
// contains filtered or unexported fields
}
A message recorded during the snapshot process
type SnapshotState ¶
type SnapshotState struct {
// contains filtered or unexported fields
}
State recorded during the snapshot process
type StartSnapshot ¶
type StartSnapshot struct {
// contains filtered or unexported fields
}
A message that signifies the beginning of the snapshot process on a particular server. This is used only for debugging that is not sent between servers.
func (StartSnapshot) String ¶
func (m StartSnapshot) String() string
type SyncMap ¶
type SyncMap struct {
// contains filtered or unexported fields
}
An implementation of a map that synchronizes read and write accesses. Note: This class intentionally adopts the interface of `sync.Map`, which is introduced in Go 1.9+ but not available before that. This provides a simplified version of the same class without requiring the user to upgrade their Go installation.
func NewSyncMap ¶
func NewSyncMap() *SyncMap
func (*SyncMap) LoadOrStore ¶
type TokenMessage ¶
type TokenMessage struct {
// contains filtered or unexported fields
}
A message sent from one server to another for token passing. This is expected to be encapsulated within a `sendMessageEvent`.
func (TokenMessage) String ¶
func (m TokenMessage) String() string