Merge pull request #776 from darkness463/develop

[ISSUE #768] Fix: client beat interval is not controlled by server.
This commit is contained in:
Fury Zhu 2019-02-17 09:46:46 +08:00 committed by GitHub
commit ee9447c388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,7 @@ public class BeatReactor {
private ScheduledExecutorService executorService; private ScheduledExecutorService executorService;
private long clientBeatInterval = 5 * 1000; private volatile long clientBeatInterval = 5 * 1000;
private NamingProxy serverProxy; private NamingProxy serverProxy;
@ -54,7 +54,7 @@ public class BeatReactor {
} }
}); });
executorService.scheduleAtFixedRate(new BeatProcessor(), 0, clientBeatInterval, TimeUnit.MILLISECONDS); executorService.schedule(new BeatProcessor(), 0, TimeUnit.MILLISECONDS);
} }
public void addBeatInfo(String dom, BeatInfo beatInfo) { public void addBeatInfo(String dom, BeatInfo beatInfo) {
@ -88,6 +88,8 @@ public class BeatReactor {
} }
} catch (Exception e) { } catch (Exception e) {
LogUtils.LOG.error("CLIENT-BEAT", "Exception while scheduling beat.", e); LogUtils.LOG.error("CLIENT-BEAT", "Exception while scheduling beat.", e);
} finally {
executorService.schedule(this, clientBeatInterval, TimeUnit.MILLISECONDS);
} }
} }
} }