Skip to content

Commit

Permalink
fixed co-master ascii topology
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomi-noach committed Oct 20, 2015
1 parent 0ad0253 commit 27649af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#
set -e

RELEASE_VERSION="1.4.453"
RELEASE_VERSION="1.4.454"
TOPDIR=/tmp/orchestrator-release
export RELEASE_VERSION TOPDIR

Expand Down
22 changes: 18 additions & 4 deletions go/inst/instance_topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ import (
// getASCIITopologyEntry will get an ascii topology tree rooted at given instance. Ir recursively
// draws the tree
func getASCIITopologyEntry(depth int, instance *Instance, replicationMap map[*Instance]([]*Instance), extendedOutput bool) []string {
if instance == nil {
return []string{}
}
if instance.IsCoMaster && depth > 1 {
return []string{}
}
prefix := ""
if depth > 0 {
prefix = strings.Repeat(" ", (depth-1)*2)
Expand Down Expand Up @@ -87,11 +93,19 @@ func ASCIITopology(instanceKey *InstanceKey, historyTimestampPattern string) (st
masterInstance = instance
}
}
if masterInstance == nil {
return "", nil
}
// Get entries:
entries := getASCIITopologyEntry(0, masterInstance, replicationMap, historyTimestampPattern == "")
var entries []string
if masterInstance != nil {
// Single master
entries = getASCIITopologyEntry(0, masterInstance, replicationMap, historyTimestampPattern == "")
} else {
// Co-masters? For visualization we put each in its own branch while ignoring its other co-masters.
for _, instance := range instances {
if instance.IsCoMaster {
entries = append(entries, getASCIITopologyEntry(1, instance, replicationMap, historyTimestampPattern == "")...)
}
}
}
// Beautify: make sure the "[...]" part is nicely aligned for all instances.
{
maxIndent := 0
Expand Down

0 comments on commit 27649af

Please sign in to comment.