Skip to content

Commit

Permalink
refactor: Improve Zone Initialization and Node Shards Assignment in
Browse files Browse the repository at this point in the history
  • Loading branch information
Sufiyan-Mirza committed Sep 24, 2023
1 parent 7d05c92 commit de38dcb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/cluster/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func SetMappingAlg(algVersion uint32) {
}

// NewZone creates a new zone with the specified attributes.
func NewZone(zoneid uint32, numNodes uint32, numZones uint32) *Zone {
zone := newZone(zoneid, numNodes, numZones)
func NewZone(zoneid uint32, numNodes uint32) *Zone {
zone := newZone(zoneid, numNodes)
return &zone
}

func NewZoneFromConfig(zoneid uint32, numNodes uint32, numZones uint32, numShards uint32) *Zone {
zone := newZone(zoneid, numNodes, numZones)
zone := newZone(zoneid, numNodes)

// Populate Nodes
zone.initShardsAsssignment(numZones, numShards)
Expand Down Expand Up @@ -389,7 +389,7 @@ func (list byWeight) Less(i, j int) bool {
}

// newZone initializes and returns a new zone with the specified attributes.
func newZone(zoneid uint32, numNodes uint32, numZones uint32) Zone {
func newZone(zoneid uint32, numNodes uint32) Zone {
return Zone{
Zoneid: zoneid,
NumNodes: numNodes,
Expand Down
2 changes: 1 addition & 1 deletion pkg/etcd/etcdreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func (cr *EtcdReader) readNodesShards(c *cluster.Cluster, tag string, offset int

// the prefix fetch is sorted by key in reverse order
if c.Zones[zoneid] == nil {
c.Zones[zoneid] = cluster.NewZone(uint32(zoneid), uint32(nodeid+1), c.NumZones)
c.Zones[zoneid] = cluster.NewZone(uint32(zoneid), uint32(nodeid+1))
}

c.Zones[zoneid].Nodes[nodeid].StringToNode(uint32(zoneid), uint32(nodeid),
Expand Down

0 comments on commit de38dcb

Please sign in to comment.