forked from External/mage
Moved job schedule time value to constant
This commit is contained in:
parent
a6decdbd14
commit
a3be8073e2
1 changed files with 8 additions and 2 deletions
|
|
@ -62,6 +62,13 @@ public class TableManager {
|
||||||
private ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
private ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
||||||
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines how often checking process should be run on server.
|
||||||
|
*
|
||||||
|
* In minutes.
|
||||||
|
*/
|
||||||
|
private static final int EXPIRE_CHECK_PERIOD = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This parameters defines when table can be counted as expired.
|
* This parameters defines when table can be counted as expired.
|
||||||
* Uses EXPIRE_TIME_UNIT_VALUE as unit of measurement.
|
* Uses EXPIRE_TIME_UNIT_VALUE as unit of measurement.
|
||||||
|
|
@ -86,7 +93,7 @@ public class TableManager {
|
||||||
public void run() {
|
public void run() {
|
||||||
checkExpired();
|
checkExpired();
|
||||||
}
|
}
|
||||||
}, 10, 10, TimeUnit.MINUTES);
|
}, EXPIRE_CHECK_PERIOD, EXPIRE_CHECK_PERIOD, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Table createTable(UUID roomId, UUID userId, MatchOptions options) {
|
public Table createTable(UUID roomId, UUID userId, MatchOptions options) {
|
||||||
|
|
@ -268,7 +275,6 @@ public class TableManager {
|
||||||
List<UUID> toRemove = new ArrayList<UUID>();
|
List<UUID> toRemove = new ArrayList<UUID>();
|
||||||
for (Table table : tables.values()) {
|
for (Table table : tables.values()) {
|
||||||
long diff = (now.getTime() - table.getCreateTime().getTime()) / EXPIRE_TIME_UNIT_VALUE;
|
long diff = (now.getTime() - table.getCreateTime().getTime()) / EXPIRE_TIME_UNIT_VALUE;
|
||||||
logger.info("Expire = " + diff);
|
|
||||||
if (diff >= EXPIRE_TIME) {
|
if (diff >= EXPIRE_TIME) {
|
||||||
logger.info("Table expired: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
logger.info("Table expired: id = " + table.getId() + ", created_by=" + table.getControllerName() + ". Removing...");
|
||||||
toRemove.add(table.getId());
|
toRemove.add(table.getId());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue