17
17
18
18
use std:: time:: { Duration , SystemTime , UNIX_EPOCH } ;
19
19
20
- use crate :: cluster:: TaskDistribution ;
21
-
22
20
#[ cfg( not( test) ) ]
23
21
use ballista_core:: error:: BallistaError ;
24
22
use ballista_core:: error:: Result ;
25
23
use ballista_core:: serde:: protobuf;
26
24
27
25
use crate :: cluster:: ClusterState ;
28
- use crate :: config:: SlotsPolicy ;
26
+ use crate :: config:: TaskDistribution ;
29
27
30
28
use crate :: state:: execution_graph:: RunningTaskInfo ;
31
29
use ballista_core:: serde:: protobuf:: executor_grpc_client:: ExecutorGrpcClient ;
@@ -101,13 +99,8 @@ pub struct ExecutorManager {
101
99
impl ExecutorManager {
102
100
pub ( crate ) fn new (
103
101
cluster_state : Arc < dyn ClusterState > ,
104
- slots_policy : SlotsPolicy ,
102
+ task_distribution : TaskDistribution ,
105
103
) -> Self {
106
- let task_distribution = match slots_policy {
107
- SlotsPolicy :: Bias => TaskDistribution :: Bias ,
108
- SlotsPolicy :: RoundRobin => TaskDistribution :: RoundRobin ,
109
- } ;
110
-
111
104
Self {
112
105
task_distribution,
113
106
cluster_state,
@@ -511,7 +504,7 @@ impl ExecutorManager {
511
504
#[ cfg( test) ]
512
505
mod test {
513
506
514
- use crate :: config:: SlotsPolicy ;
507
+ use crate :: config:: TaskDistribution ;
515
508
516
509
use crate :: scheduler_server:: timestamp_secs;
517
510
use crate :: state:: executor_manager:: { ExecutorManager , ExecutorReservation } ;
@@ -525,17 +518,19 @@ mod test {
525
518
526
519
#[ tokio:: test]
527
520
async fn test_reserve_and_cancel ( ) -> Result < ( ) > {
528
- test_reserve_and_cancel_inner ( SlotsPolicy :: Bias ) . await ?;
529
- test_reserve_and_cancel_inner ( SlotsPolicy :: RoundRobin ) . await ?;
521
+ test_reserve_and_cancel_inner ( TaskDistribution :: Bias ) . await ?;
522
+ test_reserve_and_cancel_inner ( TaskDistribution :: RoundRobin ) . await ?;
530
523
531
524
Ok ( ( ) )
532
525
}
533
526
534
- async fn test_reserve_and_cancel_inner ( slots_policy : SlotsPolicy ) -> Result < ( ) > {
527
+ async fn test_reserve_and_cancel_inner (
528
+ task_distribution : TaskDistribution ,
529
+ ) -> Result < ( ) > {
535
530
let cluster = test_cluster_context ( ) ;
536
531
537
532
let executor_manager =
538
- ExecutorManager :: new ( cluster. cluster_state ( ) , slots_policy ) ;
533
+ ExecutorManager :: new ( cluster. cluster_state ( ) , task_distribution ) ;
539
534
540
535
let executors = test_executors ( 10 , 4 ) ;
541
536
@@ -551,7 +546,7 @@ mod test {
551
546
assert_eq ! (
552
547
reservations. len( ) ,
553
548
40 ,
554
- "Expected 40 reservations for policy {slots_policy :?}"
549
+ "Expected 40 reservations for policy {task_distribution :?}"
555
550
) ;
556
551
557
552
// Now cancel them
@@ -563,25 +558,27 @@ mod test {
563
558
assert_eq ! (
564
559
reservations. len( ) ,
565
560
40 ,
566
- "Expected 40 reservations for policy {slots_policy :?}"
561
+ "Expected 40 reservations for policy {task_distribution :?}"
567
562
) ;
568
563
569
564
Ok ( ( ) )
570
565
}
571
566
572
567
#[ tokio:: test]
573
568
async fn test_reserve_partial ( ) -> Result < ( ) > {
574
- test_reserve_partial_inner ( SlotsPolicy :: Bias ) . await ?;
575
- test_reserve_partial_inner ( SlotsPolicy :: RoundRobin ) . await ?;
569
+ test_reserve_partial_inner ( TaskDistribution :: Bias ) . await ?;
570
+ test_reserve_partial_inner ( TaskDistribution :: RoundRobin ) . await ?;
576
571
577
572
Ok ( ( ) )
578
573
}
579
574
580
- async fn test_reserve_partial_inner ( slots_policy : SlotsPolicy ) -> Result < ( ) > {
575
+ async fn test_reserve_partial_inner (
576
+ task_distribution : TaskDistribution ,
577
+ ) -> Result < ( ) > {
581
578
let cluster = test_cluster_context ( ) ;
582
579
583
580
let executor_manager =
584
- ExecutorManager :: new ( cluster. cluster_state ( ) , slots_policy ) ;
581
+ ExecutorManager :: new ( cluster. cluster_state ( ) , task_distribution ) ;
585
582
586
583
let executors = test_executors ( 10 , 4 ) ;
587
584
@@ -621,21 +618,23 @@ mod test {
621
618
622
619
#[ tokio:: test]
623
620
async fn test_reserve_concurrent ( ) -> Result < ( ) > {
624
- test_reserve_concurrent_inner ( SlotsPolicy :: Bias ) . await ?;
625
- test_reserve_concurrent_inner ( SlotsPolicy :: RoundRobin ) . await ?;
621
+ test_reserve_concurrent_inner ( TaskDistribution :: Bias ) . await ?;
622
+ test_reserve_concurrent_inner ( TaskDistribution :: RoundRobin ) . await ?;
626
623
627
624
Ok ( ( ) )
628
625
}
629
626
630
- async fn test_reserve_concurrent_inner ( slots_policy : SlotsPolicy ) -> Result < ( ) > {
627
+ async fn test_reserve_concurrent_inner (
628
+ task_distribution : TaskDistribution ,
629
+ ) -> Result < ( ) > {
631
630
let ( sender, mut receiver) =
632
631
tokio:: sync:: mpsc:: channel :: < Result < Vec < ExecutorReservation > > > ( 1000 ) ;
633
632
634
633
let executors = test_executors ( 10 , 4 ) ;
635
634
636
635
let cluster = test_cluster_context ( ) ;
637
636
let executor_manager =
638
- ExecutorManager :: new ( cluster. cluster_state ( ) , slots_policy ) ;
637
+ ExecutorManager :: new ( cluster. cluster_state ( ) , task_distribution ) ;
639
638
640
639
for ( executor_metadata, executor_data) in executors {
641
640
executor_manager
@@ -670,17 +669,19 @@ mod test {
670
669
671
670
#[ tokio:: test]
672
671
async fn test_register_reserve ( ) -> Result < ( ) > {
673
- test_register_reserve_inner ( SlotsPolicy :: Bias ) . await ?;
674
- test_register_reserve_inner ( SlotsPolicy :: RoundRobin ) . await ?;
672
+ test_register_reserve_inner ( TaskDistribution :: Bias ) . await ?;
673
+ test_register_reserve_inner ( TaskDistribution :: RoundRobin ) . await ?;
675
674
676
675
Ok ( ( ) )
677
676
}
678
677
679
- async fn test_register_reserve_inner ( slots_policy : SlotsPolicy ) -> Result < ( ) > {
678
+ async fn test_register_reserve_inner (
679
+ task_distribution : TaskDistribution ,
680
+ ) -> Result < ( ) > {
680
681
let cluster = test_cluster_context ( ) ;
681
682
682
683
let executor_manager =
683
- ExecutorManager :: new ( cluster. cluster_state ( ) , slots_policy ) ;
684
+ ExecutorManager :: new ( cluster. cluster_state ( ) , task_distribution ) ;
684
685
685
686
let executors = test_executors ( 10 , 4 ) ;
686
687
@@ -702,17 +703,19 @@ mod test {
702
703
703
704
#[ tokio:: test]
704
705
async fn test_ignore_fenced_executors ( ) -> Result < ( ) > {
705
- test_ignore_fenced_executors_inner ( SlotsPolicy :: Bias ) . await ?;
706
- test_ignore_fenced_executors_inner ( SlotsPolicy :: RoundRobin ) . await ?;
706
+ test_ignore_fenced_executors_inner ( TaskDistribution :: Bias ) . await ?;
707
+ test_ignore_fenced_executors_inner ( TaskDistribution :: RoundRobin ) . await ?;
707
708
708
709
Ok ( ( ) )
709
710
}
710
711
711
- async fn test_ignore_fenced_executors_inner ( slots_policy : SlotsPolicy ) -> Result < ( ) > {
712
+ async fn test_ignore_fenced_executors_inner (
713
+ task_distribution : TaskDistribution ,
714
+ ) -> Result < ( ) > {
712
715
let cluster = test_cluster_context ( ) ;
713
716
714
717
let executor_manager =
715
- ExecutorManager :: new ( cluster. cluster_state ( ) , slots_policy ) ;
718
+ ExecutorManager :: new ( cluster. cluster_state ( ) , task_distribution ) ;
716
719
717
720
// Setup two executors initially
718
721
let executors = test_executors ( 2 , 4 ) ;
0 commit comments