|
|
@@ -4,6 +4,8 @@ import com.adx.tencent.storage.model.BidRecord;
|
|
|
import com.adx.tencent.storage.model.QueuedEvent;
|
|
|
import com.adx.tencent.storage.model.TrackingRecord;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.data.redis.core.script.DefaultRedisScript;
|
|
|
import org.springframework.data.redis.connection.stream.*;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
@@ -23,6 +25,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
*/
|
|
|
public class RedisHotStore {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(RedisHotStore.class);
|
|
|
public static final String BID_NOT_FOUND_MSG = "bid not found";
|
|
|
private static final Duration IMPRESSION_BID_TTL = Duration.ofHours(3);
|
|
|
private static final Duration DEFAULT_CONVERSION_SEEN_TTL = Duration.ofDays(7);
|
|
|
@@ -381,7 +384,12 @@ public class RedisHotStore {
|
|
|
|
|
|
public void delete(List<String> ids) {
|
|
|
if (ids == null || ids.isEmpty()) return;
|
|
|
- redis.opsForStream().delete(stream, ids.toArray(String[]::new));
|
|
|
+ try {
|
|
|
+ redis.opsForStream().delete(stream, ids.toArray(String[]::new));
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("[RedisHotStore] delete acknowledged stream entries failed | stream={} | count={} | error={}",
|
|
|
+ stream, ids.size(), rootMessage(e));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -389,7 +397,12 @@ public class RedisHotStore {
|
|
|
*/
|
|
|
public void trim(long maxLen) {
|
|
|
if (maxLen <= 0) return;
|
|
|
- redis.opsForStream().trim(stream, maxLen, false);
|
|
|
+ try {
|
|
|
+ redis.opsForStream().trim(stream, maxLen, false);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("[RedisHotStore] trim stream failed | stream={} | maxLen={} | error={}",
|
|
|
+ stream, maxLen, rootMessage(e));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void trimStreamIfNeeded(org.springframework.data.redis.connection.RedisConnection conn) {
|
|
|
@@ -465,6 +478,18 @@ public class RedisHotStore {
|
|
|
return script;
|
|
|
}
|
|
|
|
|
|
+ private static String rootMessage(Throwable e) {
|
|
|
+ Throwable cur = e;
|
|
|
+ String msg = null;
|
|
|
+ while (cur != null) {
|
|
|
+ if (cur.getMessage() != null && !cur.getMessage().isBlank()) {
|
|
|
+ msg = cur.getMessage();
|
|
|
+ }
|
|
|
+ cur = cur.getCause();
|
|
|
+ }
|
|
|
+ return msg == null ? "" : msg;
|
|
|
+ }
|
|
|
+
|
|
|
public static class DeductionDecision {
|
|
|
private final long totalSeen;
|
|
|
private final long totalDeducted;
|