2121import org .apache .doris .common .Config ;
2222import org .apache .doris .ha .BDBHA ;
2323import org .apache .doris .ha .BDBStateChangeListener ;
24+ import org .apache .doris .ha .FrontendNodeType ;
2425import org .apache .doris .ha .HAProtocol ;
26+ import org .apache .doris .system .Frontend ;
2527
2628import com .sleepycat .je .Database ;
2729import com .sleepycat .je .DatabaseConfig ;
5153import java .net .InetSocketAddress ;
5254import java .util .ArrayList ;
5355import java .util .Collections ;
54- import java .util .HashSet ;
5556import java .util .List ;
5657import java .util .Set ;
5758import java .util .concurrent .TimeUnit ;
5859import java .util .concurrent .locks .ReentrantReadWriteLock ;
60+ import java .util .stream .Collectors ;
5961
6062/* this class contains the reference to bdb environment.
6163 * including all the opened databases and the replicationGroupAdmin.
@@ -73,7 +75,6 @@ public class BDBEnvironment {
7375 private ReplicationConfig replicationConfig ;
7476 private DatabaseConfig dbConfig ;
7577 private Database epochDB = null ; // used for fencing
76- private ReplicationGroupAdmin replicationGroupAdmin = null ;
7778 private ReentrantReadWriteLock lock ;
7879 private List <Database > openedDatabases ;
7980
@@ -153,29 +154,6 @@ public void setup(File envHome, String selfNodeName, String selfNodeHostPort,
153154 // open the environment
154155 replicatedEnvironment = new ReplicatedEnvironment (envHome , replicationConfig , environmentConfig );
155156
156- // get replicationGroupAdmin object.
157- Set <InetSocketAddress > adminNodes = new HashSet <InetSocketAddress >();
158- // 1. add helper node
159- // If host is ipv6 address there will be more than one colon in host str
160- int helperColonIdx = helperHostPort .lastIndexOf (":" );
161- String helperHost = helperHostPort .substring (0 , helperColonIdx );
162- int helperPort = Integer .parseInt (helperHostPort .substring (helperColonIdx + 1 ));
163- InetSocketAddress helper = new InetSocketAddress (helperHost , helperPort );
164- adminNodes .add (helper );
165- LOG .info ("add helper[{}] as ReplicationGroupAdmin" , helperHostPort );
166-
167- // 2. add self if is electable
168- if (!selfNodeHostPort .equals (helperHostPort ) && Env .getCurrentEnv ().isElectable ()) {
169- int selfColonIdx = selfNodeHostPort .lastIndexOf (":" );
170- String selfHost = selfNodeHostPort .substring (0 , selfColonIdx );
171- int selfPort = Integer .parseInt (selfNodeHostPort .substring (selfColonIdx + 1 ));
172- InetSocketAddress self = new InetSocketAddress (selfHost , selfPort );
173- adminNodes .add (self );
174- LOG .info ("add self[{}] as ReplicationGroupAdmin" , selfNodeHostPort );
175- }
176-
177- replicationGroupAdmin = new ReplicationGroupAdmin (PALO_JOURNAL_GROUP , adminNodes );
178-
179157 // get a BDBHA object and pass the reference to Catalog
180158 HAProtocol protocol = new BDBHA (this , selfNodeName );
181159 Env .getCurrentEnv ().setHaProtocol (protocol );
@@ -211,11 +189,13 @@ public void setup(File envHome, String selfNodeName, String selfNodeHostPort,
211189 }
212190
213191 public ReplicationGroupAdmin getReplicationGroupAdmin () {
214- return this .replicationGroupAdmin ;
215- }
216-
217- public void setNewReplicationGroupAdmin (Set <InetSocketAddress > newHelperNodes ) {
218- this .replicationGroupAdmin = new ReplicationGroupAdmin (PALO_JOURNAL_GROUP , newHelperNodes );
192+ Set <InetSocketAddress > addresses = Env .getCurrentEnv ()
193+ .getFrontends (FrontendNodeType .FOLLOWER )
194+ .stream ()
195+ .filter (Frontend ::isAlive )
196+ .map (fe -> new InetSocketAddress (fe .getIp (), fe .getEditLogPort ()))
197+ .collect (Collectors .toSet ());
198+ return new ReplicationGroupAdmin (PALO_JOURNAL_GROUP , addresses );
219199 }
220200
221201 // Return a handle to the epochDB
0 commit comments