@@ -115,7 +115,7 @@ public final class FlussClusterExtension
115115 private File tempDir ;
116116
117117 private final Map <Integer , TabletServer > tabletServers ;
118- private final List < ServerInfo > tabletServerInfos ;
118+ private final Map < Integer , ServerInfo > tabletServerInfos ;
119119 private final Configuration clusterConf ;
120120
121121 /** Creates a new {@link Builder} for {@link FlussClusterExtension}. */
@@ -132,7 +132,7 @@ private FlussClusterExtension(
132132 this .tabletServers = new HashMap <>(numOfTabletServers );
133133 this .coordinatorServerListeners = coordinatorServerListeners ;
134134 this .tabletServerListeners = tabletServerListeners ;
135- this .tabletServerInfos = new ArrayList <>();
135+ this .tabletServerInfos = new HashMap <>();
136136 this .clusterConf = clusterConf ;
137137 }
138138
@@ -268,9 +268,7 @@ public void startTabletServer(int serverId) throws Exception {
268268
269269 public void startTabletServer (int serverId , boolean forceStartIfExists ) throws Exception {
270270 if (tabletServers .containsKey (serverId )) {
271- if (forceStartIfExists ) {
272- tabletServers .remove (serverId );
273- } else {
271+ if (!forceStartIfExists ) {
274272 throw new IllegalArgumentException (
275273 "Tablet server " + serverId + " already exists." );
276274 }
@@ -294,7 +292,7 @@ public void startTabletServer(int serverId, boolean forceStartIfExists) throws E
294292 ServerType .TABLET_SERVER );
295293
296294 tabletServers .put (serverId , tabletServer );
297- tabletServerInfos .add ( serverInfo );
295+ tabletServerInfos .put ( serverId , serverInfo );
298296 }
299297
300298 public void assertHasTabletServerNumber (int tabletServerNumber ) {
@@ -333,7 +331,7 @@ public void stopTabletServer(int serverId) throws Exception {
333331 throw new IllegalArgumentException ("Tablet server " + serverId + " does not exist." );
334332 }
335333 tabletServers .remove (serverId ).close ();
336- tabletServerInfos .removeIf ( node -> node . id () == serverId );
334+ tabletServerInfos .remove ( serverId );
337335 }
338336
339337 public Configuration getClientConfig () {
@@ -363,7 +361,7 @@ public ServerInfo getCoordinatorServerInfo() {
363361 }
364362
365363 public List <ServerInfo > getTabletServerInfos () {
366- return tabletServerInfos ;
364+ return new ArrayList <>( tabletServerInfos . values ()) ;
367365 }
368366
369367 public ServerNode getCoordinatorServerNode () {
@@ -391,7 +389,7 @@ public List<ServerNode> getTabletServerNodes() {
391389 }
392390
393391 public List <ServerNode > getTabletServerNodes (@ Nullable String listenerName ) {
394- return tabletServerInfos .stream ()
392+ return tabletServerInfos .values (). stream ()
395393 .map (
396394 node -> {
397395 Endpoint endpoint =
0 commit comments