第6次优化
parent
ff7dfdc1e4
commit
e70a315159
|
@ -2,6 +2,7 @@ package com.lyh;
|
|||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @ProjectName: Default (Template) Project
|
||||
|
@ -11,8 +12,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
*/
|
||||
|
||||
@SpringBootApplication
|
||||
//@EnableScheduling
|
||||
//@EnableFeignClients
|
||||
@EnableScheduling
|
||||
public class LoadCenterApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LoadCenterApplication.class, args);
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.lyh.domain.resp.Result;
|
|||
import com.lyh.service.LoadCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
@ -36,6 +37,19 @@ public class LoadCenterServiceImpl implements LoadCenterService {
|
|||
@Autowired
|
||||
private AliYunEcsService aliYunEcsService;
|
||||
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/17 20:31
|
||||
* @Description: 定时刷新实例公网IP列表缓存
|
||||
* @Param: []
|
||||
* @Return: void
|
||||
**/
|
||||
@Scheduled(cron = "0/2 * * * * ?")
|
||||
public void refreshEcsIPListCache() {
|
||||
getEcsIPList();
|
||||
}
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/15 21:49
|
||||
|
@ -46,10 +60,6 @@ public class LoadCenterServiceImpl implements LoadCenterService {
|
|||
@Override
|
||||
public Result<String> getAssignedServer() {
|
||||
|
||||
|
||||
//刷新一下 实例公网IP列 缓存
|
||||
this.getEcsIPList();
|
||||
|
||||
//从缓存中获取实例公网IP列表
|
||||
if (redis.getCacheList("实例IP列表:").isEmpty()) {
|
||||
throw new RuntimeException("实例IP列表为空!");
|
||||
|
|
|
@ -72,7 +72,7 @@ public class Test {
|
|||
**/
|
||||
@org.junit.jupiter.api.Test
|
||||
public void releaseInstances() throws Exception {
|
||||
aliYunEcsService.releaseInstances("i-uf624nmh7j2nzlzxnd1u");
|
||||
aliYunEcsService.releaseInstances("i-uf6dmmscd3b64m0jqs9f");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue