11use futures:: Future ;
2- use itertools:: Itertools ;
3- use scylla:: load_balancing:: LoadBalancingPolicy ;
4- use scylla:: routing:: Shard ;
5- use scylla:: transport:: NodeRef ;
62use std:: collections:: HashMap ;
73use std:: env;
84use std:: net:: SocketAddr ;
@@ -19,66 +15,6 @@ pub(crate) fn setup_tracing() {
1915 . try_init ( ) ;
2016}
2117
22- fn with_pseudorandom_shard ( node : NodeRef ) -> ( NodeRef , Option < Shard > ) {
23- let nr_shards = node
24- . sharder ( )
25- . map ( |sharder| sharder. nr_shards . get ( ) )
26- . unwrap_or ( 1 ) ;
27- ( node, Some ( ( ( nr_shards - 1 ) % 42 ) as Shard ) )
28- }
29-
30- #[ derive( Debug ) ]
31- pub ( crate ) struct FixedOrderLoadBalancer ;
32- impl LoadBalancingPolicy for FixedOrderLoadBalancer {
33- fn pick < ' a > (
34- & ' a self ,
35- _info : & ' a scylla:: load_balancing:: RoutingInfo ,
36- cluster : & ' a scylla:: transport:: ClusterData ,
37- ) -> Option < ( NodeRef < ' a > , Option < Shard > ) > {
38- cluster
39- . get_nodes_info ( )
40- . iter ( )
41- . sorted_by ( |node1, node2| Ord :: cmp ( & node1. address , & node2. address ) )
42- . next ( )
43- . map ( with_pseudorandom_shard)
44- }
45-
46- fn fallback < ' a > (
47- & ' a self ,
48- _info : & ' a scylla:: load_balancing:: RoutingInfo ,
49- cluster : & ' a scylla:: transport:: ClusterData ,
50- ) -> scylla:: load_balancing:: FallbackPlan < ' a > {
51- Box :: new (
52- cluster
53- . get_nodes_info ( )
54- . iter ( )
55- . sorted_by ( |node1, node2| Ord :: cmp ( & node1. address , & node2. address ) )
56- . map ( with_pseudorandom_shard) ,
57- )
58- }
59-
60- fn on_query_success (
61- & self ,
62- _: & scylla:: load_balancing:: RoutingInfo ,
63- _: std:: time:: Duration ,
64- _: NodeRef < ' _ > ,
65- ) {
66- }
67-
68- fn on_query_failure (
69- & self ,
70- _: & scylla:: load_balancing:: RoutingInfo ,
71- _: std:: time:: Duration ,
72- _: NodeRef < ' _ > ,
73- _: & scylla_cql:: errors:: QueryError ,
74- ) {
75- }
76-
77- fn name ( & self ) -> String {
78- "FixedOrderLoadBalancer" . to_string ( )
79- }
80- }
81-
8218pub ( crate ) async fn test_with_3_node_cluster < F , Fut > (
8319 shard_awareness : ShardAwareness ,
8420 test : F ,
0 commit comments