diff --git a/src/main/java/com/dispose/annotation/UserId.java b/src/main/java/com/dispose/annotation/UserId.java deleted file mode 100644 index ea11bdbc..00000000 --- a/src/main/java/com/dispose/annotation/UserId.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.dispose.annotation; - -import com.dispose.annotation.validator.UserIdValidator; -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; -import javax.validation.Constraint; -import javax.validation.Payload; - -/** - * @author phoenix - * @date 2020年2月8日 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.FIELD, ElementType.ANNOTATION_TYPE}) -//指定注解的处理类 -@Constraint(validatedBy = {UserIdValidator.class}) -public @interface UserId { - - String value() default ""; - - String message() default "用户 ID 不存在"; - - Class[] groups() default {}; - - Class[] payload() default {}; -} diff --git a/src/main/java/com/dispose/annotation/bodyencdec/ReqDec.java b/src/main/java/com/dispose/annotation/bodyencdec/ReqDec.java deleted file mode 100644 index c7ec2fe9..00000000 --- a/src/main/java/com/dispose/annotation/bodyencdec/ReqDec.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dispose.annotation.bodyencdec; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author phoenix - * @date 2020年2月10日 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ReqDec { - -} - diff --git a/src/main/java/com/dispose/annotation/bodyencdec/RespEnc.java b/src/main/java/com/dispose/annotation/bodyencdec/RespEnc.java deleted file mode 100644 index fa0f84ed..00000000 --- a/src/main/java/com/dispose/annotation/bodyencdec/RespEnc.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.dispose.annotation.bodyencdec; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @author phoenix - * @date 2020年2月10日 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface RespEnc { - -} - diff --git a/src/main/java/com/dispose/annotation/validator/UserIdValidator.java b/src/main/java/com/dispose/annotation/validator/UserIdValidator.java deleted file mode 100644 index 1f24e451..00000000 --- a/src/main/java/com/dispose/annotation/validator/UserIdValidator.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.dispose.annotation.validator; - -import com.dispose.annotation.UserId; -import com.google.common.collect.Sets; -import java.util.Set; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; - -/** - * @author phoenix - * @date 2020年2月8日 - */ -public class UserIdValidator implements ConstraintValidator { - - private final Set idSet = Sets.newHashSet(1L, 2L); - - /** - * 快速失败模式下,这里无法注入依赖 参数校验的数据源相关校验放到controller里 方法抽象到下层service中 - */ - - @Override - public boolean isValid(Long aLong, ConstraintValidatorContext constraintValidatorContext) { - if (aLong == null) { - return false; - } - return existsById(aLong); - } - - private boolean existsById(long aId) { - return idSet.contains(aId); - } - -} diff --git a/src/main/java/com/dispose/aop/MyInterceptor.java b/src/main/java/com/dispose/aop/MyInterceptor.java deleted file mode 100644 index 55723a13..00000000 --- a/src/main/java/com/dispose/aop/MyInterceptor.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.dispose.aop; - -import java.lang.reflect.Method; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.stereotype.Component; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -/** - * AOP切面 - * - * @author phoenix - * @date 2020年2月4日 - */ -@Aspect -@Component -@Slf4j -public class MyInterceptor { - - public static final String EXEC = "execution(* com.cmcc.hy.phoenix.controller.*.*(..))" - + "&& !execution(* com.cmcc.hy.phoenix.controller.*.get*(..))" - + "&& !execution(* com.cmcc.hy.phoenix.controller.*.set*(..))"; - - /** - * - */ - @Pointcut(EXEC) - public void interceptor() { - } - - /** - * @param point - * @return - * @throws Throwable - */ - @SuppressWarnings("unused") - @Around("interceptor()") - public Object doAround(ProceedingJoinPoint point) throws Throwable { - Method method = ((MethodSignature) point.getSignature()).getMethod(); - log.info("方法:" + method.getName()); - HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) - .getRequest(); - HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()) - .getResponse(); - - return point.proceed(); - } -} diff --git a/src/main/java/com/dispose/aop/cache/CacheDel.java b/src/main/java/com/dispose/aop/cache/CacheDel.java deleted file mode 100644 index ebe3eb5c..00000000 --- a/src/main/java/com/dispose/aop/cache/CacheDel.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.dispose.aop.cache; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 在数据更新、删除情况下,先删除缓存 - * - * @author phoenix - * @date 2020年2月25日 - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface CacheDel { - - /** - * 什么对象 - * - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - Class clazz(); - - /** - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - String[] key() default {}; - -} diff --git a/src/main/java/com/dispose/aop/cache/CacheGet.java b/src/main/java/com/dispose/aop/cache/CacheGet.java deleted file mode 100644 index 613cc0ed..00000000 --- a/src/main/java/com/dispose/aop/cache/CacheGet.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.dispose.aop.cache; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 先从缓存读取,读不到走数据层读取,并存入缓存 - * - * @author phoenix - * @date 2020年2月25日 - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface CacheGet { - - /** - * 缓存的有效期,默认300秒 - * - * @return - * @Description: - */ - int ttl() default 300; - - /** - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - String[] key(); - - /** - * 是否缓存空值,防止缓存穿透使用 - * 慎用 - * 如果使用了空缓存,而不使用CachePut,则数据影响周期就是ttl时间 - * - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - boolean cacheNull() default false; - -} diff --git a/src/main/java/com/dispose/aop/cache/CachePut.java b/src/main/java/com/dispose/aop/cache/CachePut.java deleted file mode 100644 index cc31950e..00000000 --- a/src/main/java/com/dispose/aop/cache/CachePut.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.dispose.aop.cache; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 新增数据,直接设置缓存,目的适合缓存穿透结合使用 - * 减少空缓存影响时间 - * - * @author phoenix - * @date 2020年2月25日 - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface CachePut { - - /** - * 缓存的有效期,默认300秒 - * - * @return - * @Description: - */ - int ttl() default 300; - - /** - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - String[] key() default {}; - -} diff --git a/src/main/java/com/dispose/aop/cache/MyCache.java b/src/main/java/com/dispose/aop/cache/MyCache.java deleted file mode 100644 index 7121a42d..00000000 --- a/src/main/java/com/dispose/aop/cache/MyCache.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dispose.aop.cache; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Inherited; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 某些方法需要组合注解的用这个注解标注 - * - * @author phoenix - * @date 2020年3月4日 - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -@Inherited -@Documented -public @interface MyCache { - - CachePut[] put() default {};//保存数据同时设置多个key缓存 - - //CacheGet[] get() default {}; - - CacheDel[] del() default {};//删除对象,需要删除该对象的所有缓存数据 - -} diff --git a/src/main/java/com/dispose/aop/cache/MyCacheInterceptor.java b/src/main/java/com/dispose/aop/cache/MyCacheInterceptor.java deleted file mode 100644 index 9dc31f71..00000000 --- a/src/main/java/com/dispose/aop/cache/MyCacheInterceptor.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.dispose.aop.cache; - -import com.dispose.common.Utils; -import com.dispose.redis.RedisClient; -import java.io.Serializable; -import java.lang.reflect.Method; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.ArrayUtils; -import org.apache.commons.lang3.ObjectUtils; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.core.LocalVariableTableParameterNameDiscoverer; -import org.springframework.expression.EvaluationContext; -import org.springframework.expression.Expression; -import org.springframework.expression.ExpressionParser; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.stereotype.Component; - -/** - * 自定义封装manager缓存统一管理 TODO 未完待续 - * - * @author phoenix - * @date 2020年2月10日 - */ -@Aspect -@Component -@Slf4j -public class MyCacheInterceptor { - - public static final String EXEC = "execution(* com.cmcc.hy.phoenix.manager.*.* (..))"; - // + "&& !execution(* com.cmcc.hy.phoenix.manager.impl.*.get*(..))" - // + "&& !execution(* com.cmcc.hy.phoenix.manager.impl.*.set*(..))"; - /** - * 缓存key分隔符 - */ - public static final String SPILIT = "#"; - /** - * 系统统一缓存key前缀 - */ - public static final String CACHE_PREFIX = "PHOENIX_IC" + SPILIT; - // SpelExpressionParser spelExpressionParser = new SpelExpressionParser(); - public static final String CACHE_NULL = "NULL"; - private static final ExpressionParser parser = new SpelExpressionParser(); - @Resource - private RedisClient redisClient; - - /** - * - */ - @Pointcut(EXEC) - public void cache() { - } - - /** - * 切记,这三个缓存注解,不可同时在一个方法上使用 如果出现,一定是你的业务设计有问题 - * - * @param point - * @return - * @throws Throwable - * @数据操作可归结为 CRUD 操作(增加、读取、更新、删除) - * @组合操作 MyCache - * @增加:可能需要CachePut - * @读取:可能需要CacheGet - * @更新:可能需要CacheDel 这里不要加CachePut,简化操作,简单就是高效 - * @删除:可能需要CacheDel - */ - @Around("cache()") - public Object doAround(ProceedingJoinPoint point) throws Throwable { - Method method = ((MethodSignature) point.getSignature()).getMethod(); - log.info("CACHE拦截方法:" + point.getSignature().getName()); - MyCache mc = method.getAnnotation(MyCache.class); - if (mc != null) { - Object obj = point.proceed(); - if ((int) obj > 0) { - //说明增删改操作有实际数据生效 - log.info("方法 {} 检查到注解 @MyCache", method.getName()); - CachePut[] puts = mc.put(); - if (ArrayUtils.isNotEmpty(puts)) { - log.info("方法 {} 检查到组合注解 @CachePut", method.getName()); - for (int i = 0; i < puts.length; i++) { - putHandle(point, puts[i]); - } - } - CacheDel[] dels = mc.del(); - if (ArrayUtils.isNotEmpty(dels)) { - log.info("方法 {} 检查到组合注解 @CacheDel", method.getName()); - for (int i = 0; i < dels.length; i++) { - delHandle(point, dels[i]); - } - } - return obj; - } else { - log.info("方法 {} 未实际产生数据影响", method.getName()); - } - } else { - CacheGet get = method.getAnnotation(CacheGet.class); - if (get != null) { - log.info("方法 {} 检查到独立注解 @CacheGet", method.getName()); - return getHandle(point, get); - } - Object obj = point.proceed(); - CachePut put = method.getAnnotation(CachePut.class); - if (put != null) { - log.info("方法 {} 检查到独立注解 @CachePut", method.getName()); - if ((int) obj > 0) { - putHandle(point, put); - } - } - CacheDel del = method.getAnnotation(CacheDel.class); - if (del != null) { - log.info("方法 {} 检查到独立注解 @CacheDel", method.getName()); - if ((int) obj > 0) { - delHandle(point, del); - } - } - return obj; - } - return point.proceed(); - } - - @SuppressWarnings("unchecked") - private void putHandle(ProceedingJoinPoint point, CachePut put) throws Throwable { - log.info("CachePut操作"); - Method method = ((MethodSignature) point.getSignature()).getMethod(); - Class[] clazz = (Class[]) method.getParameterTypes(); - String[] keys = put.key(); - String key = genKey(point, clazz[0], keys); - log.info("key = " + key); - Object[] obj = point.getArgs(); - if (ObjectUtils.isEmpty(obj[0])) { - log.warn("参数为NULL,不要使用CachePut注解"); - } else { - redisClient.put(key, clazz[0].cast(obj[0]), Utils.randomTTL(put.ttl())); - log.info("设置缓存 {}", key); - } - } - - private void delHandle(ProceedingJoinPoint point, CacheDel del) throws Throwable { - // 说明要删除缓存 - log.info("CacheDel操作"); - String[] keys = del.key(); - String key = genKey(point, del.clazz(), keys); - log.info("key = " + key); - redisClient.del(key); - log.info("缓存清空 {}", key); - // point.proceed(); - } - - @SuppressWarnings("unchecked") - private Object getHandle(ProceedingJoinPoint point, CacheGet get) throws Throwable { - // 说明是读数据操作,优先读取缓存 - log.info("CacheGet操作"); - Method method = ((MethodSignature) point.getSignature()).getMethod(); - Class clazz = (Class) method.getReturnType(); - String key = genKey(point, clazz, get.key()); - log.info("key = " + key); - int ttl = Utils.randomTTL(get.ttl()); - Object obj = redisClient.get(key, clazz); - if (ObjectUtils.isEmpty(obj)) { - log.info("缓存查询为空"); - obj = point.proceed(); - if (ObjectUtils.isNotEmpty(obj)) { - log.info("数据库查询到数据 {}", obj); - redisClient.put(key, clazz.cast(obj), ttl); - log.info("成功将数据存入缓存"); - } else { - log.info("数据库查询依然为空"); - // 开启防缓存穿透,设置空缓存 - if (get.cacheNull()) { - redisClient.put(key, CACHE_NULL, ttl); - log.info("设置空缓存,防缓存穿透"); - } - } - } else if (CACHE_NULL.equals(obj)) { - // 缓存查询对象不为空,判断是否是空缓存 - obj = null; - } - return obj; - } - - private String genKey(ProceedingJoinPoint point, Class clazz, String[] keys) { - StringBuilder sb = new StringBuilder(); - String clazzName = clazz.getSimpleName(); - sb.append(CACHE_PREFIX).append(clazzName); - EvaluationContext context = getContext(point.getArgs(), point); - for (int i = 0; i < keys.length; i++) { - sb.append(SPILIT).append(getValue(context, keys[i], String.class)); - } - return sb.toString(); - } - - private T getValue(EvaluationContext context, String key, Class clazz) { - Expression expression = parser.parseExpression(key); - return expression.getValue(context, clazz); - } - - private EvaluationContext getContext(Object[] arguments, ProceedingJoinPoint point) { - String[] parameterNames = new LocalVariableTableParameterNameDiscoverer() - .getParameterNames(((MethodSignature) point.getSignature()).getMethod()); - if (parameterNames == null) { - throw new RuntimeException("参数列表不能为null"); - } - EvaluationContext context = new StandardEvaluationContext(); - for (int i = 0; i < arguments.length; i++) { - context.setVariable(parameterNames[i], arguments[i]); - } - return context; - } - -} diff --git a/src/main/java/com/dispose/common/ConstValue.java b/src/main/java/com/dispose/common/ConstValue.java index 2e713ceb..6bcc1506 100644 --- a/src/main/java/com/dispose/common/ConstValue.java +++ b/src/main/java/com/dispose/common/ConstValue.java @@ -4,192 +4,6 @@ package com.dispose.common; * The type Const value. */ public class ConstValue { - /** - * The enum Dispose device type. - */ - public enum DisposeDeviceType { - /** - * The Dptech umc. - */ - DPTECH_UMC(0, "迪普UMC管理平台"), - /** - * The Haohan platform. - */ - HAOHAN_PLATFORM(1, "浩瀚处置设备"), - - /** - * Virtual dispose dispose device type. - */ - VIRTUAL_DISPOSE(999, "虚拟处置设备"); - - private final int code; - private final String readme; - - DisposeDeviceType(int code, String readme) { - this.code = code; - this.readme = readme; - } - - /** - * Gets code. - * - * @return the code - */ - public int getCode() { - return this.code; - } - - /** - * Gets readme. - * - * @return the readme - */ - public String getReadme() { - return this.readme; - } - } - - /** - * The enum Device capacity. - */ - public enum DeviceCapacity { - /** - * The Cleanup. - */ - CLEANUP(0, "清洗能力"), - /** - * The Hidepend. - */ - HIDEPEND(1, "高防能力"), - /** - * The Blackhool. - */ - BLACKHOOL(2, "黑洞能力"), - /** - * The Detecive. - */ - DETECIVE(3, "检测能力"); - - private final int code; - private final String readme; - - DeviceCapacity(int code, String readme) { - this.code = code; - this.readme = readme; - } - - /** - * Gets code. - * - * @return the code - */ - public int getCode() { - return this.code; - } - - /** - * Gets readme. - * - * @return the readme - */ - public String getReadme() { - return this.readme; - } - } - - /** - * The enum Ip addr type. - */ - public enum IPAddrType { - /** - * The Ipv 4 type. - */ - IPV4_TYPE, - /** - * The Ipv 6 type. - */ - IPV6_TYPE; - - /** - * Gets ip addr type. - * - * @param ipAddr the ip addr - * @return the ip addr type - */ - public static IPAddrType getIpAddrType(String ipAddr) { - if (ipAddr.contains(":")) { - return IPV6_TYPE; - } else { - return IPV4_TYPE; - } - } - } - - public enum DisposeTaskStatus { - TASK_NEW(0, "新建"), - TASK_RUNNING(1, "运行中"), - TASK_STOP(2, "停止"), - TASK_FINISH(3, "结束"), - TASK_DELETE(4, "删除"); - - private final int code; - private final String readme; - - DisposeTaskStatus(int code, String readme) { - this.code = code; - this.readme = readme; - } - - /** - * Gets code. - * - * @return the code - */ - public int getCode() { - return this.code; - } - - /** - * Gets readme. - * - * @return the readme - */ - public String getReadme() { - return this.readme; - } - } - - public enum FlowDirection { - DIRECTION_INPUT(0, "流入"), - DIRECTION_OUTPUT(1, "流出"), - DIRECTION_TWOWAY(2, "双向"); - - private final int code; - private final String readme; - - FlowDirection(int code, String readme) { - this.code = code; - this.readme = readme; - } - - /** - * Gets code. - * - * @return the code - */ - public int getCode() { - return this.code; - } - - /** - * Gets readme. - * - * @return the readme - */ - public String getReadme() { - return this.readme; - } - } /** * The type Global configure. diff --git a/src/main/java/com/dispose/common/DeviceCapacity.java b/src/main/java/com/dispose/common/DeviceCapacity.java new file mode 100644 index 00000000..ec523a8f --- /dev/null +++ b/src/main/java/com/dispose/common/DeviceCapacity.java @@ -0,0 +1,49 @@ +package com.dispose.common; + +/** + * The enum Device capacity. + */ +public enum DeviceCapacity { + /** + * The Cleanup. + */ + CLEANUP(0, "清洗能力"), + /** + * The Hidepend. + */ + HIDEPEND(1, "高防能力"), + /** + * The Blackhool. + */ + BLACKHOOL(2, "黑洞能力"), + /** + * The Detecive. + */ + DETECIVE(3, "检测能力"); + + private final int code; + private final String readme; + + DeviceCapacity(int code, String readme) { + this.code = code; + this.readme = readme; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return this.code; + } + + /** + * Gets readme. + * + * @return the readme + */ + public String getReadme() { + return this.readme; + } +} diff --git a/src/main/java/com/dispose/common/DisposeDeviceType.java b/src/main/java/com/dispose/common/DisposeDeviceType.java new file mode 100644 index 00000000..d96bc1f2 --- /dev/null +++ b/src/main/java/com/dispose/common/DisposeDeviceType.java @@ -0,0 +1,46 @@ +package com.dispose.common; + +/** + * The enum Dispose device type. + */ +public enum DisposeDeviceType { + /** + * The Dptech umc. + */ + DPTECH_UMC(0, "迪普UMC管理平台"), + /** + * The Haohan platform. + */ + HAOHAN_PLATFORM(1, "浩瀚处置设备"), + + /** + * Virtual dispose dispose device type. + */ + VIRTUAL_DISPOSE(999, "虚拟处置设备"); + + private final int code; + private final String readme; + + DisposeDeviceType(int code, String readme) { + this.code = code; + this.readme = readme; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return this.code; + } + + /** + * Gets readme. + * + * @return the readme + */ + public String getReadme() { + return this.readme; + } +} diff --git a/src/main/java/com/dispose/common/DisposeTaskStatus.java b/src/main/java/com/dispose/common/DisposeTaskStatus.java new file mode 100644 index 00000000..e430f9f4 --- /dev/null +++ b/src/main/java/com/dispose/common/DisposeTaskStatus.java @@ -0,0 +1,35 @@ +package com.dispose.common; + +public enum DisposeTaskStatus { + TASK_NEW(0, "新建"), + TASK_RUNNING(1, "运行中"), + TASK_STOP(2, "停止"), + TASK_FINISH(3, "结束"), + TASK_DELETE(4, "删除"); + + private final int code; + private final String readme; + + DisposeTaskStatus(int code, String readme) { + this.code = code; + this.readme = readme; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return this.code; + } + + /** + * Gets readme. + * + * @return the readme + */ + public String getReadme() { + return this.readme; + } +} diff --git a/src/main/java/com/dispose/common/FlowDirection.java b/src/main/java/com/dispose/common/FlowDirection.java new file mode 100644 index 00000000..7ab27eda --- /dev/null +++ b/src/main/java/com/dispose/common/FlowDirection.java @@ -0,0 +1,33 @@ +package com.dispose.common; + +public enum FlowDirection { + DIRECTION_INPUT(0, "流入"), + DIRECTION_OUTPUT(1, "流出"), + DIRECTION_TWOWAY(2, "双向"); + + private final int code; + private final String readme; + + FlowDirection(int code, String readme) { + this.code = code; + this.readme = readme; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return this.code; + } + + /** + * Gets readme. + * + * @return the readme + */ + public String getReadme() { + return this.readme; + } +} diff --git a/src/main/java/com/dispose/common/IPAddrType.java b/src/main/java/com/dispose/common/IPAddrType.java new file mode 100644 index 00000000..842a55e7 --- /dev/null +++ b/src/main/java/com/dispose/common/IPAddrType.java @@ -0,0 +1,29 @@ +package com.dispose.common; + +/** + * The enum Ip addr type. + */ +public enum IPAddrType { + /** + * The Ipv 4 type. + */ + IPV4_TYPE, + /** + * The Ipv 6 type. + */ + IPV6_TYPE; + + /** + * Gets ip addr type. + * + * @param ipAddr the ip addr + * @return the ip addr type + */ + public static IPAddrType getIpAddrType(String ipAddr) { + if (ipAddr.contains(":")) { + return IPV6_TYPE; + } else { + return IPV4_TYPE; + } + } +} diff --git a/src/main/java/com/dispose/dispose/DeviceRouter.java b/src/main/java/com/dispose/dispose/DeviceRouter.java index cc6a17ab..d143d1c0 100644 --- a/src/main/java/com/dispose/dispose/DeviceRouter.java +++ b/src/main/java/com/dispose/dispose/DeviceRouter.java @@ -1,7 +1,8 @@ package com.dispose.dispose; -import com.dispose.common.ConstValue; +import com.dispose.common.DisposeDeviceType; import com.dispose.common.GlobalVar; +import com.dispose.common.IPAddrType; import com.dispose.dispose.impl.DPTechImpl; import com.dispose.dispose.impl.VirtualDeviceImpl; @@ -18,13 +19,13 @@ public class DeviceRouter { * @param ipType the ip type * @return the dispose entry manager */ - public static DisposeEntryManager deviceRouterFactory(int devType, String ipAddr, ConstValue.IPAddrType ipType) { + public static DisposeEntryManager deviceRouterFactory(int devType, String ipAddr, IPAddrType ipType) { if (GlobalVar.USED_VIRTUAL_DISPOSE_MODE) { return new VirtualDeviceImpl(ipAddr); } - if (devType == ConstValue.DisposeDeviceType.DPTECH_UMC.getCode()) { + if (devType == DisposeDeviceType.DPTECH_UMC.getCode()) { return new DPTechImpl(ipAddr); } @@ -39,6 +40,6 @@ public class DeviceRouter { * @return the dispose entry manager */ public static DisposeEntryManager deviceRouterFactory(int devType, String ipAddr) { - return deviceRouterFactory(devType, ipAddr, ConstValue.IPAddrType.IPV4_TYPE); + return deviceRouterFactory(devType, ipAddr, IPAddrType.IPV4_TYPE); } } diff --git a/src/main/java/com/dispose/dispose/impl/DPTechImpl.java b/src/main/java/com/dispose/dispose/impl/DPTechImpl.java index b5376d37..da8977ba 100644 --- a/src/main/java/com/dispose/dispose/impl/DPTechImpl.java +++ b/src/main/java/com/dispose/dispose/impl/DPTechImpl.java @@ -2,7 +2,9 @@ package com.dispose.dispose.impl; import com.dispose.Interceptor.SoapPasswordCallbackHandler; import com.dispose.common.ConstValue; +import com.dispose.common.DeviceCapacity; import com.dispose.common.GlobalVar; +import com.dispose.common.IPAddrType; import com.dispose.config.DisposeConfigure; import com.dispose.dispose.DisposeEntryManager; import com.dispose.dispose.po.DeviceInfo; @@ -75,7 +77,7 @@ public class DPTechImpl implements DisposeEntryManager { * @param ipAddr the ip addr * @param type the type */ - public DPTechImpl(String ipAddr, ConstValue.IPAddrType type) { + public DPTechImpl(String ipAddr, IPAddrType type) { this(ipAddr); } @@ -123,7 +125,7 @@ public class DPTechImpl implements DisposeEntryManager { if (devs != null && devs.length() > 0) { capList.add(DisposeDeviceCapacity.builder() - .capacity(ConstValue.DeviceCapacity.DETECIVE.getCode()) + .capacity(DeviceCapacity.DETECIVE.getCode()) .tolFlowCapacity(0) .build()); } @@ -147,7 +149,7 @@ public class DPTechImpl implements DisposeEntryManager { }); capList.add(DisposeDeviceCapacity.builder() - .capacity(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .capacity(DeviceCapacity.CLEANUP.getCode()) .tolFlowCapacity(0) .protectIpV4(proIPv4.toArray(new String[0])) .protectIpV6(proIPv6.toArray(new String[0])) diff --git a/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java b/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java index f1bf9646..77078b58 100644 --- a/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java +++ b/src/main/java/com/dispose/dispose/impl/VirtualDeviceImpl.java @@ -1,6 +1,7 @@ package com.dispose.dispose.impl; -import com.dispose.common.ConstValue; +import com.dispose.common.DeviceCapacity; +import com.dispose.common.IPAddrType; import com.dispose.dispose.DisposeEntryManager; import com.dispose.dispose.po.DeviceInfo; import com.dispose.pojo.po.DisposeDeviceCapacity; @@ -15,7 +16,7 @@ public class VirtualDeviceImpl implements DisposeEntryManager { } - public VirtualDeviceImpl(String ipAddr, ConstValue.IPAddrType type) { + public VirtualDeviceImpl(String ipAddr, IPAddrType type) { } @@ -70,14 +71,14 @@ public class VirtualDeviceImpl implements DisposeEntryManager { List capList = new ArrayList<>(); capList.add(DisposeDeviceCapacity.builder() - .capacity(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .capacity(DeviceCapacity.CLEANUP.getCode()) .protectIpV4(new String[]{"192.168.1.1", "192.168.1.2"}) .protectIpV6(new String[]{}) .tolFlowCapacity(1024) .build()); capList.add(DisposeDeviceCapacity.builder() - .capacity(ConstValue.DeviceCapacity.DETECIVE.getCode()) + .capacity(DeviceCapacity.DETECIVE.getCode()) .protectIpV4(new String[]{"192.168.2.1", "192.168.2.2"}) .protectIpV6(new String[]{}) .tolFlowCapacity(0) @@ -103,6 +104,7 @@ public class VirtualDeviceImpl implements DisposeEntryManager { * @return the all detection object */ @Override + @SuppressWarnings("unchecked") public T getAllDetectionObject() { List detectionObjects = new ArrayList<>(); @@ -117,6 +119,7 @@ public class VirtualDeviceImpl implements DisposeEntryManager { * @return the all protection object */ @Override + @SuppressWarnings("unchecked") public T getAllProtectionObject() { List protectObjects = new ArrayList<>(); diff --git a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java index 87dcdb84..e94c8182 100644 --- a/src/main/java/com/dispose/mapper/DisposeTaskMapper.java +++ b/src/main/java/com/dispose/mapper/DisposeTaskMapper.java @@ -58,7 +58,7 @@ public interface DisposeTaskMapper extends Mapper, * @param ipAddr the ip addr * @return the all task by dispose ip */ - List getAllTaskByDisposeIp(String ipAddr); + List getAllTaskByDisposeIp(@Param("ipAddr")String ipAddr); /** * Gets all task by node dev id. @@ -69,10 +69,38 @@ public interface DisposeTaskMapper extends Mapper, List getAllTaskByNodeDevId(Long devId); /** - * Gets all task by node user id. + * Gets node all task by user id. * * @param userId the user id - * @return the all task by node user id + * @return the node all task by user id */ - List getAllTaskByNodeUserId(Long userId); + List getNodeAllTaskByUserId(Long userId); + + /** + * Gets node task by ip and status. + * + * @param devId the dev id + * @param ipAddr the ip addr + * @param status the status + * @return the node task by ip and status + */ + List getNodeTaskByIpAndStatus(@Param("devId")Long devId, + @Param("ipAddr")String ipAddr, + @Param("status") int status); + + /** + * Gets all task by ip. + * + * @param ipAddr the ip addr + * @return the all task by ip + */ + List getAllTaskByIp(@Param("ipAddr")String ipAddr); + + /** + * Gets all task by status. + * + * @param status the status + * @return the all task by status + */ + List getAllTaskByStatus(@Param("status") int status); } diff --git a/src/main/java/com/dispose/redis/MyRedisConfiguration.java b/src/main/java/com/dispose/redis/MyRedisConfiguration.java deleted file mode 100644 index 6365937c..00000000 --- a/src/main/java/com/dispose/redis/MyRedisConfiguration.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.dispose.redis; - -import com.dispose.common.Utils; -import com.dispose.config.MyConfig; -import java.util.ArrayList; -import java.util.List; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.pool2.impl.GenericObjectPoolConfig; -import org.redisson.Redisson; -import org.redisson.api.RedissonClient; -import org.redisson.config.Config; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import redis.clients.jedis.JedisShardInfo; -import redis.clients.jedis.ShardedJedisPool; -import redis.clients.jedis.util.Hashing; -import redis.clients.jedis.util.Sharded; - -/** - * @author phoenix - * @date 2020年3月10日 - */ -@Configuration -@Slf4j -public class MyRedisConfiguration { - - @Resource - private MyConfig myConfig; - - @SuppressWarnings("rawtypes") - @ConditionalOnProperty(prefix = "phoenix", name = "redis.type", havingValue = "jedis") - @Bean - public ShardedJedisPool shardedJedisPool() { - GenericObjectPoolConfig config = new GenericObjectPoolConfig(); - // 连接数配置也可放到外部配置文件去 - config.setMaxTotal(128); - config.setMaxIdle(16); - config.setMinIdle(4); - config.setMaxWaitMillis(1000L); - config.setTestWhileIdle(true); - config.setTimeBetweenEvictionRunsMillis(30000L); - config.setMinEvictableIdleTimeMillis(600000L); - config.setNumTestsPerEvictionRun(-1); - config.setJmxEnabled(false); - List shards = new ArrayList(); - String[] serverList = myConfig.getRedisServer().split(",", 0); - for (String server : serverList) { - JedisShardInfo jsi = new JedisShardInfo(server); - jsi.setConnectionTimeout(5000); - jsi.setSoTimeout(5000); - shards.add(jsi); - } - log.info("Redis Type = jedis ,initialized success"); - return new ShardedJedisPool(config, shards, Hashing.MURMUR_HASH, Sharded.DEFAULT_KEY_TAG_PATTERN); - } - - /** - * @return - * @Description: Redisson哨兵模式实例 具体API操作参照Redisson Github对照表 - * https://github.com/redisson/redisson/wiki/11 - * .-Redis%E5%91%BD%E4%BB%A4%E5%92%8CRedisson%E5%AF%B9%E8%B1%A1%E5%8C%B9%E9%85%8D%E5%88%97%E8%A1%A8 - * @blog https://blog.csdn.net/unclecoco/article/details/99412915 - */ - @ConditionalOnProperty(prefix = "phoenix", name = "redis.type", havingValue = "redisson-sentinel") - @Bean - public RedissonClient redissonSentinel() { - List servers = Utils.splitStr2List(myConfig.getRedisServer(), ","); - Config config = new Config(); - String masterName = myConfig.getRedisRedissonSentinelMasterName(); - config.useSentinelServers().setMasterName(masterName).setPassword(myConfig.getRedisRedissonPwd()) - .addSentinelAddress(servers.toArray(new String[0])); - log.info("Redis Type = redisson-sentinel ,initialized success"); - return Redisson.create(config); - } - - /** - * 在redis服务端通过KP做主备 - * - * @return - * @Description: redisson single - */ - @ConditionalOnProperty(prefix = "phoenix", name = "redis.type", havingValue = "redisson-single") - @Bean - public RedissonClient redissonSingle() { - Config config = new Config(); - config.useSingleServer().setAddress(myConfig.getRedisServer()).setPassword(myConfig.getRedisRedissonPwd()); - log.info("Redis Type = redisson-single ,initialized success"); - return Redisson.create(config); - } - -} diff --git a/src/main/java/com/dispose/redis/ProtobufSerializer.java b/src/main/java/com/dispose/redis/ProtobufSerializer.java deleted file mode 100644 index 9963d683..00000000 --- a/src/main/java/com/dispose/redis/ProtobufSerializer.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.dispose.redis; - -import io.protostuff.LinkedBuffer; -import io.protostuff.ProtostuffIOUtil; -import io.protostuff.Schema; -import io.protostuff.runtime.RuntimeSchema; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import org.objenesis.Objenesis; -import org.objenesis.ObjenesisStd; - -/** - * @author phoenix - * @date 2020年2月8日 - */ -public class ProtobufSerializer { - - private static final Map, Schema> cachedSchema = new ConcurrentHashMap, Schema>(); - - private static final Objenesis objenesis = new ObjenesisStd(true); - - static { - cachedSchema.put(Boolean.class, RuntimeSchema.createFrom(Boolean.class)); - cachedSchema.put(Byte.class, RuntimeSchema.createFrom(Byte.class)); - cachedSchema.put(Short.class, RuntimeSchema.createFrom(Short.class)); - cachedSchema.put(Integer.class, RuntimeSchema.createFrom(Integer.class)); - cachedSchema.put(Long.class, RuntimeSchema.createFrom(Long.class)); - cachedSchema.put(Float.class, RuntimeSchema.createFrom(Float.class)); - cachedSchema.put(Double.class, RuntimeSchema.createFrom(Double.class)); - cachedSchema.put(Character.class, RuntimeSchema.createFrom(Character.class)); - cachedSchema.put(String.class, RuntimeSchema.createFrom(String.class)); - cachedSchema.put(BigInteger.class, RuntimeSchema.createFrom(BigInteger.class)); - cachedSchema.put(BigDecimal.class, RuntimeSchema.createFrom(BigDecimal.class)); - } - - @SuppressWarnings("unchecked") - private static Schema getSchema(Class cls) { - Schema schema = (Schema) cachedSchema.get(cls); - if (schema == null) { - schema = RuntimeSchema.createFrom(cls); - if (schema != null) { - cachedSchema.put(cls, schema); - } - } - return schema; - } - - /** - * @param obj - * @return - */ - @SuppressWarnings("unchecked") - public static byte[] serialize(T obj) { - Class cls = (Class) obj.getClass(); - LinkedBuffer buffer = LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE); - try { - Schema schema = getSchema(cls); - return ProtostuffIOUtil.toByteArray(obj, schema, buffer); - } catch (Exception e) { - throw new RuntimeException(e); - } finally { - buffer.clear(); - } - } - - /** - * @param bytes - * @return - */ - public static T deserialize(byte[] bytes) { - throw new UnsupportedOperationException(); - } - - /** - * @param bytes - * @param cls - * @return - */ - public static T deserialize(byte[] bytes, Class cls) { - try { - T message = objenesis.newInstance(cls); - Schema schema = getSchema(cls); - ProtostuffIOUtil.mergeFrom(bytes, message, schema); - return message; - } catch (Exception e) { - throw new RuntimeException(e); - } - } - -} - -/** - * Revision history - * ------------------------------------------------------------------------- - *

- * Date Author Note - * ------------------------------------------------------------------------- - * 2016年6月6日 chiwei create - */ diff --git a/src/main/java/com/dispose/redis/RedisClient.java b/src/main/java/com/dispose/redis/RedisClient.java deleted file mode 100644 index 3868dc52..00000000 --- a/src/main/java/com/dispose/redis/RedisClient.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.dispose.redis; - -import java.io.Serializable; - -/** - * @author phoenix - * @date 2020年2月8日 - */ -public interface RedisClient { - - /** - * @param k - * @param v - * @param seconds - */ - void put(String k, String v, int seconds); - - /** - * 序列化 - * - * @param v - * @param seconds - */ - void put(String key, T v, int seconds); - - /** - * @param key - * @return - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - boolean setLock(String key); - - /** - * @param key - * @Description: TODO(这里用一句话描述这个方法的作用) - */ - void delLock(String key); - - /** - * @param key - * @return - */ - String get(String key); - - /** - * @param key - * @param cls - * @return - */ - T get(String key, Class cls); - - /** - * @param key - */ - void del(String key); - - /** - * llen:().
- * - * @param key - * @return - * @author chiwei - * @since JDK 1.6 - */ - long llen(String key); - - /** - * @param key - * @param seconds - */ - void expire(String key, int seconds); - - /** - * @param key - * @param value - */ - void lpush(String key, String value); - - /** - * @param key - * @return - */ - String rpop(String key); - - /** - * @param key - * @param timeout seconds ;0 means hold until get data - * @return - */ - String brpop(String key, int timeout); - -} diff --git a/src/main/java/com/dispose/redis/jedis/RedisClientJedisImpl.java b/src/main/java/com/dispose/redis/jedis/RedisClientJedisImpl.java deleted file mode 100644 index 0f15bd86..00000000 --- a/src/main/java/com/dispose/redis/jedis/RedisClientJedisImpl.java +++ /dev/null @@ -1,211 +0,0 @@ -package com.dispose.redis.jedis; - -import com.dispose.redis.ProtobufSerializer; -import com.dispose.redis.RedisClient; -import java.io.Serializable; -import java.nio.charset.StandardCharsets; -import java.util.List; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; -import redis.clients.jedis.Jedis; -import redis.clients.jedis.ShardedJedis; -import redis.clients.jedis.ShardedJedisPool; -import redis.clients.jedis.params.SetParams; - -/** - * @author phoenix - * @date 2020年2月8日 - */ -@ConditionalOnBean(ShardedJedisPool.class) -@Component -@Slf4j -public class RedisClientJedisImpl implements RedisClient { - - @Resource - private ShardedJedisPool shardedJedisPool; - - @Override - public void put(String k, String v, int seconds) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.setex(k, seconds, v); - } catch (Exception e) { - log.error("KV存储异常", e); - } finally { - sj.close(); - } - } - - @Override - public boolean setLock(String key) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - // nx 不存在set,ex秒 - String res = sj.set(key, key, SetParams.setParams().nx().ex(60)); - return "OK".equals(res); - } catch (Exception e) { - log.error("锁异常", e); - sj.del(key); - } finally { - sj.close(); - } - return false; - } - - @Override - public String get(String key) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - return sj.get(key); - } catch (Exception e) { - log.error("获取数据异常", e); - } finally { - sj.close(); - } - return null; - } - - @Override - public void del(String key) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.del(key); - } catch (Exception e) { - log.error("key删除异常", e); - } finally { - sj.close(); - } - } - - @Override - public void put(String key, T v, int seconds) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.setex(key.getBytes(StandardCharsets.UTF_8), seconds, ProtobufSerializer.serialize(v)); - } catch (Exception e) { - log.error("数据序列化存入异常", e); - } finally { - sj.close(); - } - } - - @Override - public T get(String key, Class cls) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - byte[] ret = sj.get(key.getBytes(StandardCharsets.UTF_8)); - return ret == null ? null : ProtobufSerializer.deserialize(ret, cls); - } catch (Exception e) { - log.error("数据序列化取出异常", e); - } finally { - sj.close(); - } - return null; - } - - @Override - public void expire(String key, int seconds) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.expire(key, seconds); - } catch (Exception e) { - log.error("key设置有效期异常", e); - } finally { - sj.close(); - } - } - - @Override - public String rpop(String key) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - return sj.rpop(key); - } catch (Exception e) { - log.error("队列取数据异常", e); - } finally { - sj.close(); - } - return null; - } - - @Override - public void lpush(String key, String value) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.lpush(key, value); - } catch (Exception e) { - log.error("数据存入队列异常", e); - } finally { - sj.close(); - } - } - - @Override - public long llen(String key) { - // TODO Auto-generated method stub - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - return sj.llen(key); - } catch (Exception e) { - log.error("获取队列长度异常", e); - return 0; - } finally { - sj.close(); - } - } - - @Override - public String brpop(String key, int timeout) { - // TODO Auto-generated method stub - Jedis jedis = null; - try { - jedis = shardedJedisPool.getResource().getShard(key); - List ret = jedis.brpop(timeout, key); - return ret == null ? null : ret.get(1); - } catch (Exception e) { - log.error("数据取出队列异常", e); - } finally { - jedis.close(); - } - return null; - } - - @Override - public void delLock(String key) { - // TODO Auto-generated method stub - //网上很多方法解锁通过LUA脚本判断value去解锁 - //这里大家可以把加锁的key细化,不同业务用不同的key即可, - //不要整个系统用一个key,再通过value去细分不同业务的锁 - ShardedJedis sj = null; - try { - sj = shardedJedisPool.getResource(); - sj.del(key); - } catch (Exception e) { - log.error("解锁异常", e); - } finally { - sj.close(); - } - } - -} diff --git a/src/main/java/com/dispose/redis/redisson/RedisClientRedissonImpl.java b/src/main/java/com/dispose/redis/redisson/RedisClientRedissonImpl.java deleted file mode 100644 index c39713ea..00000000 --- a/src/main/java/com/dispose/redis/redisson/RedisClientRedissonImpl.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.dispose.redis.redisson; - -import com.dispose.redis.ProtobufSerializer; -import com.dispose.redis.RedisClient; -import java.io.Serializable; -import java.util.concurrent.TimeUnit; -import javax.annotation.Resource; -import lombok.extern.slf4j.Slf4j; -import org.redisson.api.RBlockingDeque; -import org.redisson.api.RBucket; -import org.redisson.api.RDeque; -import org.redisson.api.RKeys; -import org.redisson.api.RList; -import org.redisson.api.RLock; -import org.redisson.api.RMap; -import org.redisson.api.RedissonClient; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; -import org.springframework.stereotype.Component; - -/** - * @author phoenix - * @date 2020年3月10日 - */ -@ConditionalOnBean(RedissonClient.class) -@Slf4j -@Component -public class RedisClientRedissonImpl implements RedisClient { - - @Resource - private RedissonClient redissonClient; - - @Override - public void put(String k, String v, int seconds) { - // TODO Auto-generated method stub - RBucket cache = redissonClient.getBucket(k); - cache.set(v, seconds, TimeUnit.SECONDS); - } - - @Override - public void put(String key, T v, int seconds) { - // TODO Auto-generated method stub - RBucket cache = redissonClient.getBucket(key); - cache.set(ProtobufSerializer.serialize(v), seconds, TimeUnit.SECONDS); - } - - @Override - public boolean setLock(String key) { - // TODO Auto-generated method stub - // 抢占式上锁 - RLock lock = redissonClient.getLock(key); - // 公平锁,按照线程的优先顺序 - // redissonClient.getFairLock(key); - // waitTime 超时时间 - // leaseTime 有效期,过期自动失效 - try { - return lock.tryLock(5, 600, TimeUnit.SECONDS); - } catch (Exception e) { - log.error("Redisson 加锁异常", e); - return false; - } - } - - public void delLock(String key) { - // TODO Auto-generated method stub - RLock lock = redissonClient.getLock(key); - // lock.forceUnlock(); - lock.unlock(); - // lock.forceUnlockAsync(); - } - - @Override - public String get(String key) { - // TODO Auto-generated method stub - RBucket cache = redissonClient.getBucket(key); - return cache.get(); - } - - @Override - public T get(String key, Class cls) { - // TODO Auto-generated method stub - RBucket cache = redissonClient.getBucket(key); - return cache.get() == null ? null : ProtobufSerializer.deserialize(cache.get(), cls); - } - - @Override - public void del(String key) { - // TODO Auto-generated method stub - RKeys k = redissonClient.getKeys(); - k.delete(key); - } - - @Override - public long llen(String key) { - // TODO Auto-generated method stub - RList list = redissonClient.getList(key); - return list.size(); - } - - @Override - public void expire(String key, int seconds) { - // TODO Auto-generated method stub - RMap map = redissonClient.getMap(key); - map.expire(seconds, TimeUnit.SECONDS); - } - - @Override - public void lpush(String key, String value) { - // TODO Auto-generated method stub - RDeque list = redissonClient.getDeque(key); - list.addFirst(value);// lpush - } - - @Override - public String rpop(String key) { - // TODO Auto-generated method stub - RDeque list = redissonClient.getDeque(key); - return list.pollLast(); - } - - @Override - public String brpop(String key, int timeout) { - // TODO Auto-generated method stub - RBlockingDeque list = redissonClient.getBlockingDeque(key); - try { - return list.pollLast(timeout, TimeUnit.SECONDS); - } catch (InterruptedException e) { - log.error("BRPOP异常", e); - return null; - } - } - -} diff --git a/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java b/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java index 6011ae0c..fb6a6354 100644 --- a/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeNodeManagerImpl.java @@ -1,7 +1,7 @@ package com.dispose.service.impl; -import com.dispose.common.ConstValue; import com.dispose.common.ErrorCode; +import com.dispose.common.IPAddrType; import com.dispose.dispose.DeviceRouter; import com.dispose.dispose.DisposeEntryManager; import com.dispose.mapper.DisposeDeviceMapper; @@ -41,7 +41,7 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager { devList.forEach(v -> { DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(v.getType(), v.getIpAddr(), - ConstValue.IPAddrType.getIpAddrType(v.getIpAddr())); + IPAddrType.getIpAddrType(v.getIpAddr())); v.setLinkStatus(dp.getDeviceLinkStatus() ? 1 : 0); v.setVersion(dp.getVersion()); @@ -109,7 +109,7 @@ public class DisposeNodeManagerImpl implements DisposeNodeManager { try { dp = DeviceRouter.deviceRouterFactory(dev.getType(), - dev.getIpAddr(), ConstValue.IPAddrType.getIpAddrType(dev.getIpAddr())); + dev.getIpAddr(), IPAddrType.getIpAddrType(dev.getIpAddr())); } catch (Exception ex) { return new MReturnType<>(ErrorCode.ERR_NOSUCHDEVICE, String.valueOf(-1)); } diff --git a/src/main/java/com/dispose/session/MyCookie.java b/src/main/java/com/dispose/session/MyCookie.java deleted file mode 100644 index 7b4c3efd..00000000 --- a/src/main/java/com/dispose/session/MyCookie.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.dispose.session; - -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -/** - * @author phoenix - * @date 2020年2月24日 - */ -public class MyCookie { - - private final HttpServletRequest request; - private final HttpServletResponse response; - - public MyCookie(HttpServletRequest req, HttpServletResponse res) { - request = req; - response = res; - } - - public String getRemoteIp() { - String ip = request.getHeader("X-Forwarded-For"); - if (isEffective(ip) && ip.indexOf(",") > -1) { - String[] array = ip.split(","); - for (String str : array) { - if (isEffective(str)) { - ip = str; - break; - } - } - } - if (!isEffective(ip)) { - ip = request.getHeader("Proxy-Client-IP"); - } - if (!isEffective(ip)) { - ip = request.getHeader("WL-Proxy-Client-IP"); - } - if (!isEffective(ip)) { - ip = request.getHeader("HTTP_CLIENT_IP"); - } - if (!isEffective(ip)) { - ip = request.getHeader("HTTP_X_FORWARDED_FOR"); - } - if (!isEffective(ip)) { - ip = request.getRemoteAddr(); - } - return ip; - } - - private boolean isEffective(String remoteAddr) { - return (null != remoteAddr) && (!"".equals(remoteAddr.trim())) - && (!"unknown".equalsIgnoreCase(remoteAddr.trim())); - } - - /** - * 设置cookie - * - * @param name - * @param value - * @param domain - * @param expire - */ - public void setCookie(String name, String value, String domain, int expire) { - Cookie cookie = new Cookie(name, value); - cookie.setDomain(domain); - cookie.setPath("/"); - if (expire >= 0) { - cookie.setMaxAge(expire); - } - cookie.setHttpOnly(true); - response.addCookie(cookie); - } - - /** - * 获取某个cookie值 - * - * @param name - * @return - */ - public String getCookieValue(String name) { - Cookie[] cookies = request.getCookies(); - if (cookies == null) { - return null; - } - Cookie cookie = null; - for (int i = 0; i < cookies.length; i++) { - cookie = cookies[i]; - if (cookie.getName().equalsIgnoreCase(name)) { - return cookie.getValue(); - } - } - return null; - } - - /** - * setCookie:().
- * - * @param name - * @param value - * @param domain - * @author chiwei - * @since JDK 1.6 - */ - public void setCookie(String name, String value, String domain) { - // maxage=-1表示关闭浏览器则cookie失效 - setCookie(name, value, domain, -1); - } - - /** - * @param name - * @param domain - */ - public void clearCookie(String name, String domain) { - setCookie(name, "", domain, 0); - } - - /** - * clearSession:().
- * - * @param name - * @return - * @author chiwei - * @since JDK 1.6 - */ - public void clearSession(String name) { - request.getSession().removeAttribute(name); - } -} diff --git a/src/main/java/com/dispose/task/DeviceManagerTask.java b/src/main/java/com/dispose/task/DeviceManagerTask.java index 50f1bf4f..adff177a 100644 --- a/src/main/java/com/dispose/task/DeviceManagerTask.java +++ b/src/main/java/com/dispose/task/DeviceManagerTask.java @@ -1,6 +1,6 @@ package com.dispose.task; -import com.dispose.common.ConstValue; +import com.dispose.common.IPAddrType; import com.dispose.dispose.DeviceRouter; import com.dispose.dispose.DisposeEntryManager; import com.dispose.pojo.entity.DisposeDevice; @@ -32,14 +32,12 @@ public class DeviceManagerTask { devList.forEach(v -> { DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(v.getType(), v.getIpAddr(), - ConstValue.IPAddrType.getIpAddrType(v.getIpAddr())); + IPAddrType.getIpAddrType(v.getIpAddr())); - if (dp != null) { - v.setLinkStatus(dp.getDeviceLinkStatus() ? 1 : 0); - v.setVersion(dp.getVersion()); - v.setDevInfo(dp.getDeviceInfo()); - log.info("Upgrade {} Device Status", v.getIpAddr()); - } + v.setLinkStatus(dp.getDeviceLinkStatus() ? 1 : 0); + v.setVersion(dp.getVersion()); + v.setDevInfo(dp.getDeviceInfo()); + log.info("Upgrade {} Device Status", v.getIpAddr()); }); } } diff --git a/src/main/resources/mappers/DisposeTask.xml b/src/main/resources/mappers/DisposeTask.xml index a5f6671e..dc2e3653 100644 --- a/src/main/resources/mappers/DisposeTask.xml +++ b/src/main/resources/mappers/DisposeTask.xml @@ -46,19 +46,43 @@ - SELECT * FROM dispose_task WHERE - deviceId = #{userId, jdbcType=INTEGER} + accountId = #{userId, jdbcType=INTEGER} AND + currentStatus != ${@com.dispose.common.DisposeTaskStatus@TASK_DELETE.getCode()} + + + + + + + \ No newline at end of file diff --git a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java index 5f23d094..f5e2c852 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeInfoControllerTest.java @@ -248,7 +248,7 @@ public class DeviceNodeInfoControllerTest extends InitTestEnvironment { reqInfo.setTimeStamp(System.currentTimeMillis()); reqInfo.setMsgContent(objectMapper.writeValueAsString(reqData)); - mockMvc.perform(MockMvcRequestBuilders + String var = mockMvc.perform(MockMvcRequestBuilders .post("/information/protected_ip") .contentType(MediaType.APPLICATION_JSON) .header("Authorization", "Bearer " + getLogToken()) diff --git a/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java b/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java index fb81c9a0..674b86b1 100644 --- a/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java +++ b/src/test/java/com/dispose/controller/DeviceNodeManagerControllerTest.java @@ -2,6 +2,7 @@ package com.dispose.controller; import com.dispose.Global.InitTestEnvironment; import com.dispose.common.ConstValue; +import com.dispose.common.DisposeDeviceType; import com.dispose.pojo.dto.ProtocolReqDTO; import com.dispose.pojo.po.NewNodeInfo; import com.dispose.pojo.vo.common.IDArrayReq; @@ -51,7 +52,7 @@ public class DeviceNodeManagerControllerTest extends InitTestEnvironment { addReq.getItems().add(NewNodeInfo.builder() .ipAddr("10.88.77.15") - .type(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode()) + .type(DisposeDeviceType.DPTECH_UMC.getCode()) .areaCode(0) .name("中移杭研实验室清洗设备") .manufacturer("DPTech") diff --git a/src/test/java/com/dispose/controller/TaskControllerTest.java b/src/test/java/com/dispose/controller/TaskControllerTest.java index 64c76b6b..4b8a7370 100644 --- a/src/test/java/com/dispose/controller/TaskControllerTest.java +++ b/src/test/java/com/dispose/controller/TaskControllerTest.java @@ -2,6 +2,7 @@ package com.dispose.controller; import com.dispose.Global.InitTestEnvironment; import com.dispose.common.ConstValue; +import com.dispose.common.DeviceCapacity; import com.dispose.pojo.dto.ProtocolReqDTO; import com.dispose.pojo.vo.common.IDArrayReq; import com.dispose.pojo.vo.task.StartTaskReq; @@ -50,7 +51,7 @@ public class TaskControllerTest extends InitTestEnvironment { public void t1_startTask() throws Exception { StartTaskReq reqData = StartTaskReq.builder() .id(210) - .type(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .type(DeviceCapacity.CLEANUP.getCode()) .disposeIp("192.168.0.1") .build(); @@ -110,7 +111,7 @@ public class TaskControllerTest extends InitTestEnvironment { public void t3_stopNodeIpTask() throws Exception { StopTaskData itemData = StopTaskData.builder() .disposeIp("192.168.1.1") - .type(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .type(DeviceCapacity.CLEANUP.getCode()) .id("210") .build(); @@ -145,7 +146,7 @@ public class TaskControllerTest extends InitTestEnvironment { @Test public void t4_stopNodeTask() throws Exception { StopTaskData itemData = StopTaskData.builder() - .type(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .type(DeviceCapacity.CLEANUP.getCode()) .id("210") .build(); @@ -180,7 +181,7 @@ public class TaskControllerTest extends InitTestEnvironment { @Test public void t5_stopAllTask() throws Exception { StopTaskData itemData = StopTaskData.builder() - .type(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .type(DeviceCapacity.CLEANUP.getCode()) .build(); StopTaskReq reqData = new StopTaskReq(); diff --git a/src/test/java/com/dispose/dptech/DPTechInterfaceTestCase.java b/src/test/java/com/dispose/dptech/DPTechInterfaceTestCase.java index c277658f..8d70a55f 100644 --- a/src/test/java/com/dispose/dptech/DPTechInterfaceTestCase.java +++ b/src/test/java/com/dispose/dptech/DPTechInterfaceTestCase.java @@ -1,7 +1,7 @@ package com.dispose.dptech; import com.dispose.Global.InitTestEnvironment; -import com.dispose.common.ConstValue; +import com.dispose.common.DisposeDeviceType; import com.dispose.dispose.DeviceRouter; import com.dispose.dispose.DisposeEntryManager; import com.dispose.pojo.po.DisposeDeviceCapacity; @@ -40,7 +40,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment { try { DisposeEntryManager dp = - DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); + DeviceRouter.deviceRouterFactory(DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); List detDevs = dp.getAllDetectionObject(); @@ -59,7 +59,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment { try { DisposeEntryManager dp = - DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); + DeviceRouter.deviceRouterFactory(DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); String proDevs = dp.getProtectDevices(); @@ -78,7 +78,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment { try { DisposeEntryManager dp = - DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); + DeviceRouter.deviceRouterFactory(DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); List proObjs = dp.getAllProtectionObject(); @@ -95,7 +95,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment { @Test public void t4_getLinkStatus() { - DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), + DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); Assert.assertTrue(dp.getDeviceLinkStatus()); @@ -109,7 +109,7 @@ public class DPTechInterfaceTestCase extends InitTestEnvironment { @Test public void t5_getDeviceCapacity() throws JsonProcessingException { - DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode(), + DisposeEntryManager dp = DeviceRouter.deviceRouterFactory(DisposeDeviceType.DPTECH_UMC.getCode(), "10.88.77.15"); List capList = dp.getDeviceCapacity(); diff --git a/src/test/java/com/dispose/mapper/DisposeDeviceMapperTest.java b/src/test/java/com/dispose/mapper/DisposeDeviceMapperTest.java index f09a9a59..83dc06ad 100644 --- a/src/test/java/com/dispose/mapper/DisposeDeviceMapperTest.java +++ b/src/test/java/com/dispose/mapper/DisposeDeviceMapperTest.java @@ -1,7 +1,7 @@ package com.dispose.mapper; import com.dispose.Global.InitTestEnvironment; -import com.dispose.common.ConstValue; +import com.dispose.common.DisposeDeviceType; import com.dispose.pojo.entity.DisposeDevice; import com.dispose.pojo.po.DisposeDeviceCapacity; import com.dispose.service.DisposeNodeManager; @@ -48,7 +48,7 @@ public class DisposeDeviceMapperTest extends InitTestEnvironment { List devCaps = new ArrayList<>(); dev.setId(devId); dev.setIpAddr("10.88.77.15"); - dev.setType(ConstValue.DisposeDeviceType.DPTECH_UMC.getCode()); + dev.setType(DisposeDeviceType.DPTECH_UMC.getCode()); dev.setName("中移杭研实验室清洗设备"); dev.setManufacturer("DPTech"); dev.setModel("UMC"); diff --git a/src/test/java/com/dispose/mapper/DisposeTaskMapperTest.java b/src/test/java/com/dispose/mapper/DisposeTaskMapperTest.java index 9cc4017d..0c0e6695 100644 --- a/src/test/java/com/dispose/mapper/DisposeTaskMapperTest.java +++ b/src/test/java/com/dispose/mapper/DisposeTaskMapperTest.java @@ -1,12 +1,16 @@ package com.dispose.mapper; import com.dispose.Global.InitTestEnvironment; -import com.dispose.common.ConstValue; +import com.dispose.common.DeviceCapacity; +import com.dispose.common.DisposeTaskStatus; +import com.dispose.common.FlowDirection; import com.dispose.pojo.vo.common.TaskInfoDetail; +import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import javax.annotation.Resource; +import lombok.extern.slf4j.Slf4j; import org.junit.Assert; import org.junit.FixMethodOrder; import org.junit.Test; @@ -21,6 +25,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest @FixMethodOrder(MethodSorters.NAME_ASCENDING) +@Slf4j public class DisposeTaskMapperTest extends InitTestEnvironment { /** * The Obj mapper. @@ -76,10 +81,11 @@ public class DisposeTaskMapperTest extends InitTestEnvironment { .id(-1L) .deviceId(deviceId) .accountId(accountId) - .type(ConstValue.DeviceCapacity.CLEANUP.getCode()) + .type(DeviceCapacity.CLEANUP.getCode()) .disposeIp("192.168.0.1") - .flowDirection(ConstValue.FlowDirection.DIRECTION_TWOWAY.getCode()) - .currentStatus(ConstValue.DisposeTaskStatus.TASK_NEW.getCode()) + .attackType("0") + .flowDirection(FlowDirection.DIRECTION_TWOWAY.getCode()) + .currentStatus(DisposeTaskStatus.TASK_NEW.getCode()) .planEndTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) .endTime(endTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))) .build(); @@ -96,7 +102,7 @@ public class DisposeTaskMapperTest extends InitTestEnvironment { @Test public void t2_changeTaskStatusTest() { disposeTaskMapper.selectAll().forEach(v -> { - for (ConstValue.DisposeTaskStatus k : ConstValue.DisposeTaskStatus.values()) { + for (DisposeTaskStatus k : DisposeTaskStatus.values()) { disposeTaskMapper.changeTaskCurrentStatus(v.getId(), k.getCode()); Assert.assertEquals(disposeTaskMapper.getTaskCurrentStatus(v.getId()), k.getCode()); } @@ -112,6 +118,12 @@ public class DisposeTaskMapperTest extends InitTestEnvironment { TaskInfoDetail taskInfo = disposeTaskMapper.getTaskInfoById(v.getId()); Assert.assertNotNull(taskInfo); Assert.assertEquals(taskInfo.getId(), v.getId()); + try { + log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskInfo)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail(); + } }); } @@ -122,27 +134,68 @@ public class DisposeTaskMapperTest extends InitTestEnvironment { public void t4_getAllTaskByDisposeIpTest() { disposeTaskMapper.selectAll().forEach(v -> disposeTaskMapper .getAllTaskByDisposeIp(v.getDisposeIp()) - .forEach(k -> Assert.assertEquals(k.getDisposeIp(), v.getDisposeIp()))); + .forEach(k -> { + Assert.assertEquals(k.getDisposeIp(), v.getDisposeIp()); + try { + log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(k)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail(); + } + })); } /** * T 5 get all task by node dev id. */ @Test - public void t5_getAllTaskByNodeDevId() { + public void t5_getAllTaskByNodeDevIdTest() { disposeTaskMapper.selectAll().forEach(v -> disposeTaskMapper .getAllTaskByNodeDevId(v.getDeviceId()) - .forEach(k -> Assert.assertEquals(k.getDeviceId(), v.getDeviceId()))); + .forEach(k -> { + Assert.assertEquals(k.getDeviceId(), v.getDeviceId()); + try { + log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(k)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail(); + } + })); } /** * T 6 get all task by node user id. */ @Test - public void t6_getAllTaskByNodeUserId() { + public void t6_getNodeAllTaskByUserIdTest() { disposeTaskMapper.selectAll().forEach(v -> disposeTaskMapper - .getAllTaskByNodeUserId(v.getAccountId()) - .forEach(k -> Assert.assertEquals(k.getAccountId(), v.getAccountId()))); + .getNodeAllTaskByUserId(v.getAccountId()) + .forEach(k -> { + Assert.assertEquals(k.getAccountId(), v.getAccountId()); + try { + log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(k)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail(); + } + })); + } + + @Test + public void t7_getNodeTaskByIpAndStatusTest() { + disposeTaskMapper.selectAll().forEach(v -> disposeTaskMapper + .getNodeTaskByIpAndStatus(v.getAccountId(), v.getDisposeIp(), v.getCurrentStatus()) + .forEach(k -> { + Assert.assertEquals(k.getAccountId(), v.getAccountId()); + Assert.assertEquals(k.getDisposeIp(), v.getDisposeIp()); + Assert.assertEquals(k.getCurrentStatus(), v.getCurrentStatus()); + try { + log.info(objMapper.writerWithDefaultPrettyPrinter().writeValueAsString(k)); + } catch (JsonProcessingException e) { + e.printStackTrace(); + Assert.fail(); + } + })); } /**