mirror of
https://github.com/Qortal/qortal.git
synced 2025-04-14 23:35:54 +00:00
added rebuild arbitrary rebuild resource timer task
This commit is contained in:
parent
934c23402a
commit
10dda255e2
@ -547,6 +547,16 @@ public class Controller extends Thread {
|
||||
ArbitraryDataStorageManager.getInstance().start();
|
||||
ArbitraryDataRenderManager.getInstance().start();
|
||||
|
||||
// start rebuild arbitrary resource cache timer task
|
||||
if( Settings.getInstance().isRebuildArbitraryResourceCacheTaskEnabled() ) {
|
||||
new Timer().schedule(
|
||||
new RebuildArbitraryResourceCacheTask(),
|
||||
Settings.getInstance().getRebuildArbitraryResourceCacheTaskDelay() * RebuildArbitraryResourceCacheTask.MILLIS_IN_MINUTE,
|
||||
Settings.getInstance().getRebuildArbitraryResourceCacheTaskPeriod() * RebuildArbitraryResourceCacheTask.MILLIS_IN_HOUR
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
LOGGER.info("Starting online accounts manager");
|
||||
OnlineAccountsManager.getInstance().start();
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
package org.qortal.controller.arbitrary;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.qortal.repository.DataException;
|
||||
import org.qortal.repository.Repository;
|
||||
import org.qortal.repository.RepositoryManager;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class RebuildArbitraryResourceCacheTask extends TimerTask {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger(RebuildArbitraryResourceCacheTask.class);
|
||||
|
||||
public static final long MILLIS_IN_HOUR = 60 * 60 * 1000;
|
||||
|
||||
public static final long MILLIS_IN_MINUTE = 60 * 1000;
|
||||
|
||||
private static final String REBUILD_ARBITRARY_RESOURCE_CACHE_TASK = "Rebuild Arbitrary Resource Cache Task";
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Thread.currentThread().setName(REBUILD_ARBITRARY_RESOURCE_CACHE_TASK);
|
||||
|
||||
try (final Repository repository = RepositoryManager.getRepository()) {
|
||||
ArbitraryDataCacheManager.getInstance().buildArbitraryResourcesCache(repository, true);
|
||||
}
|
||||
catch( DataException e ) {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -508,12 +508,43 @@ public class Settings {
|
||||
*/
|
||||
private boolean connectionPoolMonitorEnabled = false;
|
||||
|
||||
/**
|
||||
* Buiild Arbitrary Resources Batch Size
|
||||
*
|
||||
* The number resources to batch per iteration when rebuilding.
|
||||
*/
|
||||
private int buildArbitraryResourcesBatchSize = 200;
|
||||
|
||||
/**
|
||||
* Arbitrary Indexing Priority
|
||||
*
|
||||
* The thread priority when indexing arbirary resources.
|
||||
*/
|
||||
private int arbitraryIndexingPriority = 5;
|
||||
|
||||
/**
|
||||
* Arbitrary Indexing Frequency (In Minutes)
|
||||
*
|
||||
* The frequency at which the arbitrary indices are cached.
|
||||
*/
|
||||
private int arbitraryIndexingFrequency = 1;
|
||||
|
||||
private boolean rebuildArbitraryResourceCacheTaskEnabled = false;
|
||||
|
||||
/**
|
||||
* Rebuild Arbitrary Resource Cache Task Delay (In Minutes)
|
||||
*
|
||||
* Waiting period before the first rebuild task is started.
|
||||
*/
|
||||
private int rebuildArbitraryResourceCacheTaskDelay = 300;
|
||||
|
||||
/**
|
||||
* Rebuild Arbitrary Resource Cache Task Period (In Hours)
|
||||
*
|
||||
* The frequency the arbitrary resource cache is rebuilt.
|
||||
*/
|
||||
private int rebuildArbitraryResourceCacheTaskPeriod = 24;
|
||||
|
||||
// Domain mapping
|
||||
public static class ThreadLimit {
|
||||
private String messageType;
|
||||
@ -1351,4 +1382,16 @@ public class Settings {
|
||||
public int getArbitraryIndexingFrequency() {
|
||||
return arbitraryIndexingFrequency;
|
||||
}
|
||||
|
||||
public boolean isRebuildArbitraryResourceCacheTaskEnabled() {
|
||||
return rebuildArbitraryResourceCacheTaskEnabled;
|
||||
}
|
||||
|
||||
public int getRebuildArbitraryResourceCacheTaskDelay() {
|
||||
return rebuildArbitraryResourceCacheTaskDelay;
|
||||
}
|
||||
|
||||
public int getRebuildArbitraryResourceCacheTaskPeriod() {
|
||||
return rebuildArbitraryResourceCacheTaskPeriod;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user