浏览代码

去除无用配置

gufengshou1 1 年之前
父节点
当前提交
29c8338e89

+ 0 - 206
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/redis/AdOwnRedisHelper.java

@@ -1,206 +0,0 @@
-package com.tzld.piaoquan.ad.engine.commons.redis;
-
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
-
-@Component
-public class AdOwnRedisHelper {
-
-    private final static Logger log = LoggerFactory.getLogger(AdOwnRedisHelper.class);
-
-    private final static Long AD_FILTER_DEFAULT_EXPIRE_TIME = 30L * 24 * 60 * 60; // 排除人群(广告、计划)默认设置30天,单位秒
-    private final static Long AD_FILTER_DELAY_QUEUE_EXPIRETIME = 5L * 60 * 1000; // 排除人群优化默认设置5分钟,单位毫秒
-    private final static Long AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME = 1L * 24 * 60 * 60; // 排除人群优化默认设置1天,单位秒
-    @Resource(name = "adOwnRedisTemplate")
-    private RedisTemplate<String, String> adOwnRedisTemplate;
-
-
-    public boolean containsKey(String key) {
-        return adOwnRedisTemplate.hasKey(key);
-    }
-
-    public String getString(String key) {
-        Object obj = adOwnRedisTemplate.opsForValue().get(key);
-        return Objects.isNull(obj) ? null : obj.toString();
-    }
-
-    public Long getLong(String key) {
-        long longVal = 0L;
-        Object obj = adOwnRedisTemplate.opsForValue().get(key);
-        if (Objects.nonNull(obj)) {
-            try {
-                longVal = Long.parseLong(obj.toString());
-            } catch (Exception e) {
-                e.printStackTrace();
-                return longVal;
-            }
-
-        }
-        return longVal;
-    }
-
-    public void setValueWithExpire(String key, String value, Date date) {
-        long expireTime;
-        if (date != null) {
-            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
-            if (expireTime < 0) { // 过期时间有问题,或者小于当前时间
-                expireTime = AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME;
-            }
-        } else {
-            expireTime = AD_FILTER_DEFAULT_USER_BEHAVIOR_EXPIRETIME;
-        }
-        adOwnRedisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.SECONDS);
-    }
-
-    public void setIncrementValue(String key, long value, Date date) {
-        Long expireTime;
-        if (date != null) {
-            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
-            // 过期时间有问题,或者小于当前时间
-            if (expireTime < 0) {
-                expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
-            }
-        } else { // date为null
-            expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
-        }
-        // 只在第一次进行设置过期时间
-        if (!containsKey(key)) {
-            adOwnRedisTemplate.opsForValue().increment(key, value);
-            adOwnRedisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
-        } else {
-            adOwnRedisTemplate.opsForValue().increment(key, value);
-        }
-    }
-
-    public void setIncrementValue(String key, double value, Date date) {
-        Long expireTime;
-        if (date != null) {
-            expireTime = (date.getTime() - System.currentTimeMillis()) / 1000;
-            // 过期时间有问题,或者小于当前时间
-            if (expireTime < 0) {
-                expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
-            }
-        } else { // date为null
-            expireTime = AD_FILTER_DEFAULT_EXPIRE_TIME;
-        }
-        // 只在第一次进行设置过期时间
-        if (!containsKey(key)) {
-            adOwnRedisTemplate.opsForValue().increment(key, value);
-            adOwnRedisTemplate.expire(key, expireTime, TimeUnit.SECONDS);
-        } else {
-            adOwnRedisTemplate.opsForValue().increment(key, value);
-        }
-    }
-
-    public int getInteger(String key) {
-        Object obj = adOwnRedisTemplate.opsForValue().get(key);
-        if (Objects.isNull(obj)) {
-            return 0;
-        }
-        return Integer.valueOf(obj.toString());
-    }
-
-    public void putDelayQueueMsg(String key, String value) {
-        adOwnRedisTemplate.opsForZSet().add(key, value, System.currentTimeMillis() + AD_FILTER_DELAY_QUEUE_EXPIRETIME);
-    }
-
-    public Set<String> processDelayQueue(String key) {
-        long currentTimeMillis = System.currentTimeMillis();
-        Set<String> values = adOwnRedisTemplate.opsForZSet().rangeByScore(key, 0, currentTimeMillis);
-        if (!CollectionUtils.isEmpty(values)) {
-            adOwnRedisTemplate.opsForZSet().removeRangeByScore(key, 0, currentTimeMillis);
-        }
-        return values;
-    }
-
-    public void addVal(String key, String val) {
-        adOwnRedisTemplate.opsForValue().set(key, val);
-    }
-
-    public Double zScore(String key, String value) {
-        return adOwnRedisTemplate.opsForZSet().score(key, value);
-    }
-
-    public Long getKeyExpire(String key) {
-        return adOwnRedisTemplate.getExpire(key, TimeUnit.SECONDS);
-    }
-
-    public void expire(String key, Long time) {
-        adOwnRedisTemplate.expire(key, time, TimeUnit.SECONDS);
-    }
-
-    public Long countExistingKeys(List<String> keys) {
-        return adOwnRedisTemplate.countExistingKeys(keys);
-    }
-
-    public boolean del(String key) {
-        return adOwnRedisTemplate.delete(key);
-    }
-
-    public boolean set(String key, String value, long time) {
-        try {
-            if (time > 0) {
-                adOwnRedisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
-            } else {
-                adOwnRedisTemplate.opsForValue().set(key, value);
-            }
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    /**
-     * Redis 分布式锁
-     *
-     * @param key        锁键
-     * @param value      锁值,可以为随机数或者 UUID 等唯一标识符
-     * @param expireTime 锁过期时间,单位为秒
-     * @return true:获取锁成功,false:获取锁失败
-     */
-    public boolean tryLock(String key, String value, long expireTime) {
-        Boolean result = adOwnRedisTemplate.opsForValue().setIfAbsent(key, value, expireTime, TimeUnit.SECONDS);
-        if (result != null && result) {
-            // 获取锁成功
-            return true;
-        }
-        return false;
-    }
-
-    public void listLeftPush(String key, String value) {
-        adOwnRedisTemplate.opsForList().leftPush(key, value);
-
-    }
-
-    public String listRightPop(String key) {
-        return adOwnRedisTemplate.opsForList().rightPop(key);
-    }
-
-    public Double getDouble(String key) {
-        String val = adOwnRedisTemplate.opsForValue().get(key);
-        if (StringUtils.isNotBlank(val)) {
-            return Double.valueOf(val);
-        }
-        return null;
-    }
-
-    public String get(String key) {
-        String val = adOwnRedisTemplate.opsForValue().get(key);
-        if (StringUtils.isNotBlank(val)) {
-            return val;
-        }
-        return null;
-    }
-}

+ 1 - 1
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/redis/AlgorithmRedisHelper.java

@@ -16,7 +16,7 @@ import java.util.concurrent.TimeUnit;
 
 @Component
 public class AlgorithmRedisHelper {
-    private final static Logger log = LoggerFactory.getLogger(AdOwnRedisHelper.class);
+    private final static Logger log = LoggerFactory.getLogger(AlgorithmRedisHelper.class);
 
     private final static Long AD_FILTER_DEFAULT_EXPIRE_TIME = 30L * 24 * 60 * 60; // 排除人群(广告、计划)默认设置30天,单位秒
     private final static Long AD_FILTER_DELAY_QUEUE_EXPIRETIME = 5L * 60 * 1000; // 排除人群优化默认设置5分钟,单位毫秒

+ 0 - 37
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/redis/RedisTemplateConfig.java

@@ -33,41 +33,6 @@ public class RedisTemplateConfig {
         return new GenericObjectPoolConfig<>();
     }
 
-    @Bean
-    @ConfigurationProperties(prefix = "spring.redis")
-    public RedisStandaloneConfiguration redisConfig() {
-        return new RedisStandaloneConfiguration();
-    }
-
-    @Bean("factory")
-    @Primary
-    public LettuceConnectionFactory factory(GenericObjectPoolConfig<LettucePoolingClientConfiguration> config, RedisStandaloneConfiguration redisConfig) {
-        LettuceClientConfiguration lettuceClientConfiguration = LettucePoolingClientConfiguration.builder().poolConfig(config).build();
-        return new LettuceConnectionFactory(redisConfig, lettuceClientConfiguration);
-    }
-
-    @Bean(name = "redisTemplate")
-    public RedisTemplate<String, String> getRedisTemplate(@Qualifier("factory") RedisConnectionFactory factory) {
-        return buildRedisTemplateByString(factory);
-    }
-
-    @Bean
-    @ConfigurationProperties(prefix = "spring.redis-ad")
-    public RedisStandaloneConfiguration adOwnRedisConfig() {
-        return new RedisStandaloneConfiguration();
-    }
-
-    @Bean("adOwnFactory")
-    public LettuceConnectionFactory pushCenterFactory(GenericObjectPoolConfig<LettucePoolingClientConfiguration> config, RedisStandaloneConfiguration adOwnRedisConfig) {
-        LettuceClientConfiguration lettuceClientConfiguration = LettucePoolingClientConfiguration.builder().poolConfig(config).build();
-        return new LettuceConnectionFactory(adOwnRedisConfig, lettuceClientConfiguration);
-    }
-
-    @Bean(name = "adOwnRedisTemplate")
-    public RedisTemplate<String, String> getPushCenterRedisTemplate(@Qualifier("adOwnFactory") RedisConnectionFactory pushCenterFactory) {
-        return buildRedisTemplateByString(pushCenterFactory);
-    }
-
     @Bean(name = "algorithmRedisTemplate")
     public RedisTemplate<String, String> getAlgorithmRedisTemplate(@Qualifier("algorithmRedisFactory") RedisConnectionFactory algorithmRedisFactory) {
         return buildRedisTemplateByString(algorithmRedisFactory);
@@ -85,8 +50,6 @@ public class RedisTemplateConfig {
         return new LettuceConnectionFactory(algorithmRedisConfig, lettuceClientConfiguration);
     }
 
-
-
     /**
      * 构建redisTemplate 使用string序列化
      *

+ 0 - 16
ad-engine-server/src/main/resources/application-dev.yml

@@ -26,22 +26,6 @@ spring:
       #username: wx2023_ad
       #password: wx2023_adP@assword1234
 
-  redis:
-    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
-    port: 6379
-    password: Wqsd@2019
-    timeout: 1000
-    lettuce:
-      pool:
-        max-active: 8
-        max-wait: -1
-        max-idle: 8
-        min-idle: 0
-  redis-ad:
-    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
-    port: 6379
-    password: Wqsd@2019
-    timeout: 1000
   redis-algorithm:
 #    hostName: r-bp1ps6my7lzg8rdhwx682.redis.rds.aliyuncs.com
     hostName: r-bp1fogs2mflr1ybfot.redis.rds.aliyuncs.com

+ 0 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/AddThresholdPredictModel.java

@@ -1,10 +1,8 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
 
-import com.tzld.piaoquan.ad.engine.commons.redis.AdOwnRedisHelper;
 import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.calculator.ThresholdPredictCalculator;
-import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;
 import com.tzld.piaoquan.ad.engine.service.predict.param.RuleParamHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdCalculateParam;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;

+ 0 - 4
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/BasicThresholdPredictModel.java

@@ -1,11 +1,7 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-import com.tzld.piaoquan.ad.engine.commons.redis.AdOwnRedisHelper;
 import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.calculator.ThresholdPredictCalculator;
-import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;
 import com.tzld.piaoquan.ad.engine.service.predict.param.RuleParamHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdCalculateParam;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;

+ 0 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/MultiplyThresholdPredictModel.java

@@ -1,9 +1,7 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
-import com.tzld.piaoquan.ad.engine.commons.redis.AdOwnRedisHelper;
 import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.calculator.ThresholdPredictCalculator;
-import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;
 import com.tzld.piaoquan.ad.engine.service.predict.param.RuleParamHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdCalculateParam;
 import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;

+ 0 - 1
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/model/threshold/ScoreThresholdPredictModel.java

@@ -1,6 +1,5 @@
 package com.tzld.piaoquan.ad.engine.service.predict.model.threshold;
 
-import com.tzld.piaoquan.ad.engine.commons.redis.AdOwnRedisHelper;
 import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
 import com.tzld.piaoquan.ad.engine.service.predict.config.AdOutV1OnlineWeightConfig;
 import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;