forked from External/mage
Network upgrade and new reconnection mode (#11527)
Network upgrade and new reconnection mode: * users can disconnect or close app without game progress loose now; * disconnect dialog will show active tables stats and additional options; * all active tables will be restored on reconnect (tables, tourneys, games, drafts, sideboarding, constructing); * user must use same server and username on next connection; * there are few minutes for reconnect until server kick off a disconnected player from all player's tables (concede/loose); * now you can safety reconnect after IP change (after proxy/vpn/wifi/router restart); Other improvements and fixes: * gui: main menu - improved switch panel button, added stats about current tables/panels; * gui: improved data sync and updates (fixes many use cases with empty battlefield, not started games/drafts/tourneys, not updatable drafts, etc); * gui: improved stability on game updates (fixes some random errors related to wrong threads); * server: fixed miss messages about player's disconnection problems for other players in the chat; * refactor: simplified and improved connection and network related code, deleted outdated code, added docs; * tests: improved load test to support lands only set for more stable performance/network testing (set TEST_AI_RANDOM_DECK_SETS = PELP and run test_TwoAIPlayGame_Multiple);
This commit is contained in:
parent
7f0558ff3c
commit
960e896903
71 changed files with 1274 additions and 802 deletions
|
|
@ -7,9 +7,25 @@ import mage.server.game.ReplayManagerImpl;
|
|||
import mage.server.managers.*;
|
||||
import mage.server.tournament.TournamentManagerImpl;
|
||||
import mage.server.util.ThreadExecutorImpl;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author Burato, JayDi85
|
||||
*/
|
||||
public class MainManagerFactory implements ManagerFactory {
|
||||
|
||||
private final Logger logger = Logger.getLogger(MainManagerFactory.class);
|
||||
|
||||
// defines how often checking process should be run on server (in minutes)
|
||||
// TODO: WARNING, it's can be very buggy but very rare (quit players for no reason, e.g. empty deck bug in sideboard)
|
||||
// main reason - health code can run in the moment of game move from one stage to another (e.g. on sideboarding prepare)
|
||||
// TODO: add debug menu like "call server health in 10 seconds"
|
||||
// TODO: add debug menu like "call server side disconnect in 10 seconds"
|
||||
// TODO: add debug menu like "call client side disconnect in 10 seconds"
|
||||
private static final int SERVER_HEALTH_CHECK_TIMEOUT_MINS = 10;
|
||||
|
||||
private final ConfigSettings configSettings;
|
||||
private final ThreadExecutor threadExecutor;
|
||||
private final ChatManager chatManager;
|
||||
|
|
@ -24,7 +40,6 @@ public class MainManagerFactory implements ManagerFactory {
|
|||
private final UserManager userManager;
|
||||
private final TournamentManager tournamentManager;
|
||||
|
||||
|
||||
public MainManagerFactory(ConfigSettings configSettings) {
|
||||
this.configSettings = configSettings;
|
||||
// ThreadExecutorImpl, MailClientImpl and MailGunClient depend only on the config, so they are initialised first
|
||||
|
|
@ -47,6 +62,7 @@ public class MainManagerFactory implements ManagerFactory {
|
|||
this.gamesRoomManager = gamesRoomManager;
|
||||
this.tableManager = tableManager;
|
||||
this.userManager = userManager;
|
||||
|
||||
// execute the initialisation block of the relevant manager (they start the executor services)
|
||||
startThreads(gamesRoomManager, tableManager, userManager);
|
||||
}
|
||||
|
|
@ -55,6 +71,21 @@ public class MainManagerFactory implements ManagerFactory {
|
|||
userManager.init();
|
||||
tableManager.init();
|
||||
gamesRoomManager.init();
|
||||
|
||||
threadExecutor().getServerHealthExecutor().scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
//logger.info("---");
|
||||
//logger.info("Server health check started");
|
||||
this.tableManager().checkHealth();
|
||||
this.chatManager().checkHealth();
|
||||
this.userManager().checkHealth();
|
||||
this.sessionManager().checkHealth();
|
||||
} catch (Exception ex) {
|
||||
logger.fatal("Server health check: catch unknown error - " + ex, ex);
|
||||
}
|
||||
//logger.info("Server health check end");
|
||||
//logger.info("---");
|
||||
}, SERVER_HEALTH_CHECK_TIMEOUT_MINS, SERVER_HEALTH_CHECK_TIMEOUT_MINS, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue