|
1 | 1 | use security::AuthenticationConfig; |
2 | 2 | use serde::{Deserialize, Serialize}; |
3 | | -use shell_escape::escape; |
4 | 3 | use stackable_operator::{ |
5 | 4 | commons::{ |
6 | 5 | affinity::StackableAffinity, |
@@ -66,9 +65,6 @@ pub const HBASE_REST_METRICS_PORT: u16 = 8085; |
66 | 65 | pub const LISTENER_VOLUME_NAME: &str = "listener"; |
67 | 66 | pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener"; |
68 | 67 |
|
69 | | -const DEFAULT_REGION_MOVER_TIMEOUT: Duration = Duration::from_minutes_unchecked(59); |
70 | | -const DEFAULT_REGION_MOVER_DELTA_TO_SHUTDOWN: Duration = Duration::from_minutes_unchecked(1); |
71 | | - |
72 | 68 | const DEFAULT_LISTENER_CLASS: &str = "cluster-internal"; |
73 | 69 |
|
74 | 70 | fn default_hbase_rootdir() -> String { |
@@ -462,17 +458,17 @@ pub struct HbaseConfig { |
462 | 458 | )] |
463 | 459 | pub struct RegionMover { |
464 | 460 | /// Move local regions to other servers before terminating a region server's pod. |
465 | | - run_before_shutdown: bool, |
| 461 | + pub run_before_shutdown: bool, |
466 | 462 |
|
467 | 463 | /// Maximum number of threads to use for moving regions. |
468 | | - max_threads: u16, |
| 464 | + pub max_threads: u16, |
469 | 465 |
|
470 | 466 | /// If enabled (default), the region mover will confirm that regions are available on the |
471 | 467 | /// source as well as the target pods before and after the move. |
472 | | - ack: bool, |
| 468 | + pub ack: bool, |
473 | 469 |
|
474 | 470 | #[fragment_attrs(serde(flatten))] |
475 | | - cli_opts: Option<RegionMoverExtraCliOpts>, |
| 471 | + pub cli_opts: Option<RegionMoverExtraCliOpts>, |
476 | 472 | } |
477 | 473 |
|
478 | 474 | #[derive(Clone, Debug, Eq, Deserialize, JsonSchema, PartialEq, Serialize)] |
@@ -602,61 +598,6 @@ impl AnyServiceConfig { |
602 | 598 | AnyServiceConfig::RestServer(config) => config.hbase_rootdir.clone(), |
603 | 599 | } |
604 | 600 | } |
605 | | - |
606 | | - /// Returns command line arguments to pass on to the region mover tool. |
607 | | - /// The following arguments are excluded because they are already part of the |
608 | | - /// hbase-entrypoint.sh script. |
609 | | - /// The most important argument, '--regionserverhost' can only be computed on the Pod |
610 | | - /// because it contains the pod's hostname. |
611 | | - /// |
612 | | - /// Returns an empty string if the region mover is disabled or any other role is "self". |
613 | | - pub fn region_mover_args(&self) -> String { |
614 | | - match self { |
615 | | - AnyServiceConfig::RegionServer(config) => { |
616 | | - if config.region_mover.run_before_shutdown { |
617 | | - let timeout = config |
618 | | - .graceful_shutdown_timeout |
619 | | - .map(|d| { |
620 | | - if d.as_secs() <= DEFAULT_REGION_MOVER_DELTA_TO_SHUTDOWN.as_secs() { |
621 | | - d.as_secs() |
622 | | - } else { |
623 | | - d.as_secs() - DEFAULT_REGION_MOVER_DELTA_TO_SHUTDOWN.as_secs() |
624 | | - } |
625 | | - }) |
626 | | - .unwrap_or(DEFAULT_REGION_MOVER_TIMEOUT.as_secs()); |
627 | | - let mut command = vec![ |
628 | | - "--maxthreads".to_string(), |
629 | | - config.region_mover.max_threads.to_string(), |
630 | | - "--timeout".to_string(), |
631 | | - timeout.to_string(), |
632 | | - ]; |
633 | | - if !config.region_mover.ack { |
634 | | - command.push("--noack".to_string()); |
635 | | - } |
636 | | - |
637 | | - command.extend( |
638 | | - config |
639 | | - .region_mover |
640 | | - .cli_opts |
641 | | - .iter() |
642 | | - .flat_map(|o| o.additional_mover_options.clone()) |
643 | | - .map(|s| escape(std::borrow::Cow::Borrowed(&s)).to_string()), |
644 | | - ); |
645 | | - command.join(" ") |
646 | | - } else { |
647 | | - "".to_string() |
648 | | - } |
649 | | - } |
650 | | - _ => "".to_string(), |
651 | | - } |
652 | | - } |
653 | | - |
654 | | - pub fn run_region_mover(&self) -> bool { |
655 | | - match self { |
656 | | - AnyServiceConfig::RegionServer(config) => config.region_mover.run_before_shutdown, |
657 | | - _ => false, |
658 | | - } |
659 | | - } |
660 | 601 | } |
661 | 602 |
|
662 | 603 | #[cfg(test)] |
|
0 commit comments