mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-10-09 12:27:52 +00:00
Add Cluster.UnavailableNodes support to skip reads on certain nodes.
This commit is contained in:
parent
0ce5245e5a
commit
65760496fe
3 changed files with 21 additions and 3 deletions
|
|
@ -83,6 +83,9 @@ func (a Nodes) Clone() []*Node {
|
|||
type Cluster struct {
|
||||
Nodes []*Node
|
||||
|
||||
// UnavailableNodes do not receive read queries.
|
||||
UnavailableNodes []*Node
|
||||
|
||||
// Hashing algorithm used to assign partitions to nodes.
|
||||
Hasher Hasher
|
||||
|
||||
|
|
|
|||
11
config.go
11
config.go
|
|
@ -13,9 +13,10 @@ type Config struct {
|
|||
Host string `toml:"host"`
|
||||
|
||||
Cluster struct {
|
||||
ReplicaN int `toml:"replicas"`
|
||||
Nodes []*ConfigNode `toml:"node"`
|
||||
PollingInterval Duration `toml:"polling-interval"`
|
||||
ReplicaN int `toml:"replicas"`
|
||||
Nodes []*ConfigNode `toml:"node"`
|
||||
UnavailableNodes []*ConfigNode `toml:"unavailable-node"`
|
||||
PollingInterval Duration `toml:"polling-interval"`
|
||||
} `toml:"cluster"`
|
||||
|
||||
Plugins struct {
|
||||
|
|
@ -59,6 +60,10 @@ func (c *Config) PilosaCluster() *Cluster {
|
|||
cluster.Nodes = append(cluster.Nodes, &Node{Host: n.Host})
|
||||
}
|
||||
|
||||
for _, u := range c.Cluster.UnavailableNodes {
|
||||
cluster.UnavailableNodes = append(cluster.UnavailableNodes, &Node{Host: u.Host})
|
||||
}
|
||||
|
||||
return cluster
|
||||
}
|
||||
|
||||
|
|
|
|||
10
executor.go
10
executor.go
|
|
@ -718,6 +718,16 @@ func (e *Executor) mapReduce(ctx context.Context, db string, slices []uint64, c
|
|||
var nodes []*Node
|
||||
if !opt.Remote {
|
||||
nodes = Nodes(e.Cluster.Nodes).Clone()
|
||||
|
||||
// If this is a read operation, don't send the query to nodes
|
||||
// marked as unavailable in the config file.
|
||||
switch c.(type) {
|
||||
case pql.BitmapCall, *pql.TopN, *pql.Count:
|
||||
for _, u := range e.Cluster.UnavailableNodes {
|
||||
nodes = Nodes(nodes).FilterHost(u.Host)
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
nodes = []*Node{e.Cluster.NodeByHost(e.Host)}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue