This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
dependency_graph.go
58 lines (49 loc) · 2.56 KB
/
dependency_graph.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package controllers
type dependencyGraph interface {
AddDependency(component MilvusComponent, dependencies []MilvusComponent)
GetDependencies(component MilvusComponent) []MilvusComponent
// GetReversedDependencies returns the reversed dependencies of the component
// it's used for downgrade
GetReversedDependencies(component MilvusComponent) []MilvusComponent
}
type dependencyGraphImpl struct {
dependencies map[MilvusComponent][]MilvusComponent
reversedDependencies map[MilvusComponent][]MilvusComponent
}
func newDependencyGraphImpl() dependencyGraph {
return &dependencyGraphImpl{
dependencies: make(map[MilvusComponent][]MilvusComponent),
reversedDependencies: make(map[MilvusComponent][]MilvusComponent),
}
}
func (d *dependencyGraphImpl) AddDependency(component MilvusComponent, dependencies []MilvusComponent) {
d.dependencies[component] = dependencies
for _, dep := range dependencies {
if d.reversedDependencies[dep] == nil {
d.reversedDependencies[dep] = []MilvusComponent{}
}
d.reversedDependencies[dep] = append(d.reversedDependencies[dep], component)
}
}
func (d *dependencyGraphImpl) GetDependencies(component MilvusComponent) []MilvusComponent {
return d.dependencies[component]
}
func (d *dependencyGraphImpl) GetReversedDependencies(component MilvusComponent) []MilvusComponent {
return d.reversedDependencies[component]
}
func init() {
clusterDependencyGraph.AddDependency(RootCoord, []MilvusComponent{})
clusterDependencyGraph.AddDependency(DataCoord, []MilvusComponent{RootCoord})
clusterDependencyGraph.AddDependency(IndexCoord, []MilvusComponent{DataCoord})
clusterDependencyGraph.AddDependency(QueryCoord, []MilvusComponent{IndexCoord})
clusterDependencyGraph.AddDependency(IndexNode, []MilvusComponent{QueryCoord})
clusterDependencyGraph.AddDependency(QueryNode, []MilvusComponent{QueryCoord})
clusterDependencyGraph.AddDependency(DataNode, []MilvusComponent{QueryCoord})
clusterDependencyGraph.AddDependency(Proxy, []MilvusComponent{IndexNode, QueryNode, DataNode})
mixCoordClusterDependencyGraph.AddDependency(MixCoord, []MilvusComponent{})
mixCoordClusterDependencyGraph.AddDependency(IndexNode, []MilvusComponent{MixCoord})
mixCoordClusterDependencyGraph.AddDependency(QueryNode, []MilvusComponent{MixCoord})
mixCoordClusterDependencyGraph.AddDependency(DataNode, []MilvusComponent{MixCoord})
mixCoordClusterDependencyGraph.AddDependency(Proxy, []MilvusComponent{IndexNode, QueryNode, DataNode})
}
var clusterDependencyGraph, mixCoordClusterDependencyGraph dependencyGraph = newDependencyGraphImpl(), newDependencyGraphImpl()