@@ -19,9 +19,7 @@ public class ServerState {
1919 private final ConcurrentHashMap <Long , ClientHandler > clientHandlerHashMap = new ConcurrentHashMap <>();
2020 private final ConcurrentHashMap <String , Room > roomsHashMap = new ConcurrentHashMap <>();
2121 private final ConcurrentHashMap <String , Server > serversHashmap = new ConcurrentHashMap <>(); // has all the Servers; dead and alive; except this
22- // TODO: Change identityList into a HashMap to keep the serverIds.
23- // unique client identifies
24- private final ConcurrentHashMap <String , String > identityHashMap = new ConcurrentHashMap <>();
22+ private final ConcurrentHashMap <String , String > identityHashMap = new ConcurrentHashMap <>(); // unique client identifies
2523 private final ConcurrentHashMap <String , Long > heartBeatMap = new ConcurrentHashMap <>(); //store heartbeats of servers
2624 private final ConcurrentLinkedQueue <String > failedServers = new ConcurrentLinkedQueue <>(); // store failed servers
2725 private boolean smallPartitionFormed = false ;
@@ -90,7 +88,7 @@ public Server getServerFromId(String serverId) {
9088 }
9189 }
9290 if (serverId .equals (this .serverId )) {
93- return new Server (this .serverId , this .serverAddress , this .coordinationPort , this .clientsPort ); //todo check coordination port or clients port
91+ return new Server (this .serverId , this .serverAddress , this .coordinationPort , this .clientsPort );
9492 }
9593 return null ;
9694 }
@@ -250,7 +248,6 @@ public boolean amITheLeader() {
250248 public HashMap <String , String > getCurrentServerState () throws IOException {
251249 HashMap <String , String > serverState = new HashMap <>();
252250
253- // TODO: change the code to reflect the datatype change in identityList.
254251 // Serialize identity list.
255252 serverState .put ("IdentityMap" , serialize (identityHashMap ));
256253
@@ -364,9 +361,6 @@ private void removeRoomsExceptMainHall() {
364361 */
365362 private void disconnectClients () throws IOException {
366363
367- //TODO:
368- //Closing the socket here might throw an SocketException in either ClientHandler or main.
369- //Need to handle that scenario after testing.
370364 for (ClientHandler clientHandler : clientHandlerHashMap .values ()) {
371365 clientHandler .forceQuitClient ();
372366 }
@@ -424,7 +418,7 @@ public void removeIdentity(String identity) {
424418 public Collection <String > getIdentityByServer (String sId ) {
425419 Collection <String > identities = new ArrayList <>();
426420 for (Map .Entry <String , String > entry : identityHashMap .entrySet ()) {
427- if (sId .equals (entry .getValue ())){
421+ if (sId .equals (entry .getValue ())) {
428422 identities .add (entry .getKey ());
429423 }
430424 }
0 commit comments