优化服务器列表查询速度、筛选条件bug修复。
ipv4、ipv6初始流量处理。 增加日志排查收益未自动生成问题。
This commit is contained in:
+2
@@ -64,7 +64,9 @@ public class RmMtrPolicyConfig extends BaseEntity
|
|||||||
/** 查询条件 */
|
/** 查询条件 */
|
||||||
private String queryName;
|
private String queryName;
|
||||||
@Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -353,7 +353,7 @@ public class MessageHandler {
|
|||||||
boolean needUpdate = false;
|
boolean needUpdate = false;
|
||||||
RmMtrClientRegistration updateData = new RmMtrClientRegistration();
|
RmMtrClientRegistration updateData = new RmMtrClientRegistration();
|
||||||
updateData.setId(rmMtrClientRegistration.getId());
|
updateData.setId(rmMtrClientRegistration.getId());
|
||||||
if(rmMtrClientRegistration.getLogicalNode() == null ||
|
if((rmMtrClientRegistration.getLogicalNode() == null && heartbeat.getLogicalNode()!=null) ||
|
||||||
!StringUtils.equals(rmMtrClientRegistration.getLogicalNode(), heartbeat.getLogicalNode())){
|
!StringUtils.equals(rmMtrClientRegistration.getLogicalNode(), heartbeat.getLogicalNode())){
|
||||||
updateData.setLogicalNode(heartbeat.getLogicalNode());
|
updateData.setLogicalNode(heartbeat.getLogicalNode());
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
@@ -371,7 +371,7 @@ public class MessageHandler {
|
|||||||
}
|
}
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
if(rmMtrClientRegistration.getCpucores() == null ||
|
if((rmMtrClientRegistration.getCpucores() == null && heartbeat.getCpucores() != null) ||
|
||||||
rmMtrClientRegistration.getCpucores() != heartbeat.getCpucores()){
|
rmMtrClientRegistration.getCpucores() != heartbeat.getCpucores()){
|
||||||
updateData.setCpucores(heartbeat.getCpucores());
|
updateData.setCpucores(heartbeat.getCpucores());
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
|
|||||||
+2
-2
@@ -37,8 +37,8 @@ public class CalculateController extends BaseController {
|
|||||||
queryParam.setDayOrMonth(dayOrMonth);
|
queryParam.setDayOrMonth(dayOrMonth);
|
||||||
InitialSwitchInfoDetails initialSwitchInfoDetails = new InitialSwitchInfoDetails();
|
InitialSwitchInfoDetails initialSwitchInfoDetails = new InitialSwitchInfoDetails();
|
||||||
initialSwitchInfoDetails.setDayOrMonth(dayOrMonth);
|
initialSwitchInfoDetails.setDayOrMonth(dayOrMonth);
|
||||||
// epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1000");
|
epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1000");
|
||||||
// epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1024");
|
epsInitialTrafficDataService.calculateBusiness95BandwidthDaily(queryParam, dailyStartTime, dailyEndTime, "1024");
|
||||||
// initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1000");
|
// initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1000");
|
||||||
// initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024");
|
// initialSwitchInfoDetailsService.calculateSwitch95BandwidthDaily(initialSwitchInfoDetails, dailyStartTime, dailyEndTime, "1024");
|
||||||
}
|
}
|
||||||
|
|||||||
+5
@@ -282,7 +282,12 @@ public class EpsInitialTrafficDataServiceImpl implements EpsInitialTrafficDataSe
|
|||||||
// 遍历处理每个设备
|
// 遍历处理每个设备
|
||||||
snList.forEach(interfaceName -> {
|
snList.forEach(interfaceName -> {
|
||||||
queryParam.setClientId(interfaceName.getClientId());
|
queryParam.setClientId(interfaceName.getClientId());
|
||||||
|
try {
|
||||||
calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
calculateChangedDeviceBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||||
|
log.info("计算{}的95带宽值完成", interfaceName.getClientId());
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("计算{}的95带宽值失败,详情:{}", interfaceName.getClientId(), e.getMessage());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
+53
-80
@@ -13,8 +13,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 服务器收益方式配置Service业务层处理
|
* 服务器收益方式配置Service业务层处理
|
||||||
@@ -238,97 +241,67 @@ public class EpsServerRevenueConfigServiceImpl implements IEpsServerRevenueConfi
|
|||||||
/**
|
/**
|
||||||
* 批量处理接口名称
|
* 批量处理接口名称
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ)
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
||||||
public void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
|
public void processInterfaceNames(List<EpsInitialTrafficData> trafficDataList) {
|
||||||
// 分类处理:新增列表 vs 更新列表
|
if (CollectionUtils.isEmpty(trafficDataList)) {
|
||||||
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
|
||||||
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
|
|
||||||
|
|
||||||
// 用于去重的临时集合,防止同一批数据中的重复
|
|
||||||
Set<String> processedKeys = new HashSet<>();
|
|
||||||
|
|
||||||
trafficDataList.forEach(data -> {
|
|
||||||
String name = data.getName();
|
|
||||||
String ip = data.getMac();
|
|
||||||
String clientId = data.getClientId();
|
|
||||||
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 生成唯一键,防止同一批数据中的重复处理
|
// 直接转换并过滤
|
||||||
String uniqueKey = name + "|" + clientId + "|" + ip;
|
List<AllInterfaceName> records = new ArrayList<>();
|
||||||
if (processedKeys.contains(uniqueKey)) {
|
for (EpsInitialTrafficData data : trafficDataList) {
|
||||||
return;
|
if (isValidData(data)) {
|
||||||
}
|
records.add(convertToInterfaceName(data));
|
||||||
processedKeys.add(uniqueKey);
|
|
||||||
|
|
||||||
// 构造新记录
|
|
||||||
AllInterfaceName newRecord = new AllInterfaceName();
|
|
||||||
newRecord.setInterfaceName(name);
|
|
||||||
newRecord.setClientId(data.getClientId());
|
|
||||||
newRecord.setResourceType("1");
|
|
||||||
newRecord.setDeviceSn(data.getServiceSn());
|
|
||||||
newRecord.setNodeName(data.getNodeName());
|
|
||||||
newRecord.setBusinessCode(data.getBusinessId());
|
|
||||||
newRecord.setBusinessName(data.getBusinessName());
|
|
||||||
newRecord.setServerIp(data.getMac());
|
|
||||||
|
|
||||||
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(newRecord);
|
|
||||||
|
|
||||||
if (!existingNames.isEmpty()) {
|
|
||||||
for (AllInterfaceName existingName : existingNames) {
|
|
||||||
if (isRecordChanged(existingName, newRecord)) {
|
|
||||||
newRecord.setId(existingName.getId());
|
|
||||||
newRecord.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
|
|
||||||
// 检查是否已经存在于更新列表中
|
|
||||||
boolean alreadyInUpdateList = namesToUpdate.stream()
|
|
||||||
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
|
|
||||||
if (!alreadyInUpdateList) {
|
|
||||||
namesToUpdate.add(newRecord);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newRecord.setCreateTime(DateUtils.getNowDate());
|
|
||||||
newRecord.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
|
|
||||||
// 检查namesToInsert中是否已有相同记录
|
if (!records.isEmpty()) {
|
||||||
boolean alreadyInInsertList = namesToInsert.stream()
|
|
||||||
.anyMatch(item -> item.getInterfaceName().equals(name)
|
|
||||||
&& item.getClientId().equals(clientId)
|
|
||||||
&& item.getServerIp().equals(ip));
|
|
||||||
|
|
||||||
if (!alreadyInInsertList) {
|
|
||||||
namesToInsert.add(newRecord);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 批量操作数据库
|
|
||||||
if (!namesToInsert.isEmpty()) {
|
|
||||||
try {
|
try {
|
||||||
allInterfaceNameMapper.batchInsert(namesToInsert);
|
allInterfaceNameMapper.batchInsert(records);
|
||||||
log.info("新增接口名称数量:{}", namesToInsert.size());
|
log.info("批量处理接口名称完成,记录数: {}", records.size());
|
||||||
} catch (Exception e) {
|
}catch (Exception e){
|
||||||
log.error("新增接口名称失败:{}", e.getMessage());
|
// 处理死锁异常
|
||||||
|
if (isDeadlockException(e)) {
|
||||||
|
// 找到第一个非null的clientId
|
||||||
|
String deadlockClientId = records.stream()
|
||||||
|
.map(AllInterfaceName::getClientId)
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.findFirst()
|
||||||
|
.orElse("unknown");
|
||||||
|
log.error("检测到死锁,涉及的clientId: {}", deadlockClientId);
|
||||||
|
} else {
|
||||||
|
// 非死锁异常,重新抛出
|
||||||
|
log.error("批量处理接口名称失败:{}", e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private boolean isDeadlockException(Exception e) {
|
||||||
|
String message = e.getMessage();
|
||||||
|
return message != null && (
|
||||||
|
message.contains("deadlock") ||
|
||||||
|
message.contains("Deadlock") ||
|
||||||
|
message.contains("1213") // MySQL死锁错误码
|
||||||
|
);
|
||||||
|
}
|
||||||
|
private boolean isValidData(EpsInitialTrafficData data) {
|
||||||
|
return StringUtils.isNotBlank(data.getName())
|
||||||
|
&& StringUtils.isNotBlank(data.getMac())
|
||||||
|
&& StringUtils.isNotBlank(data.getClientId());
|
||||||
|
}
|
||||||
|
|
||||||
if (!namesToUpdate.isEmpty()) {
|
private AllInterfaceName convertToInterfaceName(EpsInitialTrafficData data) {
|
||||||
namesToUpdate.sort(Comparator.comparing(AllInterfaceName::getId));
|
AllInterfaceName record = new AllInterfaceName();
|
||||||
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
record.setInterfaceName(data.getName());
|
||||||
log.info("更新接口名称数量:{}", namesToUpdate.size());
|
record.setClientId(data.getClientId());
|
||||||
}
|
record.setResourceType("1");
|
||||||
}
|
record.setDeviceSn(data.getServiceSn());
|
||||||
|
record.setNodeName(data.getNodeName());
|
||||||
|
record.setBusinessCode(data.getBusinessId());
|
||||||
|
record.setBusinessName(data.getBusinessName());
|
||||||
|
record.setServerIp(data.getMac());
|
||||||
|
|
||||||
// 辅助方法:检查记录是否有变化
|
return record;
|
||||||
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
|
|
||||||
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
|
|
||||||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
|
|
||||||
!Objects.equals(oldRecord.getBusinessCode(), newRecord.getBusinessCode()) ||
|
|
||||||
!Objects.equals(oldRecord.getBusinessName(), newRecord.getBusinessName()) ||
|
|
||||||
!Objects.equals(oldRecord.getServerIp(), newRecord.getServerIp());
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 批量删除服务器收益方式配置
|
* 批量删除服务器收益方式配置
|
||||||
|
|||||||
+67
-77
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Isolation;
|
import org.springframework.transaction.annotation.Isolation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
@@ -349,21 +350,61 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
/**
|
/**
|
||||||
* 批量处理接口名称
|
* 批量处理接口名称
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class, isolation = Isolation.REPEATABLE_READ)
|
@Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
||||||
private void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
|
public void processSwitchInterfaceNames(List<InitialSwitchInfoDetails> initialSwitchInfoDetails) {
|
||||||
// 分类处理:新增列表 vs 更新列表
|
if (CollectionUtils.isEmpty(initialSwitchInfoDetails)) {
|
||||||
List<AllInterfaceName> namesToInsert = new ArrayList<>();
|
|
||||||
List<AllInterfaceName> namesToUpdate = new ArrayList<>();
|
|
||||||
|
|
||||||
initialSwitchInfoDetails.forEach(data -> {
|
|
||||||
String name = data.getName();
|
|
||||||
String ip = data.getSwitchIp();
|
|
||||||
String clientId = data.getClientId();
|
|
||||||
if (StringUtils.isBlank(name) || StringUtils.isBlank(ip) || StringUtils.isBlank(clientId)) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 直接转换并过滤
|
||||||
|
List<AllInterfaceName> records = new ArrayList<>();
|
||||||
|
for (InitialSwitchInfoDetails data : initialSwitchInfoDetails) {
|
||||||
|
if (isValidData(data)) {
|
||||||
|
AllInterfaceName record = convertToInterfaceName(data);
|
||||||
|
// 查询业务信息
|
||||||
|
fillBusinessInfo(record, data.getServerSn());
|
||||||
|
records.add(record);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!records.isEmpty()) {
|
||||||
|
try {
|
||||||
|
allInterfaceNameMapper.batchInsert(records);
|
||||||
|
log.info("批量处理交换机接口名称完成,记录数: {}", records.size());
|
||||||
|
}catch (Exception e){
|
||||||
|
// 处理死锁异常
|
||||||
|
if (isDeadlockException(e)) {
|
||||||
|
// 找到第一个非null的clientId
|
||||||
|
String deadlockClientId = records.stream()
|
||||||
|
.map(AllInterfaceName::getClientId)
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.findFirst()
|
||||||
|
.orElse("unknown");
|
||||||
|
log.error("检测到死锁,涉及的clientId: {}", deadlockClientId);
|
||||||
|
} else {
|
||||||
|
// 非死锁异常,重新抛出
|
||||||
|
log.error("批量处理交换机接口名称失败:{}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private boolean isDeadlockException(Exception e) {
|
||||||
|
String message = e.getMessage();
|
||||||
|
return message != null && (
|
||||||
|
message.contains("deadlock") ||
|
||||||
|
message.contains("Deadlock") ||
|
||||||
|
message.contains("1213") // MySQL死锁错误码
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isValidData(InitialSwitchInfoDetails data) {
|
||||||
|
return StringUtils.isNotBlank(data.getName())
|
||||||
|
&& StringUtils.isNotBlank(data.getSwitchIp())
|
||||||
|
&& StringUtils.isNotBlank(data.getClientId());
|
||||||
|
}
|
||||||
|
private AllInterfaceName convertToInterfaceName(InitialSwitchInfoDetails data) {
|
||||||
AllInterfaceName record = new AllInterfaceName();
|
AllInterfaceName record = new AllInterfaceName();
|
||||||
record.setInterfaceName(name);
|
record.setInterfaceName(data.getName());
|
||||||
record.setClientId(data.getClientId());
|
record.setClientId(data.getClientId());
|
||||||
record.setResourceType("2");
|
record.setResourceType("2");
|
||||||
record.setDeviceSn(data.getServerSn());
|
record.setDeviceSn(data.getServerSn());
|
||||||
@@ -373,76 +414,20 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
record.setSwitchName(data.getSwitchName());
|
record.setSwitchName(data.getSwitchName());
|
||||||
record.setSwitchSn(data.getSwitchSn());
|
record.setSwitchSn(data.getSwitchSn());
|
||||||
record.setSwitchIp(data.getSwitchIp());
|
record.setSwitchIp(data.getSwitchIp());
|
||||||
List<AllInterfaceName> existingNames = allInterfaceNameMapper.selectByNames(record);
|
return record;
|
||||||
// 根据服务器sn查询业务
|
}
|
||||||
if(data.getServerSn() != null){
|
private void fillBusinessInfo(AllInterfaceName record, String serverSn) {
|
||||||
EpsServerRevenueConfig epsServerRevenueConfig = new EpsServerRevenueConfig();
|
if (StringUtils.isNotBlank(serverSn)) {
|
||||||
epsServerRevenueConfig.setHardwareSn(data.getServerSn());
|
EpsServerRevenueConfig query = new EpsServerRevenueConfig();
|
||||||
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(epsServerRevenueConfig);
|
query.setHardwareSn(serverSn);
|
||||||
if(!businessList.isEmpty()){
|
List<EpsServerRevenueConfig> businessList = epsServerRevenueConfigMapper.selectEpsServerRevenueConfigList(query);
|
||||||
|
if (!CollectionUtils.isEmpty(businessList)) {
|
||||||
EpsServerRevenueConfig revenueConfig = businessList.get(0);
|
EpsServerRevenueConfig revenueConfig = businessList.get(0);
|
||||||
record.setBusinessName(revenueConfig.getBusinessName());
|
|
||||||
record.setBusinessCode(revenueConfig.getBusinessCode());
|
record.setBusinessCode(revenueConfig.getBusinessCode());
|
||||||
}
|
record.setBusinessName(revenueConfig.getBusinessName());
|
||||||
}else {
|
|
||||||
record.setBusinessCode(null);
|
|
||||||
record.setBusinessName(null);
|
|
||||||
}
|
|
||||||
// 判断是否需要更新
|
|
||||||
if (!existingNames.isEmpty()) {
|
|
||||||
for (AllInterfaceName existingName : existingNames) {
|
|
||||||
if(isRecordChanged(existingName,record)){
|
|
||||||
record.setId(existingName.getId()); // 保留原ID
|
|
||||||
// 检查是否已经存在于更新列表中
|
|
||||||
boolean alreadyInUpdateList = namesToUpdate.stream()
|
|
||||||
.anyMatch(item -> item.getId() != null && item.getId().equals(existingName.getId()));
|
|
||||||
if (!alreadyInUpdateList) {
|
|
||||||
namesToUpdate.add(record);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// 检查namesToInsert中是否已有相同记录
|
|
||||||
boolean alreadyInInsertList = namesToInsert.stream()
|
|
||||||
.anyMatch(item -> item.getInterfaceName().equals(name)
|
|
||||||
&& item.getClientId().equals(clientId)
|
|
||||||
&& item.getSwitchIp().equals(ip));
|
|
||||||
|
|
||||||
if (!alreadyInInsertList) {
|
|
||||||
namesToInsert.add(record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 批量操作数据库
|
|
||||||
if (!namesToInsert.isEmpty()) {
|
|
||||||
try {
|
|
||||||
allInterfaceNameMapper.batchInsert(namesToInsert);
|
|
||||||
log.info("交换机新增接口名称数量:{}", namesToInsert.size());
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("交换机接口名称批量插入失败:{}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!namesToUpdate.isEmpty()) {
|
|
||||||
namesToUpdate.sort(Comparator.comparing(AllInterfaceName::getId));
|
|
||||||
allInterfaceNameMapper.batchUpdate(namesToUpdate);
|
|
||||||
log.info("交换机更新接口名称数量:{}", namesToUpdate.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 辅助方法:检查记录是否有变化
|
|
||||||
private boolean isRecordChanged(AllInterfaceName oldRecord, AllInterfaceName newRecord) {
|
|
||||||
return !Objects.equals(oldRecord.getDeviceSn(), newRecord.getDeviceSn()) ||
|
|
||||||
!Objects.equals(oldRecord.getNodeName(), newRecord.getNodeName()) ||
|
|
||||||
!Objects.equals(oldRecord.getServerPort(), newRecord.getServerPort()) ||
|
|
||||||
!Objects.equals(oldRecord.getInterfaceDeviceType(), newRecord.getInterfaceDeviceType()) ||
|
|
||||||
!Objects.equals(oldRecord.getSwitchName(), newRecord.getSwitchName()) ||
|
|
||||||
!Objects.equals(oldRecord.getBusinessCode(), newRecord.getBusinessCode()) ||
|
|
||||||
!Objects.equals(oldRecord.getBusinessName(), newRecord.getBusinessName()) ||
|
|
||||||
!Objects.equals(oldRecord.getSwitchSn(), newRecord.getSwitchSn()) ||
|
|
||||||
!Objects.equals(oldRecord.getSwitchIp(), newRecord.getSwitchIp());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void calculateSwitch95BandwidthDaily(InitialSwitchInfoDetails queryParam, String dailyStartTime,
|
public void calculateSwitch95BandwidthDaily(InitialSwitchInfoDetails queryParam, String dailyStartTime,
|
||||||
String dailyEndTime, String calculationMode) {
|
String dailyEndTime, String calculationMode) {
|
||||||
@@ -453,7 +438,12 @@ public class InitialSwitchInfoDetailsServiceImpl implements IInitialSwitchInfoDe
|
|||||||
// 遍历处理每个交换机
|
// 遍历处理每个交换机
|
||||||
switchSnList.forEach(interfaceName -> {
|
switchSnList.forEach(interfaceName -> {
|
||||||
queryParam.setClientId(interfaceName.getClientId());
|
queryParam.setClientId(interfaceName.getClientId());
|
||||||
|
try {
|
||||||
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
processSwitchBandwidth(queryParam, dailyStartTime, dailyEndTime, calculationMode);
|
||||||
|
log.info("计算{}交换机的95带宽值完成", interfaceName.getClientId());
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("计算{}交换机的95带宽值失败,详情:{}", interfaceName.getClientId(), e.getMessage());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -101,7 +101,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
startPage(pageDomain);
|
startPage(pageDomain);
|
||||||
|
|
||||||
List<RmResourceRegistration> list = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
List<RmResourceRegistration> list = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||||
|
batchSetNetWorkMsg(list);
|
||||||
// 只处理当前页的数据
|
// 只处理当前页的数据
|
||||||
processCurrentPageData(list);
|
processCurrentPageData(list);
|
||||||
|
|
||||||
@@ -111,6 +111,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
|
|
||||||
// 情况2: 有查询参数或需要排序,全量查询+内存处理
|
// 情况2: 有查询参数或需要排序,全量查询+内存处理
|
||||||
List<RmResourceRegistration> allData = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
List<RmResourceRegistration> allData = rmResourceRegistrationMapper.getRegistrationTableInfoList(rmResourceRegistration);
|
||||||
|
batchSetNetWorkMsg(allData);
|
||||||
|
|
||||||
// 1. 过滤
|
// 1. 过滤
|
||||||
List<RmResourceRegistration> filteredList = allData;
|
List<RmResourceRegistration> filteredList = allData;
|
||||||
@@ -152,7 +153,6 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
|
|
||||||
for (RmResourceRegistration item : pageList) {
|
for (RmResourceRegistration item : pageList) {
|
||||||
if (item.getClientId() != null) {
|
if (item.getClientId() != null) {
|
||||||
setNetWorkMsg(item);
|
|
||||||
setBandwidthYestoday(item);
|
setBandwidthYestoday(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
if (result == null || result.getData() == null || result.getData().isEmpty()) {
|
if (result == null || result.getData() == null || result.getData().isEmpty()) {
|
||||||
log.warn("批量查询网络信息返回为空,clientIds: {}", clientIdsStr);
|
log.warn("批量查询网络信息返回为空,clientIds: {}", clientIdsStr);
|
||||||
// 回退到单条查询
|
// 回退到单条查询
|
||||||
fallbackSetNetworkInfo(pageList);
|
// fallbackSetNetworkInfo(pageList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,7 +341,7 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("批量查询网络信息异常", e);
|
log.error("批量查询网络信息异常", e);
|
||||||
// 回退到单条查询
|
// 回退到单条查询
|
||||||
fallbackSetNetworkInfo(pageList);
|
// fallbackSetNetworkInfo(pageList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -910,19 +910,19 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
|||||||
updateData.setOnlineStatus("1");
|
updateData.setOnlineStatus("1");
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
if(exits.getLogicalNodeId() == null ||
|
if((exits.getLogicalNodeId() == null && rmResourceRegistration.getLogicalNodeId()!=null) ||
|
||||||
!StringUtils.equals(rmResourceRegistration.getLogicalNodeId(),exits.getLogicalNodeId())){
|
!StringUtils.equals(rmResourceRegistration.getLogicalNodeId(),exits.getLogicalNodeId())){
|
||||||
// 如果服务器已注册 增加节点标识
|
// 如果服务器已注册 增加节点标识
|
||||||
updateData.setLogicalNodeId(rmResourceRegistration.getLogicalNodeId());
|
updateData.setLogicalNodeId(rmResourceRegistration.getLogicalNodeId());
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
if(exits.getAgentVersion() == null ||
|
if((exits.getAgentVersion() == null && rmResourceRegistration.getAgentVersion()!=null) ||
|
||||||
!StringUtils.equals(rmResourceRegistration.getAgentVersion(),exits.getAgentVersion())){
|
!StringUtils.equals(rmResourceRegistration.getAgentVersion(),exits.getAgentVersion())){
|
||||||
// 如果服务器已注册 增加版本信息
|
// 如果服务器已注册 增加版本信息
|
||||||
updateData.setAgentVersion(rmResourceRegistration.getAgentVersion());
|
updateData.setAgentVersion(rmResourceRegistration.getAgentVersion());
|
||||||
needUpdate = true;
|
needUpdate = true;
|
||||||
}
|
}
|
||||||
if(exits.getHardwareSn() == null ||
|
if((exits.getHardwareSn() == null && rmResourceRegistration.getHardwareSn()!=null) ||
|
||||||
!StringUtils.equals(rmResourceRegistration.getHardwareSn(),exits.getHardwareSn())){
|
!StringUtils.equals(rmResourceRegistration.getHardwareSn(),exits.getHardwareSn())){
|
||||||
// 如果服务器已注册 增加SN信息
|
// 如果服务器已注册 增加SN信息
|
||||||
updateData.setHardwareSn(rmResourceRegistration.getHardwareSn());
|
updateData.setHardwareSn(rmResourceRegistration.getHardwareSn());
|
||||||
|
|||||||
@@ -12,83 +12,73 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- DEBUG级别日志输出 - 使用ThresholdFilter -->
|
||||||
|
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/debug.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<maxHistory>7</maxHistory> <!-- debug日志只保留7天 -->
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<!-- ThresholdFilter会记录指定级别及以上级别的日志 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!-- 系统日志输出 -->
|
<!-- 系统日志输出 -->
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/info.log</file>
|
<file>${log.path}/info.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
<level>INFO</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/error.log</file>
|
<file>${log.path}/error.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
<level>ERROR</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
<!-- 简化版debug.log配置,只包含日志框架的输出 -->
|
|
||||||
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/debug.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<!-- 记录DEBUG及以上级别,但不记录ERROR(ERROR有单独文件) -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>ERROR</level>
|
|
||||||
<onMatch>DENY</onMatch>
|
|
||||||
<onMismatch>NEUTRAL</onMismatch>
|
|
||||||
</filter>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 系统模块日志级别控制 -->
|
<!-- 系统模块日志级别控制 -->
|
||||||
<logger name="com.tongran" level="info" />
|
<logger name="com.tongran" level="info" />
|
||||||
<!-- Spring日志级别控制 -->
|
<!-- Spring日志级别控制 -->
|
||||||
<logger name="org.springframework" level="warn" />
|
<logger name="org.springframework" level="warn" />
|
||||||
|
|
||||||
|
<!-- 如果你想启用特定类的debug日志 -->
|
||||||
|
<logger name="com.tongran.system" level="debug" additivity="false">
|
||||||
|
<appender-ref ref="file_debug" />
|
||||||
|
<appender-ref ref="console" />
|
||||||
|
</logger>
|
||||||
|
<!-- 排除不需要debug的子包(如果需要) -->
|
||||||
|
<logger name="com.tongran.system.mapper" level="info" />
|
||||||
|
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="console" />
|
<appender-ref ref="console" />
|
||||||
</root>
|
|
||||||
|
|
||||||
<!--系统操作日志-->
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="file_info" />
|
<appender-ref ref="file_info" />
|
||||||
<appender-ref ref="file_error" />
|
<appender-ref ref="file_error" />
|
||||||
|
<!-- 这里不包含file_debug,避免所有框架的debug日志都记录 -->
|
||||||
</root>
|
</root>
|
||||||
</configuration>
|
</configuration>
|
||||||
+59
@@ -194,6 +194,65 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
NOW()
|
NOW()
|
||||||
)
|
)
|
||||||
</foreach>
|
</foreach>
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
device_sn = CASE
|
||||||
|
WHEN device_sn != VALUES(device_sn) OR (device_sn IS NULL AND VALUES(device_sn) IS NOT NULL)
|
||||||
|
THEN VALUES(device_sn)
|
||||||
|
ELSE device_sn
|
||||||
|
END,
|
||||||
|
node_name = CASE
|
||||||
|
WHEN node_name != VALUES(node_name) OR (node_name IS NULL AND VALUES(node_name) IS NOT NULL)
|
||||||
|
THEN VALUES(node_name)
|
||||||
|
ELSE node_name
|
||||||
|
END,
|
||||||
|
business_code = CASE
|
||||||
|
WHEN business_code != VALUES(business_code) OR (business_code IS NULL AND VALUES(business_code) IS NOT NULL)
|
||||||
|
THEN VALUES(business_code)
|
||||||
|
ELSE business_code
|
||||||
|
END,
|
||||||
|
business_name = CASE
|
||||||
|
WHEN business_name != VALUES(business_name) OR (business_name IS NULL AND VALUES(business_name) IS NOT NULL)
|
||||||
|
THEN VALUES(business_name)
|
||||||
|
ELSE business_name
|
||||||
|
END,
|
||||||
|
switch_name = CASE
|
||||||
|
WHEN switch_name != VALUES(switch_name) OR (switch_name IS NULL AND VALUES(switch_name) IS NOT NULL)
|
||||||
|
THEN VALUES(switch_name)
|
||||||
|
ELSE switch_name
|
||||||
|
END,
|
||||||
|
interface_device_type = CASE
|
||||||
|
WHEN interface_device_type != VALUES(interface_device_type) OR (interface_device_type IS NULL AND VALUES(interface_device_type) IS NOT NULL)
|
||||||
|
THEN VALUES(interface_device_type)
|
||||||
|
ELSE interface_device_type
|
||||||
|
END,
|
||||||
|
server_port = CASE
|
||||||
|
WHEN server_port != VALUES(server_port) OR (server_port IS NULL AND VALUES(server_port) IS NOT NULL)
|
||||||
|
THEN VALUES(server_port)
|
||||||
|
ELSE server_port
|
||||||
|
END,
|
||||||
|
switch_sn = CASE
|
||||||
|
WHEN switch_sn != VALUES(switch_sn) OR (switch_sn IS NULL AND VALUES(switch_sn) IS NOT NULL)
|
||||||
|
THEN VALUES(switch_sn)
|
||||||
|
ELSE switch_sn
|
||||||
|
END,
|
||||||
|
switch_ip = CASE
|
||||||
|
WHEN switch_ip != VALUES(switch_ip) OR (switch_ip IS NULL AND VALUES(switch_ip) IS NOT NULL)
|
||||||
|
THEN VALUES(switch_ip)
|
||||||
|
ELSE switch_ip
|
||||||
|
END,
|
||||||
|
update_time = CASE
|
||||||
|
WHEN device_sn != VALUES(device_sn) OR (device_sn IS NULL AND VALUES(device_sn) IS NOT NULL)
|
||||||
|
OR node_name != VALUES(node_name) OR (node_name IS NULL AND VALUES(node_name) IS NOT NULL)
|
||||||
|
OR business_code != VALUES(business_code) OR (business_code IS NULL AND VALUES(business_code) IS NOT NULL)
|
||||||
|
OR business_name != VALUES(business_name) OR (business_name IS NULL AND VALUES(business_name) IS NOT NULL)
|
||||||
|
OR switch_name != VALUES(switch_name) OR (switch_name IS NULL AND VALUES(switch_name) IS NOT NULL)
|
||||||
|
OR interface_device_type != VALUES(interface_device_type) OR (interface_device_type IS NULL AND VALUES(interface_device_type) IS NOT NULL)
|
||||||
|
OR server_port != VALUES(server_port) OR (server_port IS NULL AND VALUES(server_port) IS NOT NULL)
|
||||||
|
OR switch_sn != VALUES(switch_sn) OR (switch_sn IS NULL AND VALUES(switch_sn) IS NOT NULL)
|
||||||
|
OR switch_ip != VALUES(switch_ip) OR (switch_ip IS NULL AND VALUES(switch_ip) IS NOT NULL)
|
||||||
|
THEN NOW()
|
||||||
|
ELSE update_time
|
||||||
|
END
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
<select id="getAllDeviceSn" parameterType="AllInterfaceName" resultType="AllInterfaceName">
|
||||||
|
|||||||
+1
-1
@@ -234,7 +234,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.reported_bandwidth as reportedBandwidth,
|
a.reported_bandwidth as reportedBandwidth,
|
||||||
b.machine_code as machineCode,
|
b.machine_code as machineCode,
|
||||||
(select bandwidth_result from eps_node_bandwidth
|
(select bandwidth_result from eps_node_bandwidth
|
||||||
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type=1
|
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type='1'
|
||||||
AND create_time = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) limit 1) as bandwidthResult
|
AND create_time = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) limit 1) as bandwidthResult
|
||||||
from rm_resource_registration a
|
from rm_resource_registration a
|
||||||
left join rm_registration_machine b on a.client_id = b.client_id
|
left join rm_registration_machine b on a.client_id = b.client_id
|
||||||
|
|||||||
@@ -282,6 +282,13 @@ public class MessageHandler {
|
|||||||
iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
|
iface.setTotalIpv4InSpeed(dataProcessUtil.bytesToBits(iface.getIpv4InSpeed()));
|
||||||
iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
|
iface.setTotalIpv6OutSpeed(dataProcessUtil.bytesToBits(iface.getIpv6OutSpeed()));
|
||||||
iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
|
iface.setTotalIpv6InSpeed(dataProcessUtil.bytesToBits(iface.getIpv6InSpeed()));
|
||||||
|
// 首次采集,速率设为null
|
||||||
|
iface.setInSpeed(null);
|
||||||
|
iface.setOutSpeed(null);
|
||||||
|
iface.setIpv4InSpeed(null);
|
||||||
|
iface.setIpv4OutSpeed(null);
|
||||||
|
iface.setIpv6InSpeed(null);
|
||||||
|
iface.setIpv6OutSpeed(null);
|
||||||
|
|
||||||
InitialBandwidthTrafficTemp tempInfo = tempMap.get(iface.getMac());
|
InitialBandwidthTrafficTemp tempInfo = tempMap.get(iface.getMac());
|
||||||
if (tempInfo != null) {
|
if (tempInfo != null) {
|
||||||
@@ -292,8 +299,6 @@ public class MessageHandler {
|
|||||||
BigDecimal inDiff = nowInSpeed.subtract(tempInSpeed);
|
BigDecimal inDiff = nowInSpeed.subtract(tempInSpeed);
|
||||||
if (inDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (inDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setInSpeed(inDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setInSpeed(inDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setInSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算总流出速率
|
// 计算总流出速率
|
||||||
@@ -303,8 +308,6 @@ public class MessageHandler {
|
|||||||
BigDecimal outDiff = nowOutSpeed.subtract(tempOutSpeed);
|
BigDecimal outDiff = nowOutSpeed.subtract(tempOutSpeed);
|
||||||
if (outDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (outDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setOutSpeed(outDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setOutSpeed(outDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setOutSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算IPv4流入速率
|
// 计算IPv4流入速率
|
||||||
@@ -314,8 +317,6 @@ public class MessageHandler {
|
|||||||
BigDecimal ipv4InDiff = nowIpv4In.subtract(tempIpv4In);
|
BigDecimal ipv4InDiff = nowIpv4In.subtract(tempIpv4In);
|
||||||
if (ipv4InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (ipv4InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setIpv4InSpeed(ipv4InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setIpv4InSpeed(ipv4InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setIpv4InSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算IPv4流出速率
|
// 计算IPv4流出速率
|
||||||
@@ -325,8 +326,6 @@ public class MessageHandler {
|
|||||||
BigDecimal ipv4OutDiff = nowIpv4Out.subtract(tempIpv4Out);
|
BigDecimal ipv4OutDiff = nowIpv4Out.subtract(tempIpv4Out);
|
||||||
if (ipv4OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (ipv4OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setIpv4OutSpeed(ipv4OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setIpv4OutSpeed(ipv4OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setIpv4OutSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算IPv6流入速率
|
// 计算IPv6流入速率
|
||||||
@@ -336,8 +335,6 @@ public class MessageHandler {
|
|||||||
BigDecimal ipv6InDiff = nowIpv6In.subtract(tempIpv6In);
|
BigDecimal ipv6InDiff = nowIpv6In.subtract(tempIpv6In);
|
||||||
if (ipv6InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (ipv6InDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setIpv6InSpeed(ipv6InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setIpv6InSpeed(ipv6InDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setIpv6InSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 计算IPv6流出速率
|
// 计算IPv6流出速率
|
||||||
@@ -347,8 +344,6 @@ public class MessageHandler {
|
|||||||
BigDecimal ipv6OutDiff = nowIpv6Out.subtract(tempIpv6Out);
|
BigDecimal ipv6OutDiff = nowIpv6Out.subtract(tempIpv6Out);
|
||||||
if (ipv6OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
if (ipv6OutDiff.compareTo(BigDecimal.ZERO) >= 0) {
|
||||||
iface.setIpv6OutSpeed(ipv6OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
iface.setIpv6OutSpeed(ipv6OutDiff.divide(divisor, 0, RoundingMode.HALF_UP).toString());
|
||||||
} else {
|
|
||||||
iface.setIpv6OutSpeed(null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,25 +12,35 @@
|
|||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- DEBUG级别日志输出 - 使用ThresholdFilter -->
|
||||||
|
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/debug.log</file>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<maxHistory>7</maxHistory> <!-- debug日志只保留7天 -->
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<!-- ThresholdFilter会记录指定级别及以上级别的日志 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!-- RocketMQ业务日志输出 -->
|
<!-- RocketMQ业务日志输出 -->
|
||||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/info.log</file>
|
<file>${log.path}/info.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>INFO</level>
|
<level>INFO</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
@@ -38,53 +48,30 @@
|
|||||||
<!-- RocketMQ错误日志输出 -->
|
<!-- RocketMQ错误日志输出 -->
|
||||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<file>${log.path}/error.log</file>
|
<file>${log.path}/error.log</file>
|
||||||
<!-- 循环政策:基于时间创建日志文件 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
<!-- 日志文件名格式 -->
|
|
||||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
<!-- 日志最大的历史 60天 -->
|
|
||||||
<maxHistory>60</maxHistory>
|
<maxHistory>60</maxHistory>
|
||||||
</rollingPolicy>
|
</rollingPolicy>
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>${log.pattern}</pattern>
|
<pattern>${log.pattern}</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
<!-- 过滤的级别 -->
|
|
||||||
<level>ERROR</level>
|
<level>ERROR</level>
|
||||||
<!-- 匹配时的操作:接收(记录) -->
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
<!-- 简化版debug.log配置,只包含日志框架的输出 -->
|
|
||||||
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<file>${log.path}/debug.log</file>
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
|
|
||||||
<maxHistory>30</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<encoder>
|
|
||||||
<pattern>${log.pattern}</pattern>
|
|
||||||
</encoder>
|
|
||||||
<!-- 记录DEBUG及以上级别,但不记录ERROR(ERROR有单独文件) -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>ERROR</level>
|
|
||||||
<onMatch>DENY</onMatch>
|
|
||||||
<onMismatch>NEUTRAL</onMismatch>
|
|
||||||
</filter>
|
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
|
||||||
<level>DEBUG</level>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
|
<!-- 如果你想启用特定类的debug日志 -->
|
||||||
<!-- RocketMQ模块日志级别控制 -->
|
<logger name="com.tongran.rocketmq" level="debug" additivity="false">
|
||||||
<logger name="com.tongran.rocketmq" level="info" additivity="false">
|
<appender-ref ref="file_debug" />
|
||||||
<appender-ref ref="console" /> <!-- 显式添加控制台 -->
|
|
||||||
<appender-ref ref="file_info" />
|
<appender-ref ref="file_info" />
|
||||||
<appender-ref ref="file_error" />
|
<appender-ref ref="file_error" />
|
||||||
|
<appender-ref ref="console" />
|
||||||
</logger>
|
</logger>
|
||||||
|
<!-- 排除不需要debug的子包(如果需要) -->
|
||||||
|
<logger name="com.tongran.rocketmq.snmp" level="info" />
|
||||||
|
<logger name="com.tongran.rocketmq.mapper" level="info" />
|
||||||
|
|
||||||
<!-- Apache RocketMQ客户端日志控制 -->
|
<!-- Apache RocketMQ客户端日志控制 -->
|
||||||
<logger name="org.apache.rocketmq" level="warn" />
|
<logger name="org.apache.rocketmq" level="warn" />
|
||||||
|
|||||||
Reference in New Issue
Block a user