@@ -14,6 +14,30 @@ use crate::{
1414 } ,
1515} ;
1616
17+ // `hbase-site.xml` property keys (the `port` keys carry a `_KEY` suffix to avoid clashing with the
18+ // `Port`-typed `HBASE_*_PORT` constants imported from the `crd` module).
19+ const HBASE_CLIENT_RPC_BIND_ADDRESS : & str = "hbase.client.rpc.bind.address" ;
20+ const HBASE_MASTER_IPC_ADDRESS : & str = "hbase.master.ipc.address" ;
21+ const HBASE_MASTER_IPC_PORT : & str = "hbase.master.ipc.port" ;
22+ const HBASE_MASTER_HOSTNAME : & str = "hbase.master.hostname" ;
23+ const HBASE_MASTER_PORT_KEY : & str = "hbase.master.port" ;
24+ const HBASE_MASTER_INFO_PORT : & str = "hbase.master.info.port" ;
25+ const HBASE_MASTER_BOUND_INFO_PORT : & str = "hbase.master.bound.info.port" ;
26+ const HBASE_REGIONSERVER_IPC_ADDRESS : & str = "hbase.regionserver.ipc.address" ;
27+ const HBASE_REGIONSERVER_IPC_PORT : & str = "hbase.regionserver.ipc.port" ;
28+ const HBASE_UNSAFE_REGIONSERVER_HOSTNAME : & str = "hbase.unsafe.regionserver.hostname" ;
29+ const HBASE_REGIONSERVER_PORT_KEY : & str = "hbase.regionserver.port" ;
30+ const HBASE_REGIONSERVER_INFO_PORT : & str = "hbase.regionserver.info.port" ;
31+ const HBASE_REGIONSERVER_BOUND_INFO_PORT : & str = "hbase.regionserver.bound.info.port" ;
32+ const HBASE_REST_ENDPOINT : & str = "hbase.rest.endpoint" ;
33+
34+ // `hbase-site.xml` property values that recur across roles. The `${env:...}` placeholders are
35+ // resolved by HBase at runtime from the Pod's environment.
36+ const BIND_ALL_ADDRESSES : & str = "0.0.0.0" ;
37+ const ENV_HBASE_SERVICE_HOST : & str = "${env:HBASE_SERVICE_HOST}" ;
38+ const ENV_HBASE_SERVICE_PORT : & str = "${env:HBASE_SERVICE_PORT}" ;
39+ const ENV_HBASE_INFO_PORT : & str = "${env:HBASE_INFO_PORT}" ;
40+
1741/// Renders `hbase-site.xml`.
1842pub fn build (
1943 role : & HbaseRole ,
@@ -38,69 +62,69 @@ pub fn build(
3862 // RPC traffic to happen from the same network interface that
3963 // the RPC server is bound on).
4064 config. insert (
41- "hbase.client.rpc.bind.address" . to_string ( ) ,
65+ HBASE_CLIENT_RPC_BIND_ADDRESS . to_string ( ) ,
4266 "false" . to_string ( ) ,
4367 ) ;
4468
4569 match role {
4670 HbaseRole :: Master => {
4771 config. insert (
48- "hbase.master.ipc.address" . to_string ( ) ,
49- "0.0.0.0" . to_string ( ) ,
72+ HBASE_MASTER_IPC_ADDRESS . to_string ( ) ,
73+ BIND_ALL_ADDRESSES . to_string ( ) ,
5074 ) ;
5175 config. insert (
52- "hbase.master.ipc.port" . to_string ( ) ,
76+ HBASE_MASTER_IPC_PORT . to_string ( ) ,
5377 HBASE_MASTER_PORT . to_string ( ) ,
5478 ) ;
5579 config. insert (
56- "hbase.master.hostname" . to_string ( ) ,
57- "${env:HBASE_SERVICE_HOST}" . to_string ( ) ,
80+ HBASE_MASTER_HOSTNAME . to_string ( ) ,
81+ ENV_HBASE_SERVICE_HOST . to_string ( ) ,
5882 ) ;
5983 config. insert (
60- "hbase.master.port" . to_string ( ) ,
61- "${env:HBASE_SERVICE_PORT}" . to_string ( ) ,
84+ HBASE_MASTER_PORT_KEY . to_string ( ) ,
85+ ENV_HBASE_SERVICE_PORT . to_string ( ) ,
6286 ) ;
6387 config. insert (
64- "hbase.master.info.port" . to_string ( ) ,
65- "${env:HBASE_INFO_PORT}" . to_string ( ) ,
88+ HBASE_MASTER_INFO_PORT . to_string ( ) ,
89+ ENV_HBASE_INFO_PORT . to_string ( ) ,
6690 ) ;
6791 config. insert (
68- "hbase.master.bound.info.port" . to_string ( ) ,
92+ HBASE_MASTER_BOUND_INFO_PORT . to_string ( ) ,
6993 HBASE_MASTER_UI_PORT . to_string ( ) ,
7094 ) ;
7195 }
7296 HbaseRole :: RegionServer => {
7397 config. insert (
74- "hbase.regionserver.ipc.address" . to_string ( ) ,
75- "0.0.0.0" . to_string ( ) ,
98+ HBASE_REGIONSERVER_IPC_ADDRESS . to_string ( ) ,
99+ BIND_ALL_ADDRESSES . to_string ( ) ,
76100 ) ;
77101 config. insert (
78- "hbase.regionserver.ipc.port" . to_string ( ) ,
102+ HBASE_REGIONSERVER_IPC_PORT . to_string ( ) ,
79103 HBASE_REGIONSERVER_PORT . to_string ( ) ,
80104 ) ;
81105 config. insert (
82- "hbase.unsafe.regionserver.hostname" . to_string ( ) ,
83- "${env:HBASE_SERVICE_HOST}" . to_string ( ) ,
106+ HBASE_UNSAFE_REGIONSERVER_HOSTNAME . to_string ( ) ,
107+ ENV_HBASE_SERVICE_HOST . to_string ( ) ,
84108 ) ;
85109 config. insert (
86- "hbase.regionserver.port" . to_string ( ) ,
87- "${env:HBASE_SERVICE_PORT}" . to_string ( ) ,
110+ HBASE_REGIONSERVER_PORT_KEY . to_string ( ) ,
111+ ENV_HBASE_SERVICE_PORT . to_string ( ) ,
88112 ) ;
89113 config. insert (
90- "hbase.regionserver.info.port" . to_string ( ) ,
91- "${env:HBASE_INFO_PORT}" . to_string ( ) ,
114+ HBASE_REGIONSERVER_INFO_PORT . to_string ( ) ,
115+ ENV_HBASE_INFO_PORT . to_string ( ) ,
92116 ) ;
93117 config. insert (
94- "hbase.regionserver.bound.info.port" . to_string ( ) ,
118+ HBASE_REGIONSERVER_BOUND_INFO_PORT . to_string ( ) ,
95119 HBASE_REGIONSERVER_UI_PORT . to_string ( ) ,
96120 ) ;
97121 }
98122 HbaseRole :: RestServer => {
99123 config. insert (
100124 // N.B. a custom tag, so as not to interfere with HBase internals.
101125 // The other roles use a patch to correctly resolve host/port.
102- "hbase.rest.endpoint" . to_string ( ) ,
103- "${env:HBASE_SERVICE_HOST}:${env:HBASE_SERVICE_PORT}" . to_string ( ) ,
126+ HBASE_REST_ENDPOINT . to_string ( ) ,
127+ format ! ( "{ENV_HBASE_SERVICE_HOST}:{ENV_HBASE_SERVICE_PORT}" ) ,
104128 ) ;
105129 }
106130 } ;
0 commit comments