1
0
Fork 1
mirror of https://gitlab.com/mangadex-pub/mangadex_at_home.git synced 2024-01-19 02:48:37 +00:00

Add try catches

This commit is contained in:
carbotaniuman 2020-06-16 12:56:33 -05:00
parent 8b655575e1
commit 1af4455be6

View file

@ -92,24 +92,26 @@ public class MangaDexClient {
}
executorService.scheduleWithFixedDelay(() -> {
try {
statistics.updateAndGet(n -> n.copy(n.getRequestsServed(), n.getCacheHits(), n.getCacheMisses(),
n.getBrowserCached(), n.getBytesSent(), cache.size()));
statsMap.put(Instant.now(), statistics.get());
try {
DiskLruCache.Editor editor = cache.edit("statistics");
if (editor != null) {
String json = GSON.toJson(statistics.get(), Statistics.class);
editor.setString(0, json);
editor.commit();
}
} catch (IOException ignored) {
} catch (Exception e) {
LOGGER.warn("statistics update failed", e);
}
}, 15, 15, TimeUnit.SECONDS);
executorService.scheduleAtFixedRate(() -> {
try {
if (counter == 80) {
counter = 0;
lastBytesSent = statistics.get().getBytesSent();
@ -168,6 +170,9 @@ public class MangaDexClient {
}
}
}
} catch (Exception e) {
LOGGER.warn("Server ping failed", e);
}
}, 45, 45, TimeUnit.SECONDS);
}