diff --git a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java index b2c13509458..3c2214726e1 100644 --- a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java +++ b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java @@ -119,7 +119,7 @@ public boolean filterConverge(Alert currentAlert) { } } if (match) { - long evalInterval = alertConverge.getEvalInterval() * 1000; + long evalInterval = alertConverge.getEvalInterval() * 1000L; long now = System.currentTimeMillis(); if (evalInterval <= 0) { return true; diff --git a/push/src/main/java/org/apache/hertzbeat/push/service/impl/PushServiceImpl.java b/push/src/main/java/org/apache/hertzbeat/push/service/impl/PushServiceImpl.java index 1abd4416f5e..5cdd981ca96 100644 --- a/push/src/main/java/org/apache/hertzbeat/push/service/impl/PushServiceImpl.java +++ b/push/src/main/java/org/apache/hertzbeat/push/service/impl/PushServiceImpl.java @@ -52,11 +52,11 @@ public class PushServiceImpl implements PushService { private final Map monitorIdCache; // key: monitorId, value: time stamp of last query - private static final long cacheTimeout = 5000; // ms + private static final long cacheTimeout = 5000L; // ms private final Map lastPushMetrics; - private static final long deleteMetricsPeriod = 1000 * 60 * 60 * 12; + private static final long deleteMetricsPeriod = 1000 * 60 * 60 * 12L; private static final long deleteBeforeTime = deleteMetricsPeriod / 2; diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/greptime/GrepTimeDbDataStorage.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/greptime/GrepTimeDbDataStorage.java index c0122b82897..4109cf025e9 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/greptime/GrepTimeDbDataStorage.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/greptime/GrepTimeDbDataStorage.java @@ -287,11 +287,11 @@ private long getExpireTimeFromToken(String history) { try { TemporalAmount temporalAmount = TimePeriodUtil.parseTokenTime(history); ZonedDateTime dateTime = ZonedDateTime.now().minus(temporalAmount); - expireTime = dateTime.toEpochSecond() * 1000; + expireTime = dateTime.toEpochSecond() * 1000L; } catch (Exception e) { log.error("parse history time error: {}. use default: 6h", e.getMessage()); ZonedDateTime dateTime = ZonedDateTime.now().minus(Duration.ofHours(6)); - expireTime = dateTime.toEpochSecond() * 1000; + expireTime = dateTime.toEpochSecond() * 1000L; } return expireTime; } diff --git a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/jpa/JpaDatabaseDataStorage.java b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/jpa/JpaDatabaseDataStorage.java index caea08df40c..786ea2d8728 100644 --- a/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/jpa/JpaDatabaseDataStorage.java +++ b/warehouse/src/main/java/org/apache/hertzbeat/warehouse/store/history/jpa/JpaDatabaseDataStorage.java @@ -83,20 +83,20 @@ public void expiredDataCleaner() { log.warn("[jpa-metrics-store]-start running expired data cleaner." + "Please use time series db instead of jpa for better performance"); String expireTimeStr = jpaProperties.expireTime(); - long expireTime = 0; + long expireTime; try { if (NumberUtils.isParsable(expireTimeStr)) { expireTime = NumberUtils.toLong(expireTimeStr); - expireTime = (ZonedDateTime.now().toEpochSecond() + expireTime) * 1000; + expireTime = (ZonedDateTime.now().toEpochSecond() + expireTime) * 1000L; } else { TemporalAmount temporalAmount = TimePeriodUtil.parseTokenTime(expireTimeStr); ZonedDateTime dateTime = ZonedDateTime.now().minus(temporalAmount); - expireTime = dateTime.toEpochSecond() * 1000; + expireTime = dateTime.toEpochSecond() * 1000L; } } catch (Exception e) { log.error("expiredDataCleaner time error: {}. use default expire time to clean: 1h", e.getMessage()); ZonedDateTime dateTime = ZonedDateTime.now().minus(Duration.ofHours(1)); - expireTime = dateTime.toEpochSecond() * 1000; + expireTime = dateTime.toEpochSecond() * 1000L; } try { int rows = historyDao.deleteHistoriesByTimeBefore(expireTime); @@ -217,7 +217,7 @@ public Map> getHistoryMetricData(Long monitorId, String app, try { TemporalAmount temporalAmount = TimePeriodUtil.parseTokenTime(history); ZonedDateTime dateTime = ZonedDateTime.now().minus(temporalAmount); - long timeBefore = dateTime.toEpochSecond() * 1000; + long timeBefore = dateTime.toEpochSecond() * 1000L; Predicate timePredicate = criteriaBuilder.ge(root.get("time"), timeBefore); andList.add(timePredicate); } catch (Exception e) {