Skip to content

Commit

Permalink
fix tle cache and remove decayed satellites
Browse files Browse the repository at this point in the history
  • Loading branch information
dernasherbrezon committed Jan 21, 2024
1 parent cd618a0 commit fd0f90a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 683 deletions.
11 changes: 8 additions & 3 deletions src/main/java/ru/r2cloud/tle/Housekeeping.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import ru.r2cloud.cloud.LeoSatDataClient;
import ru.r2cloud.cloud.NotModifiedException;
import ru.r2cloud.cloud.SatnogsClient;
Expand All @@ -20,6 +23,8 @@

public class Housekeeping {

private final static Logger LOG = LoggerFactory.getLogger(Housekeeping.class);

private final ThreadPoolFactory threadFactory;
private final SatelliteDao dao;
private final Configuration config;
Expand Down Expand Up @@ -139,15 +144,15 @@ private void reloadTle() {
boolean missingTle = false;
for (Satellite cur : dao.findAll()) {
if (cur.getTle() == null && tleDao.find(cur.getId(), cur.getName()) == null) {
LOG.info("cannot find tle for {} reloading", cur.getId());
missingTle = true;
break;
}
}
// do not store on disk ever growing tle list
// store only supported satellites
Map<String, Tle> updated = new HashMap<>();
boolean reloadTle = System.currentTimeMillis() - tleDao.getLastUpdateTime() > periodMillis;
if (reloadTle || missingTle) {
boolean reloadTle = (System.currentTimeMillis() - tleDao.getLastUpdateTime() > periodMillis) || missingTle;
if (reloadTle) {
tleDao.putAll(celestrak.downloadTle());
}
for (Satellite cur : dao.findAll()) {
Expand Down
Loading

0 comments on commit fd0f90a

Please sign in to comment.