chore: 210109 release
This commit is contained in:
@@ -91,41 +91,23 @@ public class FlowStatSchedConfig extends SchedConfig {
|
||||
@Resource(name = AggregateRedisConfig.AGGREGATE_REACTIVE_REDIS_TEMPLATE)
|
||||
private ReactiveStringRedisTemplate rt;
|
||||
|
||||
private boolean firstTime = true;
|
||||
|
||||
private final String ip = NetworkUtils.getServerIp();
|
||||
|
||||
private long startTimeSlot = 0;
|
||||
|
||||
@Scheduled(cron = "${flow-stat-sched.cron}")
|
||||
public void sched() {
|
||||
|
||||
if (!flowControl) {
|
||||
return;
|
||||
}
|
||||
if (firstTime) {
|
||||
firstTime = false;
|
||||
FlowStat flowStat = flowControlFilter.getFlowStat();
|
||||
if (startTimeSlot == 0) {
|
||||
startTimeSlot = getRecentEndTimeSlot(flowStat);
|
||||
return;
|
||||
}
|
||||
FlowStat flowStat = flowControlFilter.getFlowStat();
|
||||
long currentTimeSlot = flowStat.currentTimeSlotId();
|
||||
int second = DateTimeUtils.from(currentTimeSlot).getSecond();
|
||||
long interval;
|
||||
if (second > 49) {
|
||||
interval = second - 50;
|
||||
} else if (second > 39) {
|
||||
interval = second - 40;
|
||||
} else if (second > 29) {
|
||||
interval = second - 30;
|
||||
} else if (second > 19) {
|
||||
interval = second - 20;
|
||||
} else if (second > 9) {
|
||||
interval = second - 10;
|
||||
} else if (second > 0) {
|
||||
interval = second - 0;
|
||||
} else {
|
||||
interval = 0;
|
||||
}
|
||||
long recentEndTimeSlot = currentTimeSlot - interval * 1000;
|
||||
long startTimeSlot = recentEndTimeSlot - 10 * 1000;
|
||||
long st = System.currentTimeMillis();
|
||||
long recentEndTimeSlot = getRecentEndTimeSlot(flowStat);
|
||||
List<ResourceTimeWindowStat> resourceTimeWindowStats = flowStat.getResourceTimeWindowStats(null, startTimeSlot, recentEndTimeSlot, 10);
|
||||
if (resourceTimeWindowStats == null || resourceTimeWindowStats.isEmpty()) {
|
||||
log.info(toDP19(startTimeSlot) + " - " + toDP19(recentEndTimeSlot) + " no flow stat data");
|
||||
@@ -186,12 +168,42 @@ public class FlowStatSchedConfig extends SchedConfig {
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
startTimeSlot = recentEndTimeSlot;
|
||||
log.info(toDP23(st) + " fss " + toDP23(System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
private long getRecentEndTimeSlot(FlowStat flowStat) {
|
||||
long currentTimeSlot = flowStat.currentTimeSlotId();
|
||||
int second = DateTimeUtils.from(currentTimeSlot).getSecond();
|
||||
long interval;
|
||||
if (second > 49) {
|
||||
interval = second - 50;
|
||||
} else if (second > 39) {
|
||||
interval = second - 40;
|
||||
} else if (second > 29) {
|
||||
interval = second - 30;
|
||||
} else if (second > 19) {
|
||||
interval = second - 20;
|
||||
} else if (second > 9) {
|
||||
interval = second - 10;
|
||||
} else if (second > 0) {
|
||||
interval = second - 0;
|
||||
} else {
|
||||
interval = 0;
|
||||
}
|
||||
long recentEndTimeSlot = currentTimeSlot - interval * 1000;
|
||||
return recentEndTimeSlot;
|
||||
}
|
||||
|
||||
private String toDP19(long startTimeSlot) {
|
||||
return DateTimeUtils.toDate(startTimeSlot, Constants.DatetimePattern.DP19);
|
||||
}
|
||||
|
||||
private String toDP23(long startTimeSlot) {
|
||||
return DateTimeUtils.toDate(startTimeSlot, Constants.DatetimePattern.DP23);
|
||||
}
|
||||
|
||||
private static void toJsonStringValue(StringBuilder b, String value) {
|
||||
b.append(Constants.Symbol.DOUBLE_QUOTE).append(value).append(Constants.Symbol.DOUBLE_QUOTE);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import org.springframework.web.server.WebFilterChain;
|
||||
@@ -37,7 +36,6 @@ import we.plugin.auth.ApiConfig;
|
||||
import we.plugin.auth.ApiConfigService;
|
||||
import we.plugin.auth.AuthPluginFilter;
|
||||
import we.plugin.stat.StatPluginFilter;
|
||||
import we.util.JacksonUtils;
|
||||
import we.util.ReactorUtils;
|
||||
import we.util.WebUtils;
|
||||
|
||||
@@ -76,12 +74,6 @@ public class PreFilter extends ProxyAggrFilter {
|
||||
@Override
|
||||
public Mono<Void> doFilter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
|
||||
String clientReqPath = WebUtils.getClientReqPath(exchange);
|
||||
if ("/flowControl/mock".equals(clientReqPath)) {
|
||||
ServerHttpResponse resp = exchange.getResponse();
|
||||
return resp.writeWith(Mono.just(resp.bufferFactory().wrap("ok".getBytes())));
|
||||
}
|
||||
|
||||
Map<String, FilterResult> fc = new HashMap<>(6, 1.0f); fc.put(WebUtils.PREV_FILTER_RESULT, succFr);
|
||||
Map<String, String> appendHdrs = new HashMap<>(6, 1.0f);
|
||||
Map<String, Object> eas = exchange.getAttributes(); eas.put(WebUtils.FILTER_CONTEXT, fc);
|
||||
|
||||
Reference in New Issue
Block a user