Check state in shardsByNode once stator is implemented

This commit is contained in:
Kuba Podgórski 2021-02-17 16:01:22 +01:00
parent b17d2b6d18
commit bfc24a1745
5 changed files with 14 additions and 13 deletions

View file

@ -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
}

View file

@ -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) {

View file

@ -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
}

View file

@ -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(),
}

View file

@ -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 {