[ server] [ agent ] - 版本信息控制
This commit is contained in:
@@ -11,6 +11,7 @@ import io.wdd.rpc.message.sender.OMessageToAgentSender;
|
||||
import io.wdd.server.beans.vo.ServerInfoVO;
|
||||
import io.wdd.server.config.ServerCommonPool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -25,6 +26,8 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static io.wdd.rpc.init.ServerBootUpEnvironment.ALL_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.init.ServerBootUpEnvironment.ALL_HEALTHY_AGENT_TOPIC_NAME_LIST;
|
||||
import static io.wdd.rpc.message.handler.OctopusMessageHandler.AGENT_LATEST_VERSION;
|
||||
import static io.wdd.rpc.message.handler.OctopusMessageHandler.OCTOPUS_MESSAGE_FROM_AGENT;
|
||||
|
||||
@Service
|
||||
@@ -37,6 +40,9 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
@Resource
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
@Resource
|
||||
RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public Map<String, String> getAllAgentVersion() {
|
||||
HashMap<String, String> result = new HashMap<>();
|
||||
@@ -44,7 +50,7 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
// 查询获取到最新的Agent版本信息
|
||||
result.put(
|
||||
"LATEST_VERSION",
|
||||
"2023-02-06-09-23-00"
|
||||
getRealAgentLatestVersion()
|
||||
);
|
||||
|
||||
// 获取Agent的版本信息 -- 超时时间
|
||||
@@ -63,14 +69,27 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
);
|
||||
|
||||
try {
|
||||
TimeUnit.SECONDS.sleep(3);
|
||||
TimeUnit.SECONDS.sleep(5);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
System.out.println("result = " + result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getRealAgentLatestVersion() {
|
||||
|
||||
String latestVersion = (String) redisTemplate
|
||||
.opsForValue()
|
||||
.get(
|
||||
AGENT_LATEST_VERSION
|
||||
);
|
||||
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, ServerInfoVO> getAllAgentCoreInfo() {
|
||||
return null;
|
||||
@@ -87,7 +106,7 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
CompletableFuture<Void> getAllAgentVersionInfo = new CompletableFuture<>();
|
||||
try {
|
||||
ExecutorService pool = ServerCommonPool.pool;
|
||||
CountDownLatch countDownLatch = new CountDownLatch(ALL_AGENT_TOPIC_NAME_LIST.size());
|
||||
CountDownLatch countDownLatch = new CountDownLatch(ALL_HEALTHY_AGENT_TOPIC_NAME_LIST.size());
|
||||
|
||||
// 从OCTOPUS_MESSAGE_FROM_AGENT中获取符合条件的信息
|
||||
getAllAgentVersionInfo = CompletableFuture.runAsync(
|
||||
@@ -163,7 +182,7 @@ public class OctopusAgentServiceImpl implements OctopusAgentService {
|
||||
|
||||
private void buildAndSendToAllAgent(AgentOperationType operationType, LocalDateTime currentTime) {
|
||||
|
||||
List<OctopusMessage> octopusMessageList = ALL_AGENT_TOPIC_NAME_LIST
|
||||
List<OctopusMessage> octopusMessageList = ALL_HEALTHY_AGENT_TOPIC_NAME_LIST
|
||||
.stream()
|
||||
.map(
|
||||
agentTopicName ->
|
||||
|
||||
Reference in New Issue
Block a user