22
33## Introduction
44
5- The driver uses a load balancing policy to determine which node(s) to contact
6- when executing a query. Load balancing policies implement the
5+ The driver uses a load balancing policy to determine which node(s) and shard(s)
6+ to contact when executing a query. Load balancing policies implement the
77` LoadBalancingPolicy ` trait, which contains methods to generate a load
88balancing plan based on the query information and the state of the cluster.
99
@@ -12,12 +12,14 @@ being opened. For a node connection blacklist configuration refer to
1212` scylla::transport::host_filter::HostFilter ` , which can be set session-wide
1313using ` SessionBuilder::host_filter ` method.
1414
15+ In this chapter, "target" will refer to a pair ` <node, optional shard> ` .
16+
1517## Plan
1618
1719When a query is prepared to be sent to the database, the load balancing policy
18- constructs a load balancing plan. This plan is essentially a list of nodes to
20+ constructs a load balancing plan. This plan is essentially a list of targets to
1921which the driver will try to send the query. The first elements of the plan are
20- the nodes which are the best to contact (e.g. they might be replicas for the
22+ the targets which are the best to contact (e.g. they might be replicas for the
2123requested data or have the best latency).
2224
2325## Policy
@@ -84,17 +86,16 @@ first element of the load balancing plan is needed, so it's usually unnecessary
8486to compute entire load balancing plan. To optimize this common case, the
8587` LoadBalancingPolicy ` trait provides two methods: ` pick ` and ` fallback ` .
8688
87- ` pick ` returns the first node to contact for a given query, which is usually
88- the best based on a particular load balancing policy. If ` pick ` returns ` None ` ,
89- then ` fallback ` will not be called.
89+ ` pick ` returns the first target to contact for a given query, which is usually
90+ the best based on a particular load balancing policy.
9091
91- ` fallback ` , returns an iterator that provides the rest of the nodes in the load
92- balancing plan. ` fallback ` is called only when using the initial picked node
93- fails (or when executing speculatively).
92+ ` fallback ` , returns an iterator that provides the rest of the targets in the
93+ load balancing plan. ` fallback ` is called when using the initial picked
94+ target fails (or when executing speculatively) or when ` pick ` returned ` None ` .
9495
95- It's possible for the ` fallback ` method to include the same node that was
96+ It's possible for the ` fallback ` method to include the same target that was
9697returned by the ` pick ` method. In such cases, the query execution layer filters
97- out the picked node from the iterator returned by ` fallback ` .
98+ out the picked target from the iterator returned by ` fallback ` .
9899
99100### ` on_query_success ` and ` on_query_failure ` :
100101
0 commit comments