@@ -139,7 +139,24 @@ that case, the driver will connect to 127.0.0.1:9042, and use that node's datace
139
139
for a better out-of-the-box experience for users who have just downloaded the driver; beyond that
140
140
initial development phase, you should provide explicit contact points and a local datacenter.
141
141
142
- ##### Finding the local datacenter
142
+ ##### Rack awareness
143
+
144
+ The ` DefaultLoadBalancingPolicy ` and implicitly the ` DcInferringLoadBalancingPolicy ` prioritize replicas that are in the
145
+ local datacenter, however, sometimes there is a need to prioritize replicas that are in the local rack and to not send
146
+ queries to other replicas in the local datacenter. This will allow to avoid high network traffic between racks/availability zones
147
+ and thus will reduce data transfer costs. The rack-awareness feature is optional and to enable it the local rack should
148
+ be supplied through the configuration:
149
+
150
+ ```
151
+ datastax-java-driver.basic.load-balancing-policy {
152
+ local-rack = rack1
153
+ }
154
+ ```
155
+
156
+ The feature is disabled by default and unlike the local datacenter it will not be implicitly fetched from the provided
157
+ contact points.
158
+
159
+ ##### Finding the local datacenter & local rack
143
160
144
161
To check which datacenters are defined in a given cluster, you can run [ ` nodetool status ` ] . It will
145
162
print information about each node in the cluster, grouped by datacenters. Here is an example:
@@ -165,17 +182,17 @@ UN <IP5> 1.5 TB 256 ? <ID5> rack2
165
182
UN <IP6> 1.5 TB 256 ? <ID6> rack3
166
183
```
167
184
168
- To find out which datacenter should be considered local, you need to first determine which nodes the
169
- driver is going to be co-located with, then choose their datacenter as local. In case of doubt, you
185
+ To find out which datacenter and rack(availability zone) should be considered local, you need to first determine which nodes the
186
+ driver is going to be co-located with, then choose their datacenter and rack as local. In case of doubt, you
170
187
can also use [ cqlsh] ; if cqlsh is co-located too in the same datacenter, simply run the command
171
188
below:
172
189
173
190
```
174
- cqlsh> select data_center from system.local;
191
+ cqlsh> select data_center,rack from system.local;
175
192
176
- data_center
177
- -------------
178
- DC1
193
+ data_center | rack
194
+ -------------+-------
195
+ datacenter1 | rack1
179
196
```
180
197
181
198
#### Cross-datacenter failover
0 commit comments