diff --git a/cluster.go b/cluster.go index 37ba01b5f..96b03be7c 100644 --- a/cluster.go +++ b/cluster.go @@ -726,10 +726,10 @@ func (c *cluster) Nodes() []*topology.Node { s, err := c.stator.NodeState(context.Background(), node.ID) if err != nil { // TODO should we delete this? - copiedNodes[i].State = string(disco.NodeStateUnknown) + copiedNodes[i].State = disco.NodeStateUnknown continue } - copiedNodes[i].State = string(s) + copiedNodes[i].State = s } return result } diff --git a/encoding/proto/proto.go b/encoding/proto/proto.go index f091c77ae..465a44b63 100644 --- a/encoding/proto/proto.go +++ b/encoding/proto/proto.go @@ -21,6 +21,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/pilosa/pilosa/v2" + "github.com/pilosa/pilosa/v2/disco" "github.com/pilosa/pilosa/v2/internal" pnet "github.com/pilosa/pilosa/v2/net" "github.com/pilosa/pilosa/v2/pql" @@ -708,7 +709,7 @@ func (s Serializer) encodeNode(m *topology.Node) *internal.Node { return &internal.Node{ ID: n.ID, URI: s.encodeURI(n.URI), - State: n.State, + State: string(n.State), GRPCURI: s.encodeURI(n.GRPCURI), } } @@ -1077,7 +1078,7 @@ func (s Serializer) decodeNode(node *internal.Node, m *topology.Node) { m.ID = node.ID s.decodeURI(node.URI, &m.URI) s.decodeURI(node.GRPCURI, &m.GRPCURI) - m.State = node.State + m.State = disco.NodeState(node.State) } func (s Serializer) decodeURI(i *internal.URI, m *pnet.URI) { diff --git a/executor.go b/executor.go index f52a5083d..4fccfa9b3 100644 --- a/executor.go +++ b/executor.go @@ -26,6 +26,7 @@ import ( "time" "unsafe" + "github.com/pilosa/pilosa/v2/disco" "github.com/pilosa/pilosa/v2/pql" pb "github.com/pilosa/pilosa/v2/proto" "github.com/pilosa/pilosa/v2/roaring" @@ -5527,9 +5528,7 @@ loop: // If the node being considered is in any state other than STARTED, // then exclude it from the map. This way, one of that node's // healthy replicas will be included instead. - // TODO: check state once stator is implemented - //if topology.Nodes(nodes).ContainsID(node.ID) && node.State == disco.NodeStateStarted { - if topology.Nodes(nodes).ContainsID(node.ID) { + if topology.Nodes(nodes).ContainsID(node.ID) && node.State == disco.NodeStateStarted { m[node] = append(m[node], shard) continue loop } diff --git a/server.go b/server.go index 2803a2c5d..ee783d2ec 100644 --- a/server.go +++ b/server.go @@ -565,7 +565,7 @@ func (s *Server) Open() error { ID: s.nodeID, URI: s.uri, GRPCURI: s.grpcURI, - State: string(disco.NodeStateUnknown), + State: disco.NodeStateUnknown, IsPrimary: s.IsPrimary(), } diff --git a/topology/node.go b/topology/node.go index c691c18a3..6fde62c7c 100644 --- a/topology/node.go +++ b/topology/node.go @@ -17,16 +17,17 @@ package topology import ( "fmt" + "github.com/pilosa/pilosa/v2/disco" "github.com/pilosa/pilosa/v2/net" ) // Node represents a node in the cluster. type Node struct { - ID string `json:"id"` - URI net.URI `json:"uri"` - GRPCURI net.URI `json:"grpc-uri"` - IsPrimary bool `json:"isPrimary"` - State string `json:"state"` + ID string `json:"id"` + URI net.URI `json:"uri"` + GRPCURI net.URI `json:"grpc-uri"` + IsPrimary bool `json:"isPrimary"` + State disco.NodeState `json:"state"` } func (n *Node) Clone() *Node {