@@ -106,9 +106,6 @@ pub enum Error {
106106 #[ snafu( display( "the HBase role [{role}] is missing from spec" ) ) ]
107107 MissingHbaseRole { role : String } ,
108108
109- #[ snafu( display( "the HBase role group [{role_group}] is missing from spec" ) ) ]
110- MissingHbaseRoleGroup { role_group : String } ,
111-
112109 #[ snafu( display( "fragment validation failure" ) ) ]
113110 FragmentValidationFailure { source : ValidationError } ,
114111
@@ -315,7 +312,7 @@ fn default_regionserver_config(
315312 hdfs_discovery_cm_name,
316313 ) ,
317314 graceful_shutdown_timeout : Some ( * DEFAULT_REGION_SERVER_GRACEFUL_SHUTDOWN_TIMEOUT ) ,
318- region_mover : Some ( RegionMover :: default ( ) ) ,
315+ region_mover : RegionMoverFragment :: default ( ) ,
319316 }
320317}
321318
@@ -512,44 +509,56 @@ impl Configuration for HbaseConfigFragment {
512509 }
513510}
514511
515- #[ derive( Clone , Debug , JsonSchema , PartialEq , Serialize , Deserialize ) ]
516- #[ serde( rename_all = "camelCase" ) ]
512+ #[ derive( Fragment , Clone , Debug , JsonSchema , PartialEq , Serialize , Deserialize ) ]
513+ #[ fragment_attrs(
514+ derive(
515+ Clone ,
516+ Debug ,
517+ Default ,
518+ Deserialize ,
519+ Merge ,
520+ JsonSchema ,
521+ PartialEq ,
522+ Serialize
523+ ) ,
524+ serde( rename_all = "camelCase" )
525+ ) ]
517526pub struct RegionMover {
518527 /// Move local regions to other servers before terminating a region server's pod.
519- run_before_shutdown : bool ,
528+ run_before_shutdown : Option < bool > ,
520529
521530 /// Maximum number of threads to use for moving regions.
522- max_threads : u16 ,
531+ max_threads : Option < u16 > ,
523532
524533 /// If enabled (default), the region mover will confirm that regions are available on the
525534 /// source as well as the target pods before and after the move.
526- ack : bool ,
535+ ack : Option < bool > ,
527536
528537 /// Additional options to pass to the region mover.
529538 #[ serde( default ) ]
530- extra_opts : Vec < String > ,
539+ extra_opts : Option < RegionMoverExtraCliOpts > ,
540+ }
541+
542+ #[ derive( Clone , Debug , Eq , Deserialize , JsonSchema , PartialEq , Serialize ) ]
543+ #[ serde( rename_all = "camelCase" ) ]
544+ #[ schemars( deny_unknown_fields) ]
545+ pub struct RegionMoverExtraCliOpts {
546+ #[ serde( flatten) ]
547+ pub cli_opts : Vec < String > ,
531548}
532549
550+ impl Atomic for RegionMoverExtraCliOpts { }
551+
533552impl Default for RegionMover {
534553 fn default ( ) -> Self {
535554 Self {
536- run_before_shutdown : false ,
537- max_threads : 1 ,
538- ack : true ,
539- extra_opts : vec ! [ ] ,
555+ run_before_shutdown : Some ( false ) ,
556+ max_threads : Some ( 1 ) ,
557+ ack : Some ( true ) ,
558+ extra_opts : None ,
540559 }
541560 }
542561}
543- impl Atomic for RegionMover { }
544-
545- impl Merge for RegionMover {
546- fn merge ( & mut self , other : & Self ) {
547- self . run_before_shutdown = other. run_before_shutdown ;
548- self . max_threads = other. max_threads ;
549- self . ack = other. ack ;
550- self . extra_opts . extend ( other. extra_opts . clone ( ) ) ;
551- }
552- }
553562
554563#[ derive( Clone , Debug , Default , Fragment , JsonSchema , PartialEq ) ]
555564#[ fragment_attrs(
@@ -1136,7 +1145,8 @@ impl AnyServiceConfig {
11361145 pub fn region_mover_args ( & self ) -> String {
11371146 match self {
11381147 AnyServiceConfig :: RegionServer ( config) => {
1139- if config. region_mover . run_before_shutdown {
1148+ // TODO: is unwrap_or() the correct way to do it ? (same below)
1149+ if config. region_mover . run_before_shutdown . unwrap_or ( false ) {
11401150 let timeout = config
11411151 . graceful_shutdown_timeout
11421152 . map ( |d| {
@@ -1149,11 +1159,11 @@ impl AnyServiceConfig {
11491159 . unwrap_or ( DEFAULT_REGION_MOVER_TIMEOUT . as_secs ( ) ) ;
11501160 let mut command = vec ! [
11511161 "--maxthreads" . to_string( ) ,
1152- config. region_mover. max_threads. to_string( ) ,
1162+ config. region_mover. max_threads. unwrap_or ( 1 ) . to_string( ) ,
11531163 "--timeout" . to_string( ) ,
11541164 timeout. to_string( ) ,
11551165 ] ;
1156- if !config. region_mover . ack {
1166+ if !config. region_mover . ack . unwrap_or ( true ) {
11571167 command. push ( "--noack" . to_string ( ) ) ;
11581168 }
11591169
@@ -1162,7 +1172,8 @@ impl AnyServiceConfig {
11621172 . region_mover
11631173 . extra_opts
11641174 . iter ( )
1165- . map ( |s| escape ( std:: borrow:: Cow :: Borrowed ( s) ) . to_string ( ) ) ,
1175+ . flat_map ( |o| o. cli_opts . clone ( ) )
1176+ . map ( |s| escape ( std:: borrow:: Cow :: Borrowed ( & s) ) . to_string ( ) ) ,
11661177 ) ;
11671178 command. join ( " " )
11681179 } else {
@@ -1175,7 +1186,9 @@ impl AnyServiceConfig {
11751186
11761187 pub fn run_region_mover ( & self ) -> bool {
11771188 match self {
1178- AnyServiceConfig :: RegionServer ( config) => config. region_mover . run_before_shutdown ,
1189+ AnyServiceConfig :: RegionServer ( config) => {
1190+ config. region_mover . run_before_shutdown . unwrap_or ( false )
1191+ }
11791192 _ => false ,
11801193 }
11811194 }
@@ -1225,6 +1238,8 @@ spec:
12251238 config:
12261239 logging:
12271240 enableVectorAgent: False
1241+ regionMover:
1242+ runBeforeShutdown: false
12281243 roleGroups:
12291244 default:
12301245 replicas: 1
0 commit comments