forked from Qortal/qortal
Scheduled maintenance now enabled by default, but uses a min and a max, to reduce the chances of multiple nodes running maintenance at the same time. Default to min: 7 days, max: 30 days.
This commit is contained in:
parent
b7e9af100a
commit
cd359de7eb
@ -525,8 +525,8 @@ public class Controller extends Thread {
|
||||
Thread.currentThread().setName("Controller");
|
||||
|
||||
final long repositoryBackupInterval = Settings.getInstance().getRepositoryBackupInterval();
|
||||
final long repositoryMaintenanceInterval = Settings.getInstance().getRepositoryMaintenanceInterval();
|
||||
final long repositoryCheckpointInterval = Settings.getInstance().getRepositoryCheckpointInterval();
|
||||
long repositoryMaintenanceInterval = getRandomRepositoryMaintenanceInterval();
|
||||
|
||||
// Start executor service for trimming or pruning
|
||||
PruneManager.getInstance().start();
|
||||
@ -617,6 +617,9 @@ public class Controller extends Thread {
|
||||
} catch (DataException | TimeoutException e) {
|
||||
LOGGER.error("Scheduled repository maintenance failed", e);
|
||||
}
|
||||
|
||||
// Get a new random interval
|
||||
repositoryMaintenanceInterval = getRandomRepositoryMaintenanceInterval();
|
||||
}
|
||||
|
||||
// Prune stuck/slow/old peers
|
||||
@ -676,6 +679,15 @@ public class Controller extends Thread {
|
||||
}
|
||||
}
|
||||
|
||||
private long getRandomRepositoryMaintenanceInterval() {
|
||||
final long minInterval = Settings.getInstance().getRepositoryMaintenanceMinInterval();
|
||||
final long maxInterval = Settings.getInstance().getRepositoryMaintenanceMaxInterval();
|
||||
if (maxInterval == 0) {
|
||||
return 0;
|
||||
}
|
||||
return (new Random().nextLong() % (maxInterval - minInterval)) + minInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export current trade bot states and minting accounts.
|
||||
*/
|
||||
|
@ -89,8 +89,10 @@ public class Settings {
|
||||
private long repositoryBackupInterval = 0; // ms
|
||||
/** Whether to show a notification when we backup repository. */
|
||||
private boolean showBackupNotification = false;
|
||||
/** How long between repository maintenance attempts (ms), or 0 if disabled. */
|
||||
private long repositoryMaintenanceInterval = 0; // ms
|
||||
/** Minimum time between repository maintenance attempts (ms) */
|
||||
private long repositoryMaintenanceMinInterval = 7 * 24 * 60 * 60 * 1000L; // 7 days (ms) default
|
||||
/** Maximum time between repository maintenance attempts (ms) (0 if disabled). */
|
||||
private long repositoryMaintenanceMaxInterval = 30 * 24 * 60 * 60 * 1000L; // 30 days (ms) default
|
||||
/** Whether to show a notification when we run scheduled maintenance. */
|
||||
private boolean showMaintenanceNotification = false;
|
||||
/** How long between repository checkpoints (ms). */
|
||||
@ -562,8 +564,12 @@ public class Settings {
|
||||
return this.showBackupNotification;
|
||||
}
|
||||
|
||||
public long getRepositoryMaintenanceInterval() {
|
||||
return this.repositoryMaintenanceInterval;
|
||||
public long getRepositoryMaintenanceMinInterval() {
|
||||
return this.repositoryMaintenanceMinInterval;
|
||||
}
|
||||
|
||||
public long getRepositoryMaintenanceMaxInterval() {
|
||||
return this.repositoryMaintenanceMaxInterval;
|
||||
}
|
||||
|
||||
public boolean getShowMaintenanceNotification() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user