Export players page more frequently

Affects issues:
- Close #1999
This commit is contained in:
Aurora Lahtela 2022-02-27 12:57:22 +02:00
parent 2517c0416d
commit 8175e599ec
2 changed files with 16 additions and 11 deletions

View File

@ -84,10 +84,11 @@ public class ExportScheduler extends PluginRunnable {
}
private void schedulePlayersPageExport() {
long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS);
long period = TimeAmount.toTicks(config.get(ExportSettings.EXPORT_PERIOD), TimeUnit.MILLISECONDS)
/ 4;
runnableFactory.create(
new ExportTask(exporter, Exporter::exportPlayersPage, errorLogger)
).runTaskTimerAsynchronously(0L, period);
).runTaskTimerAsynchronously(TimeAmount.toTicks(2, TimeUnit.MINUTES), period);
}
private void scheduleServerPageExport() {
@ -102,17 +103,17 @@ public class ExportScheduler extends PluginRunnable {
Optional<Server> proxy = servers.stream().filter(Server::isProxy).findFirst();
proxy.ifPresent(mainServer -> runnableFactory.create(
new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger))
.runTaskTimerAsynchronously(0L, period)
new ExportTask(exporter, same -> same.exportServerPage(mainServer), errorLogger))
.runTaskTimerAsynchronously(TimeAmount.toTicks(1, TimeUnit.MINUTES), period)
);
int offsetMultiplier = proxy.isPresent() ? 1 : 0; // Delay first server export if on a network.
for (Server server : servers) {
runnableFactory.create(
new ExportTask(exporter, same -> {
same.exportServerPage(server);
same.exportServerJSON(server);
}, errorLogger))
new ExportTask(exporter, same -> {
same.exportServerPage(server);
same.exportServerJSON(server);
}, errorLogger))
.runTaskTimerAsynchronously(offset * offsetMultiplier, period);
offsetMultiplier++;
}

View File

@ -20,20 +20,24 @@ import com.djrapitops.plan.exceptions.ExceptionWithContext;
public interface ErrorLogger {
default <T extends ExceptionWithContext> void critical(T throwable) {
critical((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build()));
critical((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext));
}
void critical(Throwable throwable, ErrorContext context);
default <T extends ExceptionWithContext> void error(T throwable) {
error((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build()));
error((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext));
}
void error(Throwable throwable, ErrorContext context);
default <T extends ExceptionWithContext> void warn(T throwable) {
warn((Throwable) throwable, throwable.getContext().orElse(ErrorContext.builder().related("Missing Context").build()));
warn((Throwable) throwable, throwable.getContext().orElseGet(this::createMissingContext));
}
void warn(Throwable throwable, ErrorContext context);
default ErrorContext createMissingContext() {
return ErrorContext.builder().related("Missing Context").build();
}
}