11use crate :: comms_handler:: { CommsError , Event , Node , TcpTlsConfig } ;
22use crate :: configurations:: {
3- DbMode , ExtraNodeParams , NodeSpec , PreLaunchNodeConfig , PreLaunchNodeType , TlsSpec ,
3+ DbMode , ExtraNodeParams , PreLaunchNodeConfig , PreLaunchNodeType , TlsSpec ,
44} ;
55use crate :: db_utils:: { self , SimpleDb , SimpleDbSpec } ;
66use crate :: interfaces:: { DbItem , NodeType , PreLaunchRequest , Response } ;
77use crate :: raft_store:: { get_presistent_committed, CommittedIndex } ;
8- use crate :: utils:: { LocalEvent , LocalEventChannel , LocalEventSender , ResponseResult } ;
8+ use crate :: utils:: {
9+ create_socket_addr_for_list, LocalEvent , LocalEventChannel , LocalEventSender , ResponseResult ,
10+ } ;
911use bincode:: deserialize;
1012use bytes:: Bytes ;
1113use std:: { collections:: BTreeSet , error:: Error , fmt, future:: Future , net:: SocketAddr } ;
@@ -74,7 +76,7 @@ struct PreLaunchNodeConfigSelected {
7476 /// Configuration for handling TLS
7577 pub tls_config : TlsSpec ,
7678 /// All nodes addresses
77- pub pre_launch_nodes : Vec < NodeSpec > ,
79+ pub pre_launch_nodes : Vec < SocketAddr > ,
7880 /// Db spec
7981 pub db_spec : SimpleDbSpec ,
8082 /// Raft db spec
@@ -84,13 +86,14 @@ struct PreLaunchNodeConfigSelected {
8486}
8587
8688impl PreLaunchNodeConfigSelected {
87- fn new ( config : PreLaunchNodeConfig ) -> Self {
89+ async fn new ( config : PreLaunchNodeConfig ) -> Self {
8890 match config. node_type {
8991 PreLaunchNodeType :: Compute => Self {
9092 pre_launch_node_idx : config. compute_node_idx ,
9193 pre_launch_db_mode : config. compute_db_mode ,
9294 tls_config : config. tls_config ,
93- pre_launch_nodes : config. compute_nodes ,
95+ pre_launch_nodes : create_socket_addr_for_list ( & config. compute_nodes )
96+ . await . unwrap_or_default ( ) ,
9497 db_spec : crate :: compute:: DB_SPEC ,
9598 raft_db_spec : crate :: compute_raft:: DB_SPEC ,
9699 peer_limit : config. peer_limit ,
@@ -99,7 +102,8 @@ impl PreLaunchNodeConfigSelected {
99102 pre_launch_node_idx : config. storage_node_idx ,
100103 pre_launch_db_mode : config. storage_db_mode ,
101104 tls_config : config. tls_config ,
102- pre_launch_nodes : config. storage_nodes ,
105+ pre_launch_nodes : create_socket_addr_for_list ( & config. storage_nodes )
106+ . await . unwrap_or_default ( ) ,
103107 db_spec : crate :: storage:: DB_SPEC ,
104108 raft_db_spec : crate :: storage_raft:: DB_SPEC ,
105109 peer_limit : config. peer_limit ,
@@ -131,13 +135,13 @@ impl PreLaunchNode {
131135 config : PreLaunchNodeConfig ,
132136 mut extra : ExtraNodeParams ,
133137 ) -> Result < PreLaunchNode > {
134- let config = PreLaunchNodeConfigSelected :: new ( config) ;
138+ let config = PreLaunchNodeConfigSelected :: new ( config) . await ;
135139 let addr = config
136140 . pre_launch_nodes
137141 . get ( config. pre_launch_node_idx )
138- . ok_or ( PreLaunchError :: ConfigError ( "Invalid pre-launch index" ) ) ?
139- . address ;
140- let tcp_tls_config = TcpTlsConfig :: from_tls_spec ( addr, & config. tls_config ) ?;
142+ . ok_or ( PreLaunchError :: ConfigError ( "Invalid pre-launch index" ) ) ?;
143+
144+ let tcp_tls_config = TcpTlsConfig :: from_tls_spec ( addr. clone ( ) , & config. tls_config ) ?;
141145
142146 let node = Node :: new (
143147 & tcp_tls_config,
@@ -155,9 +159,16 @@ impl PreLaunchNode {
155159 db_utils:: new_db ( config. pre_launch_db_mode , spec, extra. raft_db . take ( ) , None )
156160 } ;
157161
158- let pre_launch_nodes = config. pre_launch_nodes . iter ( ) . map ( |s| s. address ) ;
159- let shutdown_group: BTreeSet < SocketAddr > = pre_launch_nodes. clone ( ) . collect ( ) ;
160- let pre_launch_nodes: Vec < _ > = pre_launch_nodes. filter ( |a| * a != addr) . collect ( ) ;
162+ let pre_launch_nodes = config. pre_launch_nodes . iter ( ) . map ( |s| s) ;
163+ let shutdown_group: BTreeSet < SocketAddr > = pre_launch_nodes
164+ . clone ( )
165+ . into_iter ( )
166+ . map ( |v| v. clone ( ) )
167+ . collect ( ) ;
168+ let pre_launch_nodes: Vec < _ > = pre_launch_nodes
169+ . filter ( |a| * a != addr)
170+ . map ( |v| v. clone ( ) )
171+ . collect ( ) ;
161172
162173 let raft_db_send = if config. pre_launch_node_idx == 0 {
163174 Some ( PreLaunchRequest :: SendDbItems {
0 commit comments