[集群-自动切换过国标级联] 添加数据库脚本
This commit is contained in:
@@ -127,4 +127,7 @@ public class Platform {
|
||||
|
||||
@Schema(description = "保密属性(必选)缺省为0;0-不涉密,1-涉密")
|
||||
private int secrecy = 0;
|
||||
|
||||
@Schema(description = "执行注册的服务ID")
|
||||
private String serverId;
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ public interface PlatformMapper {
|
||||
@Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+
|
||||
" device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,status,catalog_group, update_time," +
|
||||
" create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform,catalog_with_group,catalog_with_region, "+
|
||||
" civil_code,manufacturer,model,address,register_way,secrecy) " +
|
||||
" civil_code,manufacturer,model,address,register_way,secrecy,server_id) " +
|
||||
" VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " +
|
||||
" #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{status}, #{catalogGroup},#{updateTime}," +
|
||||
" #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{catalogWithGroup},#{catalogWithRegion}, " +
|
||||
" #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy})")
|
||||
" #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy}, #{serverId})")
|
||||
int add(Platform parentPlatform);
|
||||
|
||||
@Update("UPDATE wvp_platform " +
|
||||
@@ -55,6 +55,7 @@ public interface PlatformMapper {
|
||||
" model=#{model}, " +
|
||||
" address=#{address}, " +
|
||||
" register_way=#{registerWay}, " +
|
||||
" server_id=#{serverId}, " +
|
||||
" secrecy=#{secrecy} " +
|
||||
"WHERE id=#{id}")
|
||||
int update(Platform parentPlatform);
|
||||
@@ -77,7 +78,7 @@ public interface PlatformMapper {
|
||||
List<Platform> queryList(@Param("query") String query);
|
||||
|
||||
@Select("SELECT * FROM wvp_platform WHERE enable=#{enable} ")
|
||||
List<Platform> getEnableParentPlatformList(boolean enable);
|
||||
List<Platform> queryEnableParentPlatformList(boolean enable);
|
||||
|
||||
@Select("SELECT * FROM wvp_platform WHERE enable=true and as_message_channel=true")
|
||||
List<Platform> queryEnablePlatformListWithAsMessageChannel();
|
||||
@@ -91,7 +92,6 @@ public interface PlatformMapper {
|
||||
@Update("UPDATE wvp_platform SET status=#{online} WHERE server_gb_id=#{platformGbID}" )
|
||||
int updateStatus(@Param("platformGbID") String platformGbID, @Param("online") boolean online);
|
||||
|
||||
@Select("SELECT * FROM wvp_platform WHERE enable=true")
|
||||
List<Platform> queryEnablePlatformList();
|
||||
|
||||
@Select("SELECT server_id FROM wvp_platform WHERE enable=true and server_id != #{serverId} group by server_id")
|
||||
List<String> queryServerIdsWithEnable(@Param("serverId") String serverId);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -46,6 +47,7 @@ import java.text.ParseException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.Vector;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
@@ -98,6 +100,28 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
@Autowired
|
||||
private ISendRtpServerService sendRtpServerService;
|
||||
|
||||
// 定时监听国标级联所进行的WVP服务是否正常, 如果异常则选择新的wvp执行
|
||||
@Scheduled(fixedDelay = 2, timeUnit = TimeUnit.SECONDS) //每3秒执行一次
|
||||
public void execute(){
|
||||
if (!userSetting.isAutoRegisterPlatform()) {
|
||||
return;
|
||||
}
|
||||
// 查找非平台的国标级联执行服务Id
|
||||
List<String> serverIds = platformMapper.queryServerIdsWithEnable(userSetting.getServerId());
|
||||
if (serverIds == null || serverIds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
serverIds.forEach(serverId -> {
|
||||
// 检查每个是否存活
|
||||
ServerInfo serverInfo = redisCatchStorage.queryServerInfo(serverId);
|
||||
if (serverInfo == null) {
|
||||
// 此平台需要选择新平台处理
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 流离开的处理
|
||||
*/
|
||||
@@ -780,7 +804,7 @@ public class PlatformServiceImpl implements IPlatformService {
|
||||
|
||||
@Override
|
||||
public List<Platform> queryEnablePlatformList() {
|
||||
return platformMapper.queryEnablePlatformList();
|
||||
return platformMapper.queryEnableParentPlatformList(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user