temporarily have cluster implement Noder

This commit is contained in:
Travis 2021-01-07 13:45:46 -06:00
parent 10380a1da1
commit 4355bdd8f0
No known key found for this signature in database
GPG key ID: 37080CC2042BA34E
2 changed files with 29 additions and 7 deletions

View file

@ -73,6 +73,8 @@ type nodeAction struct {
// cluster represents a collection of nodes.
type cluster struct { // nolint: maligned
noder topology.Noder
id string
Node *topology.Node
nodes []*topology.Node
@ -133,7 +135,7 @@ type cluster struct { // nolint: maligned
// newCluster returns a new instance of Cluster with defaults.
func newCluster() *cluster {
return &cluster{
c := &cluster{
Hasher: &Jmphasher{},
partitionN: topology.DefaultPartitionN,
ReplicaN: 1,
@ -152,6 +154,8 @@ func newCluster() *cluster {
confirmDownRetries: defaultConfirmDownRetries,
confirmDownSleep: defaultConfirmDownSleep,
}
c.noder = c // TODO: this is temporary until etcd fully implements noder
return c
}
// initializeAntiEntropy is called by the anti entropy routine when it starts.
@ -1926,6 +1930,27 @@ func (t *Topology) SetNodeState(nodeID string, state string) {}
///////////////////////////////////////////
///////////////////////////////////////////
// Cluster implements the Noder interface.
// This is temporary and should be removed once etcd is fully implemented as
// noder.
// SetNodes implements the Noder interface.
func (c *cluster) SetNodes(nodes []*topology.Node) {}
// AppendNode implements the Noder interface.
func (c *cluster) AppendNode(node *topology.Node) {}
// RemoveNode implements the Noder interface.
func (c *cluster) RemoveNode(nodeID string) bool {
return false
}
// SetNodeState implements the Noder interface.
func (c *cluster) SetNodeState(nodeID string, state string) {}
///////////////////////////////////////////
func (t *Topology) GetNodeIDs() []string {
return t.nodeIDs
}

View file

@ -3556,8 +3556,7 @@ func (s *fragmentSyncer) syncFragment() error {
defer span.Finish()
// Create a snapshot of the cluster to use for node/partition calculations.
// TODO: this needs to use Cluster.noder once that has been implemented.
snap := topology.NewClusterSnapshot(topology.NewLocalNoder(s.Cluster.Nodes()), s.Cluster.Hasher, s.Cluster.ReplicaN)
snap := topology.NewClusterSnapshot(s.Cluster.noder, s.Cluster.Hasher, s.Cluster.ReplicaN)
// Determine replica set.
nodes := snap.ShardNodes(s.Fragment.index(), s.Fragment.shard)
@ -3677,8 +3676,7 @@ func (s *fragmentSyncer) syncBlockFromPrimary(id int) error {
f := s.Fragment
// Create a snapshot of the cluster to use for node/partition calculations.
// TODO: this needs to use Cluster.noder once that has been implemented.
snap := topology.NewClusterSnapshot(topology.NewLocalNoder(s.Cluster.Nodes()), s.Cluster.Hasher, s.Cluster.ReplicaN)
snap := topology.NewClusterSnapshot(s.Cluster.noder, s.Cluster.Hasher, s.Cluster.ReplicaN)
// Determine replica set. Return early if this is not
// the primary node.
@ -3730,8 +3728,7 @@ func (s *fragmentSyncer) syncBlock(id int) error {
f := s.Fragment
// Create a snapshot of the cluster to use for node/partition calculations.
// TODO: this needs to use Cluster.noder once that has been implemented.
snap := topology.NewClusterSnapshot(topology.NewLocalNoder(s.Cluster.Nodes()), s.Cluster.Hasher, s.Cluster.ReplicaN)
snap := topology.NewClusterSnapshot(s.Cluster.noder, s.Cluster.Hasher, s.Cluster.ReplicaN)
// Read pairs from each remote block.
var uris []*pnet.URI