Archived
0

stop EDCE after 5 errors

This commit is contained in:
Mo
2015-10-10 22:22:24 +03:00
parent fd85de72c6
commit f20a66f841

View File

@@ -28,6 +28,7 @@ public class EDCE {
private static ScheduledExecutorService executor; private static ScheduledExecutorService executor;
private static ScheduledFuture<?> checker; private static ScheduledFuture<?> checker;
private final static int MAX_ERRORS = 5;
private final static int CACHE_LIMIT = 8; private final static int CACHE_LIMIT = 8;
private List<EDPacket> cache = new LinkedList<>(); private List<EDPacket> cache = new LinkedList<>();
@@ -35,6 +36,7 @@ public class EDCE {
private final MarketModel world; private final MarketModel world;
private final StationUpdater updater; private final StationUpdater updater;
private final EDSession session; private final EDSession session;
private int errors;
private long interval; private long interval;
private boolean forceUpdate; private boolean forceUpdate;
@@ -200,7 +202,7 @@ public class EDCE {
LOG.trace("EDCE check, waiting {}", waiting); LOG.trace("EDCE check, waiting {}", waiting);
try { try {
if (waiting) return; if (waiting) return;
if (session.getLastStatus() == ED_SESSION_STATUS.OK) { if (session.getLastStatus() == ED_SESSION_STATUS.OK || session.getLastStatus() == ED_SESSION_STATUS.ERROR) {
LOG.trace("Read profile from ED"); LOG.trace("Read profile from ED");
session.readProfile(EDCE.this::parseAndCheck); session.readProfile(EDCE.this::parseAndCheck);
} }
@@ -242,6 +244,15 @@ public class EDCE {
waiting = false; waiting = false;
}); });
} }
if (session.getLastStatus() == ED_SESSION_STATUS.ERROR) {
errors++;
LOG.debug("Error on read response, errors count {}", errors);
if (errors >= MAX_ERRORS) {
stop();
}
} else {
errors = 0;
}
} catch (Exception ex){ } catch (Exception ex){
LOG.error("",ex); LOG.error("",ex);
} }