for (Server server : serverList) {
List<Long> roomIds = sessionManager.getActiveRoomIdsByServer(server);
if (roomIds.contains(roomId)) {
// if the room is already opened on a server, redirect the user to that one,
log.debug("Room is already opened on a server " + server.getAddress());
return new ServerDTO(server);
}
activeRoomsMap.put(server, roomIds);
}
for (Server server : activeRoomsMap.keySet()) {
List<Long> roomIds = activeRoomsMap.get(server);
Long capacity = roomDao.getRoomsCapacityByIds(roomIds);
if (minimum < 0 || capacity < minimum) {
minimum = capacity;
result = server;
}
log.debug("Checking server: " + server + " Number of rooms " + roomIds.size() + " RoomIds: "
+ roomIds + " max(Sum): " + capacity);
}
return result == null ? null : new ServerDTO(result);
}
log.error("Could not get server for cluster session");
// Empty server object
return null;