propogate updates to node details (not just additions and deletions)

to all nodes in cluster, not just coordinator
This commit is contained in:
Matt Jaffee 2018-12-04 14:03:14 -06:00
parent dfb748ec5b
commit ef6db5cc1a
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 17 additions and 1 deletions

View file

@ -70,7 +70,7 @@ type Node struct {
}
func (n Node) String() string {
return fmt.Sprintf("Node:%s:%s:%s", n.URI, n.State, n.ID[:6])
return fmt.Sprintf("Node:%s:%s:%s", n.URI, n.State, n.ID)
}
// Nodes represents a list of nodes.
@ -364,6 +364,7 @@ func (c *cluster) addNode(node *Node) error {
if !c.Topology.addID(node.ID) {
return nil
}
c.Topology.nodeStates[node.ID] = node.State
// save topology
return c.saveTopology()
@ -588,6 +589,12 @@ func (c *cluster) nodePositionByID(nodeID string) int {
func (c *cluster) addNodeBasicSorted(node *Node) bool {
n := c.unprotectedNodeByID(node.ID)
if n != nil {
if n.State != node.State || n.IsCoordinator != node.IsCoordinator || n.URI != node.URI {
n.State = node.State
n.IsCoordinator = node.IsCoordinator
n.URI = node.URI
return true
}
return false
}

View file

@ -678,6 +678,15 @@ func TestClusterQueriesAfterRestart(t *testing.T) {
defer cluster.Close()
cmd1 := cluster[1]
for _, com := range cluster {
nodes := com.API.Hosts(context.Background())
for _, n := range nodes {
if n.State != "READY" {
t.Fatalf("unexpected node state after upping cluster: %v", nodes)
}
}
}
cmd1.MustCreateIndex(t, "testidx", pilosa.IndexOptions{})
cmd1.MustCreateField(t, "testidx", "testfield", pilosa.OptFieldTypeSet(pilosa.CacheTypeRanked, 10))