use of mage.game.Table in project mage by magefree.
the class TableManagerImpl method checkTableHealthState.
private void checkTableHealthState() {
if (logger.isDebugEnabled()) {
debugServerState();
}
logger.debug("TABLE HEALTH CHECK");
for (Table table : getTables()) {
try {
if (table.getState() != TableState.FINISHED && ((System.currentTimeMillis() - table.getStartTime().getTime()) / 1000) > 30) {
// removeUserFromAllTablesAndChat only if table started longer than 30 seconds ago
// removeUserFromAllTablesAndChat tables and games not valid anymore
logger.debug(table.getId() + " [" + table.getName() + "] " + formatter.format(table.getStartTime() != null ? table.getStartTime() : table.getCreateTime()) + " (" + table.getState().toString() + ") " + (table.isTournament() ? "- Tournament" : ""));
getController(table.getId()).ifPresent(tableController -> {
if ((table.isTournament() && !tableController.isTournamentStillValid()) || (!table.isTournament() && !tableController.isMatchTableStillValid())) {
try {
logger.warn("Removing unhealthy tableId " + table.getId());
removeTable(table.getId());
} catch (Exception e) {
logger.error(e);
}
}
});
}
} catch (Exception ex) {
logger.debug("Table Health check error tableId: " + table.getId());
logger.debug(Arrays.toString(ex.getStackTrace()));
}
}
logger.debug("TABLE HEALTH CHECK - END");
}
use of mage.game.Table in project mage by magefree.
the class TableManagerImpl method getTables.
@Override
public Collection<Table> getTables() {
Collection<Table> newTables = new ArrayList<>();
final Lock r = tablesLock.readLock();
r.lock();
try {
newTables.addAll(tables.values());
} finally {
r.unlock();
}
return newTables;
}
Aggregations