Skip to content

Commit

Permalink
Merge pull request #7 from TongchengOpenSource/cjq
Browse files Browse the repository at this point in the history
feat: 优化round逻辑
  • Loading branch information
famosss authored Jan 10, 2024
2 parents 7e67233 + 0597c7f commit 35b8dd6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/main/java/com/ly/ckibana/handlers/ParamHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public class ParamHandler extends BaseHandler {

private static final String ROUND_ABLE_MIN_PERIOD = "/config/updateRoundAbleMinPeriod";

private static final String ROUND = "/config/updateRound";

private static final String MAX_TIME_RANGE = "/config/updateMaxTimeRange";

private static final String ENABLE_MONITORING = "/config/updateEnableMonitoring";
Expand All @@ -76,6 +78,7 @@ public List<HttpRoute> routes() {
HttpRoute.newRoute().path(SAMPLE_MAX_THRESHOLD).methods(HttpMethod.POST),
HttpRoute.newRoute().path(USE_CACHE).methods(HttpMethod.POST),
HttpRoute.newRoute().path(ROUND_ABLE_MIN_PERIOD).methods(HttpMethod.POST),
HttpRoute.newRoute().path(ROUND).methods(HttpMethod.POST),
HttpRoute.newRoute().path(MAX_TIME_RANGE).methods(HttpMethod.POST),
HttpRoute.newRoute().path(ENABLE_MONITORING).methods(HttpMethod.POST),
HttpRoute.newRoute().path(MSEARCH_THREAD_POOL_CORE_SIZE).methods(HttpMethod.POST)
Expand Down Expand Up @@ -120,6 +123,9 @@ public String doHandle(RequestContext context) {
case ROUND_ABLE_MIN_PERIOD:
kibanaProperty.getProxy().setRoundAbleMinPeriod(parseValue(params.get("roundAbleMinPeriod")));
break;
case ROUND:
kibanaProperty.getProxy().setRound(parseValue(params.get("round")).intValue());
break;
case MAX_TIME_RANGE:
kibanaProperty.getProxy().setMaxTimeRange(parseValue(params.get("maxTimeRange")));
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ public class KibanaItemProperty {
private EsProperty es;

/**
* 超过ROUND_ABLE_MIN_PERIOD 支持round.
* 超过ROUND_ABLE_MIN_PERIOD 支持round,单位ms.
*/
private long roundAbleMinPeriod;
private long roundAbleMinPeriod = 120000;

/**
* round值,单位s.
*/
private int round;

/**
* 支持的时间周期.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/ly/ckibana/parser/ParamParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ public long getTimeIntervalMillSeconds(Range timeRange) {

/**
* 时间参数round.
* 2分钟内数据不round,inSpecialTime round 20s,默认round 10s
* 2分钟内数据不round, 默认round 10s
* 返回ui
*/
public Range getTimeRangeAfterRound(CkRequestContext ckRequestContext) {
Range result = ckRequestContext.getTimeRange();
KibanaItemProperty kibanaItemProperty = proxyConfigLoader.getKibanaProperty().getProxy();
boolean isRoundAble = getTimeIntervalMillSeconds(result) > kibanaItemProperty.getRoundAbleMinPeriod();
if (isRoundAble) {
int realRound = Constants.ROUND_SECOND;
int realRound = kibanaItemProperty.getRound() > 0 ? kibanaItemProperty.getRound() : Constants.ROUND_SECOND;
result.setHigh(DateUtils.roundToMSecond(Math.min(System.currentTimeMillis(), (Long) result.getHigh()), realRound));
result.setLow(DateUtils.roundToMSecond((Long) result.getLow(), realRound));
}
Expand Down

0 comments on commit 35b8dd6

Please sign in to comment.