Skip to content

Instantly share code, notes, and snippets.

@samueleresca
Created December 14, 2021 14:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samueleresca/ee56fbfb9c839e85cb6e744ffb326b91 to your computer and use it in GitHub Desktop.
Save samueleresca/ee56fbfb9c839e85cb6e744ffb326b91 to your computer and use it in GitHub Desktop.
//Strategy defines a strategy related to a QuorumSystem.
type Strategy struct {
Qs QuorumSystem
SigmaR Sigma
SigmaW Sigma
nodeToReadProbability map[Node]Probability
nodeToWriteProbability map[Node]Probability
}
// Sigma defines the probabilities of a specific Strategy. Each Expr (quorum) has a probability of being choose associated.
type Sigma struct {
Values []SigmaRecord
}
// SigmaRecord defines as ExprSet that represents a quorum and the probability of being chosen.
type SigmaRecord struct {
Quorum ExprSet
Probability Probability
}
// GetReadQuorum returns a ExprSet representing a quorum of the strategy.
// The method return the quorum based on its probability.
func (s Strategy) GetReadQuorum() ExprSet {
...
}
// GetWriteQuorum returns a ExprSet representing a quorum of the strategy.
// The method return the quorum based on its probability.
func (s Strategy) GetWriteQuorum() ExprSet {
...
}
// Load calculates and returns the load of the strategy given a read and write distribution.
func (s Strategy) Load(rf *Distribution, wf *Distribution) (float64, error) {
...
}
// Capacity calculates and returns the capacity of the strategy given a read and write distribution.
func (s Strategy) Capacity(rf *Distribution, wf *Distribution) (float64, error) {
...
}
// NetworkLoad calculates and returns the network load of the strategy given a read and write Distribution.
func (s Strategy) NetworkLoad(rf *Distribution, wf *Distribution) (float64, error) {
...
}
// NodeLoad returns the load of a specific Node given a read and write Distribution.
func (s Strategy) NodeLoad(node Node, rf *Distribution, wf *Distribution) (float64, error) {
...
}
// NodeUtilization returns the utilization of a specific Node given a read and write Distribution.
func (s Strategy) NodeUtilization(node Node, rf *Distribution, wf *Distribution) (*float64, error) {
...
}
// NodeThroughput returns the throughput of a specific Node given a read and write Distribution.
func (s Strategy) NodeThroughput(node Node, rf *Distribution, wf *Distribution) (*float64, error) {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment