Commit b27cde41 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

adjusted model network graph weights for default zones & net locations + fixe...

adjusted model network graph weights for default zones & net locations + fixe net char mgr UT issues
parent 1072a8d3
Loading
Loading
Loading
Loading
+19 −5
Original line number Diff line number Diff line
@@ -461,35 +461,35 @@ func (m *Model) parseNodes() (err error) {
				domain := &m.scenario.Deployment.Domains[iDomain]
				ctx := NewNodeContext(m.scenario.Name, domain.Name, "", "", "")
				m.nodeMap.AddNode(NewNode(domain.Name, domain.Type_, domain, &domain.Zones, m.scenario.Deployment, ctx))
				m.networkGraph.AddNode(domain.Name, "")
				m.networkGraph.AddNode(domain.Name, "", false)

				// Zones
				for iZone := range domain.Zones {
					zone := &domain.Zones[iZone]
					ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, "", "")
					m.nodeMap.AddNode(NewNode(zone.Name, zone.Type_, zone, &zone.NetworkLocations, domain, ctx))
					m.networkGraph.AddNode(zone.Name, domain.Name)
					m.networkGraph.AddNode(zone.Name, domain.Name, isDefaultZone(zone.Type_))

					// Network Locations
					for iNL := range zone.NetworkLocations {
						nl := &zone.NetworkLocations[iNL]
						ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, "")
						m.nodeMap.AddNode(NewNode(nl.Name, nl.Type_, nl, &nl.PhysicalLocations, zone, ctx))
						m.networkGraph.AddNode(nl.Name, zone.Name)
						m.networkGraph.AddNode(nl.Name, zone.Name, isDefaultNetLoc(nl.Type_))

						// Physical Locations
						for iPL := range nl.PhysicalLocations {
							pl := &nl.PhysicalLocations[iPL]
							ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, pl.Name)
							m.nodeMap.AddNode(NewNode(pl.Name, pl.Type_, pl, &pl.Processes, nl, ctx))
							m.networkGraph.AddNode(pl.Name, nl.Name)
							m.networkGraph.AddNode(pl.Name, nl.Name, false)

							// Processes
							for iProc := range pl.Processes {
								proc := &pl.Processes[iProc]
								ctx := NewNodeContext(m.scenario.Name, domain.Name, zone.Name, nl.Name, pl.Name)
								m.nodeMap.AddNode(NewNode(proc.Name, proc.Type_, proc, nil, pl, ctx))
								m.networkGraph.AddNode(proc.Name, pl.Name)
								m.networkGraph.AddNode(proc.Name, pl.Name, false)

								// Update service map for external processes
								if proc.IsExternal {
@@ -655,3 +655,17 @@ func (m *Model) internalListener(channel string, payload string) {
	// external listener
	m.listener(channel, payload)
}

func isDefaultZone(typ string) bool {
	if typ == "COMMON" {
		return true
	}
	return false
}

func isDefaultNetLoc(typ string) bool {
	if typ == "DEFAULT" {
		return true
	}
	return false
}
+7 −3
Original line number Diff line number Diff line
@@ -30,10 +30,14 @@ func NewNetworkGraph() (ng *NetworkGraph) {
	return ng
}

func (ng *NetworkGraph) AddNode(node string, parent string) {
func (ng *NetworkGraph) AddNode(node string, parent string, zeroDist bool) {
	ng.graph.AddMappedVertex(node)
	if parent != "" {
		_ = ng.graph.AddMappedArc(parent, node, 1)
		_ = ng.graph.AddMappedArc(node, parent, 1)
		var distance int64 = 0
		if !zeroDist {
			distance = 1
		}
		_ = ng.graph.AddMappedArc(parent, node, distance)
		_ = ng.graph.AddMappedArc(node, parent, distance)
	}
}
+11 −9
Original line number Diff line number Diff line
@@ -1017,10 +1017,12 @@ func getNetChars(elemName string, model *mod.Model) (nc NetChar) {
		jitter = float64(nl.TerminalLinkLatencyVariation)
		packetLoss = float64(nl.TerminalLinkPacketLoss)
	} else if zone, ok := node.(*ceModel.Zone); ok {
		if zone.NetChar != nil {
			maxThroughput = float64(zone.NetChar.Throughput)
			latency = float64(zone.NetChar.Latency)
			jitter = float64(zone.NetChar.LatencyVariation)
			packetLoss = float64(zone.NetChar.PacketLoss)
		}
	} else if domain, ok := node.(*ceModel.Domain); ok {
		maxThroughput = float64(domain.InterZoneThroughput)
		latency = float64(domain.InterZoneLatency)
@@ -1113,8 +1115,8 @@ func printPath(path *SegAlgoPath) string {
	return str
}

// printElement -
func printElement(elem *SegAlgoNetElem) string {
	str := elem.Name + "-" + elem.Type + "-" + elem.PhyLocName + "-" + elem.PoaName + "-" + elem.ZoneName + "-" + elem.DomainName
	return str
}
// // printElement -
// func printElement(elem *SegAlgoNetElem) string {
// 	str := elem.Name + "-" + elem.Type + "-" + elem.PhyLocName + "-" + elem.PoaName + "-" + elem.ZoneName + "-" + elem.DomainName
// 	return str
// }
+11 −4
Original line number Diff line number Diff line
@@ -155,6 +155,8 @@ func (ncm *NetCharManager) Register(netCharUpdateCb NetCharUpdateCb, updateCompl
func (ncm *NetCharManager) Start() error {
	if !ncm.isStarted {
		ncm.isStarted = true

		// Process current controls
		ncm.updateControls()

		// Process current scenario
@@ -164,11 +166,11 @@ func (ncm *NetCharManager) Start() error {
		ncm.ticker = time.NewTicker(time.Duration(ncm.config.RecalculationPeriod) * time.Millisecond)
		go func() {
			for range ncm.ticker.C {
				if ncm.isStarted {
				ncm.mutex.Lock()
				if ncm.isStarted {
					ncm.updateNetChars()
					ncm.mutex.Unlock()
				}
				ncm.mutex.Unlock()
			}
		}()
		log.Debug("Network Characteristics Manager started: ", ncm.name)
@@ -213,6 +215,7 @@ func (ncm *NetCharManager) processActiveScenarioUpdate() {
		err := ncm.algo.ProcessScenario(ncm.activeModel)
		if err != nil {
			log.Error("Failed to process active model with error: ", err)
			ncm.mutex.Unlock()
			return
		}

@@ -230,11 +233,15 @@ func (ncm *NetCharManager) updateNetChars() {
	// Apply updates, if any
	if len(updatedNetCharList) != 0 {
		for _, flowNetChar := range updatedNetCharList {
			if ncm.netCharUpdateCb != nil {
				ncm.netCharUpdateCb(flowNetChar.DstElemName, flowNetChar.SrcElemName, flowNetChar.MyNetChar.Throughput, flowNetChar.MyNetChar.Latency, flowNetChar.MyNetChar.Jitter, flowNetChar.MyNetChar.PacketLoss)
			}
		}
		if ncm.updateCompleteCb != nil {
			ncm.updateCompleteCb()
		}
	}
}

// updateControls - Update all the different configurations attributes based on the content of the DB for dynamic updates
func (ncm *NetCharManager) updateControls() {
+3 −2
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package netchar
import (
	"fmt"
	"testing"
	"time"

	log "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-logger"
)
@@ -64,8 +65,8 @@ func TestNetCharBasic(t *testing.T) {
		t.Errorf("NetChar not running")
	}

	// fmt.Println("Run NetChar for 1 second")
	// time.Sleep(1000 * time.Millisecond)
	fmt.Println("Run NetChar for 100 ms")
	time.Sleep(100 * time.Millisecond)

	fmt.Println("Stop NetCharMgr")
	netCharMgr.Stop()
Loading