Skip to content

Commit b90fe2c

Browse files
committed
refactor: use v2 Port type
1 parent d60da59 commit b90fe2c

2 files changed

Lines changed: 19 additions & 14 deletions

File tree

rust/operator-binary/src/controller/build/role.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
//! port name/number mapping. These are operator/product knowledge, kept out of the `crd` module
33
//! so it stays a pure API definition.
44
5+
use stackable_operator::v2::types::common::Port;
6+
57
use crate::crd::{
68
HBASE_MASTER_METRICS_PORT, HBASE_MASTER_PORT, HBASE_MASTER_UI_PORT,
79
HBASE_REGIONSERVER_METRICS_PORT, HBASE_REGIONSERVER_PORT, HBASE_REGIONSERVER_UI_PORT,
@@ -29,7 +31,7 @@ impl HbaseRole {
2931
///
3032
/// Hbase versions 2.6.* will have two ports for each role. The metrics are available on the
3133
/// UI port.
32-
pub fn ports(&self, https_enabled: bool) -> Vec<(String, u16)> {
34+
pub fn ports(&self, https_enabled: bool) -> Vec<(String, Port)> {
3335
vec![
3436
(self.data_port_name(https_enabled), self.data_port()),
3537
(
@@ -39,7 +41,7 @@ impl HbaseRole {
3941
]
4042
}
4143

42-
pub fn data_port(&self) -> u16 {
44+
pub fn data_port(&self) -> Port {
4345
match self {
4446
HbaseRole::Master => HBASE_MASTER_PORT,
4547
HbaseRole::RegionServer => HBASE_REGIONSERVER_PORT,
@@ -60,7 +62,7 @@ impl HbaseRole {
6062
}
6163
}
6264

63-
pub fn ui_port(&self) -> u16 {
65+
pub fn ui_port(&self) -> Port {
6466
match self {
6567
HbaseRole::Master => HBASE_MASTER_UI_PORT,
6668
HbaseRole::RegionServer => HBASE_REGIONSERVER_UI_PORT,
@@ -77,7 +79,7 @@ impl HbaseRole {
7779
}
7880
}
7981

80-
pub fn metrics_port(&self) -> u16 {
82+
pub fn metrics_port(&self) -> Port {
8183
match self {
8284
HbaseRole::Master => HBASE_MASTER_METRICS_PORT,
8385
HbaseRole::RegionServer => HBASE_REGIONSERVER_METRICS_PORT,

rust/operator-binary/src/crd/mod.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ use stackable_operator::{
2727
v2::{
2828
config_overrides::KeyValueConfigOverrides,
2929
role_utils::JavaCommonConfig,
30-
types::kubernetes::{ConfigMapName, ListenerClassName, SecretClassName},
30+
types::{
31+
common::Port,
32+
kubernetes::{ConfigMapName, ListenerClassName, SecretClassName},
33+
},
3134
},
3235
versioned::versioned,
3336
};
@@ -56,18 +59,18 @@ pub const HBASE_CLUSTER_DISTRIBUTED: &str = "hbase.cluster.distributed";
5659
pub const HBASE_ROOTDIR: &str = "hbase.rootdir";
5760
const DEFAULT_HBASE_ROOTDIR: &str = "/hbase";
5861

59-
pub const HBASE_MASTER_PORT: u16 = 16000;
62+
pub const HBASE_MASTER_PORT: Port = Port(16000);
6063
// HBase always uses 16010, regardless of http or https. On 2024-01-17 we decided in Arch-meeting that we want to stick
6164
// the port numbers to what the product is doing, so we get the least surprise for users - even when this means we have
6265
// inconsistency between Stackable products.
63-
pub const HBASE_MASTER_UI_PORT: u16 = 16010;
64-
pub const HBASE_MASTER_METRICS_PORT: u16 = 16010;
65-
pub const HBASE_REGIONSERVER_PORT: u16 = 16020;
66-
pub const HBASE_REGIONSERVER_UI_PORT: u16 = 16030;
67-
pub const HBASE_REGIONSERVER_METRICS_PORT: u16 = 16030;
68-
pub const HBASE_REST_PORT: u16 = 8080;
69-
pub const HBASE_REST_UI_PORT: u16 = 8085;
70-
pub const HBASE_REST_METRICS_PORT: u16 = 8085;
66+
pub const HBASE_MASTER_UI_PORT: Port = Port(16010);
67+
pub const HBASE_MASTER_METRICS_PORT: Port = Port(16010);
68+
pub const HBASE_REGIONSERVER_PORT: Port = Port(16020);
69+
pub const HBASE_REGIONSERVER_UI_PORT: Port = Port(16030);
70+
pub const HBASE_REGIONSERVER_METRICS_PORT: Port = Port(16030);
71+
pub const HBASE_REST_PORT: Port = Port(8080);
72+
pub const HBASE_REST_UI_PORT: Port = Port(8085);
73+
pub const HBASE_REST_METRICS_PORT: Port = Port(8085);
7174
pub const LISTENER_VOLUME_NAME: &str = "listener";
7275
pub const LISTENER_VOLUME_DIR: &str = "/stackable/listener";
7376

0 commit comments

Comments
 (0)