Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: fix overflow of integers #2029

Merged
merged 1 commit into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public class PushServiceImpl implements PushService {

private final Map<Long, Long> 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<Long, PushMetricsDto.Metrics> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -217,7 +217,7 @@ public Map<String, List<Value>> 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) {
Expand Down
Loading