diff --git a/src/main/java/com/dispose/common/Constants.java b/src/main/java/com/dispose/common/Constants.java index 39f1a00b..c605c23c 100644 --- a/src/main/java/com/dispose/common/Constants.java +++ b/src/main/java/com/dispose/common/Constants.java @@ -13,7 +13,7 @@ public class Constants { /** * DDoS具体攻击类型 */ - public static Map ATTACK_TYPE; + public static final Map ATTACK_TYPE; static { Map attTypeMap = new HashMap<>(); @@ -79,7 +79,6 @@ public class Constants { public static final int HIDEPEND = 3; /** - * /** * 派单eoms模板 */ public static final String DISPATCH_TEMPLATE = "\nMsgSerial:{0}\nSDN:{1}\nNeName:{2}\nEquipmentClass:99236\n" + @@ -96,16 +95,18 @@ public class Constants { "ServiceName: \nServiceCrossDomainType: \nInterruptCircuitState: \nCircuitLocateInfo: \nHomeClientNum: \nHomeCellNum: \n" + "LinkOnuNum: \n"; - /* * - 0:网元自动清除 --收到从采集源发送的清除告警 + /** + * 0:网元自动清除 --收到从采集源发送的清除告警 */ public static final int NE_AUTO_CLEARED_STATUS = 0; - /* * - 1:活动告警---告警当前为活动状态 + + /** + * 1:活动告警---告警当前为活动状态 */ public static final int ACTIVE_ALARM_STATUS = 1; - /* * - 2:同步清除---已采集活动告警,但采集平台从告警源同步时,发现已经没有对应的活动告警,由采集平台产生的清除告警 + + /** + * 2:同步清除---已采集活动告警,但采集平台从告警源同步时,发现已经没有对应的活动告警,由采集平台产生的清除告警 */ public static final int SYNCHRONIZATION_CLEAR_STATUS = 2; } diff --git a/src/main/java/com/dispose/config/KafkaConfiguration.java b/src/main/java/com/dispose/config/KafkaConfiguration.java index 837f70d2..5e947e64 100644 --- a/src/main/java/com/dispose/config/KafkaConfiguration.java +++ b/src/main/java/com/dispose/config/KafkaConfiguration.java @@ -18,6 +18,8 @@ import java.util.Map; /** * The type Kafka configuration. + * + * @author */ @EnableKafka @ConfigurationProperties(prefix = "kafka") @@ -86,7 +88,7 @@ public class KafkaConfiguration { } /** - * Producer factory. + * Producer factory producer factory. * * @return the producer factory */ @@ -95,7 +97,7 @@ public class KafkaConfiguration { } /** - * Kafka template. + * Kafka template kafka template. * * @return the kafka template */ diff --git a/src/main/java/com/dispose/controller/kafkaController.java b/src/main/java/com/dispose/controller/KafkaController.java similarity index 86% rename from src/main/java/com/dispose/controller/kafkaController.java rename to src/main/java/com/dispose/controller/KafkaController.java index 39454035..857cd6db 100644 --- a/src/main/java/com/dispose/controller/kafkaController.java +++ b/src/main/java/com/dispose/controller/KafkaController.java @@ -8,8 +8,8 @@ import com.dispose.manager.AlarmInfoManager; import com.dispose.pojo.dto.protocol.base.BaseRespStatus; import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO; import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO; -import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo; import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq; +import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo; import com.dispose.pojo.entity.AlarmInformation; import com.dispose.pojo.po.MulReturnType; import com.dispose.security.annotation.Decryption; @@ -47,7 +47,7 @@ import java.util.Objects; @Validated @Encryption @Decryption -public class kafkaController { +public class KafkaController { /** * The Kafka configuration. */ @@ -102,10 +102,10 @@ public class kafkaController { .sendDefault(0, System.currentTimeMillis(), "dispose", content); sendResult.addCallback(v -> log.info("Kafka send {} to {} at {}", content, - Objects.requireNonNull(v) - .getRecordMetadata() - .topic(), v.getRecordMetadata().partition()), - ex -> log.error("Kafka send error: {}", ex.getMessage())); + Objects.requireNonNull(v) + .getRecordMetadata() + .topic(), v.getRecordMetadata().partition()), + ex -> log.error("Kafka send error: {}", ex.getMessage())); rspInfo.setStatus(ErrorCode.ERR_OK.getCode()); rspInfo.setMessage(new String[]{ErrorCode.ERR_OK.getMsg()}); @@ -141,8 +141,9 @@ public class kafkaController { String vendorAlarmId; if (type != null) { String[] arr = type.split("\\|"); + String bps = "bps"; vendorAlarmType = arr[0]; - if (alarmInfo.getBpspps().compareTo("bps") == 0) { + if (bps.equals(alarmInfo.getBpspps())) { vendorAlarmId = arr[1]; } else { vendorAlarmId = arr[2]; @@ -156,15 +157,14 @@ public class kafkaController { String alarmText = characterEncode(getAlarmText(alarmInfo)); String alarmExplanation = characterEncode(getAlarmExplanation(alarmInfo)); - String content = MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp, - dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime, - vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"), - characterEncode("DDos攻击事件"), alarmStatus, alarmText, - characterEncode(alarmInfo.getDstProvince()), characterEncode(alarmInfo.getDstCity()), - characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"), - characterEncode("安全告警"), characterEncode("DDOS告警"), - alarmExplanation, characterEncode("集中抗D")); - return content; + return MessageFormat.format(Constants.DISPATCH_TEMPLATE, increment, dstIp, + dstIp, alarmId, alarmId, dstIp, dstIp, locateInfo, eventTime, cancelTime, + vendorAlarmType, vendorSeverity, vendorAlarmId, characterEncode("重保攻击事件告警"), + characterEncode("DDos攻击事件"), alarmStatus, alarmText, + characterEncode(alarmInfo.getDstProvince()), characterEncode(alarmInfo.getDstCity()), + characterEncode("网络部集中抗D系统"), characterEncode("DDOS攻击事件告警"), + characterEncode("安全告警"), characterEncode("DDOS告警"), + alarmExplanation, characterEncode("集中抗D")); } catch (Exception e) { log.error("createSendContent告警消息异常,详细信息:{}", ExceptionUtils.getStackTrace(e)); return null; diff --git a/src/main/java/com/dispose/exception/GlobalExceptionHandler.java b/src/main/java/com/dispose/exception/GlobalExceptionHandler.java index d554a4c4..293535e7 100644 --- a/src/main/java/com/dispose/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/dispose/exception/GlobalExceptionHandler.java @@ -69,8 +69,7 @@ public class GlobalExceptionHandler { log.error("Interface [{}] request <{}> from {}, token = <{}>\n" + "+++ Request: {}\n" + "--- Verify params failed: {}", - reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), - sb.toString()); + reqType, reqPath, reqIp, reqToken, Helper.inputStream2String(req.getInputStream()), sb); } catch (Exception ignored) { } diff --git a/src/main/java/com/dispose/manager/MsgSerialManager.java b/src/main/java/com/dispose/manager/MsgSerialManager.java index 308c9bca..0ce301eb 100644 --- a/src/main/java/com/dispose/manager/MsgSerialManager.java +++ b/src/main/java/com/dispose/manager/MsgSerialManager.java @@ -2,19 +2,24 @@ package com.dispose.manager; import com.dispose.common.ErrorCode; +/** + * The interface Msg serial manager. + * + * @author + */ public interface MsgSerialManager { /** - * Add user business error code. + * Update msg serial number error code. * - * @param msgSerial the message serial + * @param msgSerial the msg serial * @return the error code */ ErrorCode updateMsgSerialNumber(Long msgSerial); /** - * get new max message serial. + * Gets max msg serial. * - * @return the long + * @return the max msg serial */ Long getMaxMsgSerial(); } diff --git a/src/main/java/com/dispose/pojo/dto/protocol/kafka/EmosAlarmInfo.java b/src/main/java/com/dispose/pojo/dto/protocol/kafka/EmosAlarmInfo.java index bc2f88c9..eda909f7 100644 --- a/src/main/java/com/dispose/pojo/dto/protocol/kafka/EmosAlarmInfo.java +++ b/src/main/java/com/dispose/pojo/dto/protocol/kafka/EmosAlarmInfo.java @@ -9,6 +9,11 @@ import lombok.EqualsAndHashCode; import java.util.List; +/** + * The type Emos alarm info. + * + * @author + */ @EqualsAndHashCode() @Data @Builder @@ -18,67 +23,67 @@ import java.util.List; @JsonInclude(JsonInclude.Include.NON_NULL) public class EmosAlarmInfo { /** - * 告警id. + * The Alarm id. */ private String alarmId; /** - * 被攻击ip. + * The Dst ip. */ private String dstIp; /** - * 攻击类型(类似HTTP Flood字符串形式). + * The Attack type. */ private String attackType; /** - * 被攻击ip. + * The Bpspps. */ private String bpspps; /** - * 目的ip省份. + * The Dst province. */ private String dstProvince; /** - * 目的ip市. + * The Dst city. */ private String dstCity; /** - * 告警源ip列表,没有就给empty的list. + * The Src ip ls. */ private List srcIpLs; /** - * 告警开始时间. + * The Start time. */ private String startTime; /** - * 告警结束时间. + * The End time. */ private String endTime; /** - * 处置类型(1:清洗,2:黑洞,3:高防),默认清洗. + * The Dispose type. */ private Integer disposeType; /** - * 处置时长. + * The Dispose time. */ private Integer disposeTime; /** - * 流量峰值(单位:bps). + * The Max bps. */ private String maxBps; /** - * 包数峰值(单位:pps). + * The Max pps. */ private String maxPps; } diff --git a/src/main/java/com/dispose/service/MsgSerialService.java b/src/main/java/com/dispose/service/MsgSerialService.java index 26a3599f..25c7699a 100644 --- a/src/main/java/com/dispose/service/MsgSerialService.java +++ b/src/main/java/com/dispose/service/MsgSerialService.java @@ -3,19 +3,24 @@ package com.dispose.service; import com.dispose.common.ErrorCode; import com.dispose.pojo.po.MulReturnType; +/** + * The interface Msg serial service. + * + * @author + */ public interface MsgSerialService { /** - * update message serial. + * Update message serial mul return type. * - * @param msgSerial the message serial + * @param msgSerial the msg serial * @return the mul return type */ MulReturnType updateMessageSerial(Long msgSerial); /** - * get new max message serial. + * Gets max message serial. * - * @return the long + * @return the max message serial */ Long getMaxMessageSerial(); diff --git a/src/main/java/com/dispose/service/impl/MsgSerialServiceImpl.java b/src/main/java/com/dispose/service/impl/MsgSerialServiceImpl.java index 8d1eb472..263346f6 100644 --- a/src/main/java/com/dispose/service/impl/MsgSerialServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/MsgSerialServiceImpl.java @@ -8,15 +8,23 @@ import org.springframework.stereotype.Service; import javax.annotation.Resource; +/** + * The type Msg serial service. + * + * @author + */ @Service public class MsgSerialServiceImpl implements MsgSerialService { + /** + * The Msg serial manager. + */ @Resource private MsgSerialManager msgSerialManager; /** - * add message serial. + * Update message serial mul return type. * - * @param msgSerial the message serial + * @param msgSerial the msg serial * @return the mul return type */ @Override @@ -37,9 +45,9 @@ public class MsgSerialServiceImpl implements MsgSerialService { } /** - * get new max message serial. + * Gets max message serial. * - * @return the long + * @return the max message serial */ @Override public Long getMaxMessageSerial() { diff --git a/src/main/java/com/dispose/validation/valids/impl/ValidAddCapacityInfoImpl.java b/src/main/java/com/dispose/validation/valids/impl/ValidAddCapacityInfoImpl.java index 9a69db5c..f6799acc 100644 --- a/src/main/java/com/dispose/validation/valids/impl/ValidAddCapacityInfoImpl.java +++ b/src/main/java/com/dispose/validation/valids/impl/ValidAddCapacityInfoImpl.java @@ -81,7 +81,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator v.getValue().equals(addCapacityInfo.getIpType()))) { List val = Arrays.stream(IpAddrType.values()).map(IpAddrType::getValue).collect(Collectors.toList()); - errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val.toString()); + errMsg.add("字段 ipType 值 {}, 错误, 合理取值范围为:" + val); ret = false; } @@ -106,7 +106,7 @@ public class ValidAddCapacityInfoImpl implements ConstraintValidator