@@ -10,8 +10,7 @@ for queries with non-local consistency mode is also supported.
1010` builder() ` method of ` DefaultPolicy ` returns a new instance of
1111` DefaultPolicyBuilder ` with the following default values:
1212
13- - ` preferred_datacenter ` : ` None `
14- - ` preferred_rack ` : ` None `
13+ - ` preferences ` : no particular datacenter/rack preference
1514- ` is_token_aware ` : ` true `
1615- ` permit_dc_failover ` : ` false `
1716- ` latency_awareness ` : ` None `
@@ -25,8 +24,7 @@ You can use the builder methods to configure the desired settings and create a
2524use scylla :: load_balancing :: DefaultPolicy ;
2625
2726let default_policy = DefaultPolicy :: builder ()
28- . prefer_datacenter (" dc1" . to_string ())
29- . prefer_rack (" rack1" . to_string ())
27+ . prefer_datacenter_and_rack (" dc1" . to_string (), " rack1" . to_string ())
3028 . token_aware (true )
3129 . permit_dc_failover (true )
3230 . build ();
@@ -35,36 +33,40 @@ let default_policy = DefaultPolicy::builder()
3533
3634### Semantics of ` DefaultPolicy `
3735
38- #### Preferred Datacenter
36+ #### Preferences
37+
38+ The ` preferences ` field in ` DefaultPolicy ` allows the load balancing
39+ policy to prioritize nodes based on their location. It has three modes:
40+
41+ - no preference
42+ - preferred datacenter
43+ - preferred datacenter and rack
3944
40- The ` preferred_datacenter ` field in ` DefaultPolicy ` allows the load balancing
41- policy to prioritize nodes based on their location. When a preferred datacenter
42- is set, the policy will treat nodes in that datacenter as "local" nodes, and
43- nodes in other datacenters as "remote" nodes. This affects the order in which
44- nodes are returned by the policy when selecting replicas for read or write
45- operations. If no preferred datacenter is specified, the policy will treat all
46- nodes as local nodes.
45+ When a datacenter ` "my_dc" ` is preferred, the policy will treat nodes in ` "my_dc" `
46+ as "local" nodes, and nodes in other datacenters as "remote" nodes. This affects
47+ the order in which nodes are returned by the policy when selecting nodes for
48+ read or write operations. If no datacenter is preferred, the policy will treat
49+ all nodes as local nodes.
50+
51+ ` preferences ` allow the load balancing policy to prioritize nodes based on their
52+ availability zones (racks) in the preferred datacenter, too. When a datacenter
53+ and a rack are preferred, the policy will first return replicas in the local rack
54+ in the preferred datacenter, and then the other replicas in the datacenter
55+ (followed by remote replicas). After replicas, the other node will be ordered
56+ similarly, too (local rack nodes, local datacenter nodes, remote nodes).
4757
4858When datacenter failover is disabled (` permit_dc_failover ` is set to
4959false), the default policy will only include local nodes in load balancing
5060plans. Remote nodes will be excluded, even if they are alive and available to
5161serve requests.
5262
53- #### Preferred Rack
54-
55- The ` preferred_rack ` field in ` DefaultPolicy ` allows the load balancing policy to
56- prioritize nodes based on their availability zones in the preferred datacenter.
57- When a preferred rack is set, the policy will first return replicas in the local rack
58- in the preferred datacenter, and then the other replicas in the datacenter.
59- When a preferred datacenter is not set, setting preferred rack will not have any effect.
60-
6163#### Datacenter Failover
6264
6365In the event of a datacenter outage or network failure, the nodes in that
6466datacenter may become unavailable, and clients may no longer be able to access
65- the data stored on those nodes. To address this, the ` DefaultPolicy ` supports datacenter
66- failover, which allows to route requests to nodes in other datacenters if the
67- local nodes are unavailable.
67+ the data stored on those nodes. To address this, the ` DefaultPolicy ` supports
68+ datacenter failover, which allows to route requests to nodes in other datacenters
69+ if the local nodes are unavailable.
6870
6971Datacenter failover can be enabled in ` DefaultPolicy ` by ` permit_dc_failover `
7072setting in the builder. When this flag is set, the policy will prefer to return
0 commit comments