()
| 71 | public abstract int getServicePort(); |
| 72 | |
| 73 | private void onTimerTask() { |
| 74 | var overload = this.overload.getOverload(); |
| 75 | int online = getOnlineLocalCount(); |
| 76 | long loginTimes = getOnlineLoginTimes(); |
| 77 | int onlineNew = (int)(loginTimes - lastLoginTime); |
| 78 | lastLoginTime = loginTimes; |
| 79 | int onlineNewPerSecond = onlineNew / timeoutDelaySeconds; |
| 80 | var config = getLoadConfig(); |
| 81 | if (overload != BLoad.eWorkFine) { |
| 82 | // fast report |
| 83 | report(overload, online, onlineNewPerSecond); |
| 84 | start(config.getDigestionDelayExSeconds()); |
| 85 | return; |
| 86 | } |
| 87 | if (onlineNewPerSecond > config.getMaxOnlineNew()) { |
| 88 | // 最近上线太多,马上报告负载。linkd不会再分配用户过来。 |
| 89 | report(overload, online, onlineNewPerSecond); |
| 90 | // new delay for digestion |
| 91 | start(onlineNewPerSecond / config.getMaxOnlineNew() + config.getDigestionDelayExSeconds()); |
| 92 | // 消化完后,下一次强迫报告Load。 |
| 93 | reportDelaySeconds = config.getReportDelaySeconds(); |
| 94 | return; |
| 95 | } |
| 96 | if (online > config.getProposeMaxOnline()) { |
| 97 | // 在线数量超过建议最大在线,马上报告。 |
| 98 | report(overload, online, onlineNewPerSecond); |
| 99 | start(config.getDigestionDelayExSeconds()); |
| 100 | // 超过最大建议值,强迫报告。 |
| 101 | reportDelaySeconds = config.getReportDelaySeconds(); |
| 102 | return; |
| 103 | } |
| 104 | // slow report |
| 105 | reportDelaySeconds += timeoutDelaySeconds; |
| 106 | if (reportDelaySeconds >= config.getReportDelaySeconds()) { |
| 107 | reportDelaySeconds = 0; |
| 108 | report(overload, online, onlineNewPerSecond); |
| 109 | } |
| 110 | start(); |
| 111 | } |
| 112 | |
| 113 | public void report(int overload, int online, int onlineNew) { |
| 114 | var load = new BLoad.Data(); |
nothing calls this directly
no test coverage detected