Config change: Add an active-flag for data-expiration and set the

default duration to 60 minutes (still disabled by default).
This commit is contained in:
asofold 2013-02-27 18:47:31 +01:00
parent 4a9f82ef0c
commit 9d1f7924b9
3 changed files with 11 additions and 5 deletions

View File

@ -61,6 +61,7 @@ public abstract class ConfPaths {
private static final String DATA = "data.";
// Expired data removal.
private static final String DATA_EXPIRATION = DATA + "expiration.";
public static final String DATA_EXPIRATION_ACTIVE = DATA_EXPIRATION + "active";
public static final String DATA_EXPIRATION_DURATION = DATA_EXPIRATION + "duration";
public static final String DATA_EXPIRATION_DATA = DATA_EXPIRATION + "data";
public static final String DATA_EXPIRATION_HISTORY = DATA_EXPIRATION + "history";

View File

@ -26,7 +26,7 @@ public class DefaultConfig extends ConfigFile {
* NCP build needed for this config.
* (Should only increment with changing or removing paths.)
*/
public static final int buildNumber = 384;
public static final int buildNumber = 414;
// TODO: auto input full version or null to an extra variable or several [fail safe for other syntax checking]?
@ -78,7 +78,8 @@ public class DefaultConfig extends ConfigFile {
// Data settings.
// Expired offline players data.
set(ConfPaths.DATA_EXPIRATION_DURATION, 0);
set(ConfPaths.DATA_EXPIRATION_ACTIVE, false);
set(ConfPaths.DATA_EXPIRATION_DURATION, 60);
set(ConfPaths.DATA_EXPIRATION_HISTORY, false);
// Consistency checking.
set(ConfPaths.DATA_CONSISTENCYCHECKS_CHECK, true);

View File

@ -91,9 +91,12 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
*/
protected final Map<CheckType, Map<String, ExecutionHistory>> executionHistories = new HashMap<CheckType, Map<String,ExecutionHistory>>();
/** Flag if data expiration is active at all. */
protected boolean doExpireData = false;
/**
* Duration in milliseconds for expiration of logged off players data.
* Disabled with 0, in the config minutes are used as unit.
* In the config minutes are used as unit.
*/
protected long durExpireData = 0;
@ -114,7 +117,7 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
* Currently only "dumb" full removal is performed. Later it is thinkable to remove "as much as reasonable".
*/
public void checkExpiration(){
if (durExpireData <= 0) return;
if (!doExpireData || durExpireData <= 0) return;
final long now = System.currentTimeMillis();
final Set<CheckDataFactory> factories = new LinkedHashSet<CheckDataFactory>();
final Set<Entry<String, Long>> entries = lastLogout.entrySet();
@ -181,7 +184,8 @@ public class DataManager implements Listener, INotifyReload, INeedConfig, Compon
*/
private void adjustSettings() {
final ConfigFile config = ConfigManager.getConfigFile();
durExpireData = config.getLong(ConfPaths.DATA_EXPIRATION_DURATION) * 60000L; // in minutes
doExpireData = config.getBoolean(ConfPaths.DATA_EXPIRATION_ACTIVE);
durExpireData = config.getLong(ConfPaths.DATA_EXPIRATION_DURATION, 1, 1000000, 60) * 60000L; // in minutes
deleteData = config.getBoolean(ConfPaths.DATA_EXPIRATION_DATA, true); // hidden.
deleteHistory = config.getBoolean(ConfPaths.DATA_EXPIRATION_HISTORY);
}