Skip to content

Instantly share code, notes, and snippets.

@kenenbek
Created July 20, 2018 05:57
Show Gist options
  • Save kenenbek/e760c8000d6cab1fc7f584c038411ddd to your computer and use it in GitHub Desktop.
Save kenenbek/e760c8000d6cab1fc7f584c038411ddd to your computer and use it in GitHub Desktop.
package src
import (
"fmt"
"lib"
"strings"
)
var _ = fmt.Println
type Tatlin struct {
hosts map[string]HostInterface
parameters map[string]*Pair
sParameters map[string]float64
clientLinks []*lib.Link
cache *lib.Storage
units map[string]float64
}
type Pair struct {
count uint64
value float64
previous float64
}
var TATLIN Tatlin
func InitTatlin() {
// Initialise tatlin variable
TATLIN = Tatlin{
parameters: make(map[string]*Pair),
sParameters: make(map[string]float64),
cache: GetOptimalCache(),
}
TATLIN.parameters["read_response_rate"] = &Pair{}
TATLIN.parameters["write_response_rate"] = &Pair{}
TATLIN.parameters["read_requests_rate"] = &Pair{}
TATLIN.parameters["write_requests_rate"] = &Pair{}
TATLIN.parameters["read_request_process_time"] = &Pair{}
TATLIN.parameters["write_request_process_time"] = &Pair{}
TATLIN.sParameters["read_data_volume"] = 0
TATLIN.sParameters["write_data_volume"] = 0
TATLIN.sParameters["read_cancel_rate"] = 0
TATLIN.sParameters["write_cancel_rate"] = 0
TATLIN.sParameters["io_process_cnt"] = 0
// client links
TATLIN.clientLinks = append(TATLIN.clientLinks, lib.GetLinkByName("Client_Server1"))
TATLIN.clientLinks = append(TATLIN.clientLinks, lib.GetLinkByName("Client_Server2"))
TATLIN.clientLinks = append(TATLIN.clientLinks, lib.GetLinkByName("Client_Server3"))
TATLIN.clientLinks = append(TATLIN.clientLinks, lib.GetLinkByName("Client_Server4"))
//InitVolumes()
InitSimulationHosts()
}
// Hosts, network manager, iobalancer variables for tatlin simulation
func InitSimulationHosts() {
//hosts, nm, iob and fm
simulationHosts := make(map[string]HostInterface)
hosts := lib.GetHosts()
for hostName, host := range hosts {
if strings.EqualFold(hostName, "FabricManager") {
// fmt.Println("FabricManager added")
p := &PCIeFabric{
Host: host,
}
simulationHosts[hostName] = p
continue
}
if strings.EqualFold(hostName, "IOBalancer") {
// fmt.Println("IOBalancer added")
i := &IOBalancer{
Host: host,
}
simulationHosts[hostName] = i
continue
}
if strings.EqualFold(hostName, "NetworkSwitch") {
// fmt.Println("NetworkSwitch added")
n := &NetworkSwitch{
Host: host,
}
simulationHosts[hostName] = n
continue
}
// only for vesnin servers
simulationHosts[hostName] = host
}
TATLIN.hosts = simulationHosts
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment