[ server ] [ oss ] - OSS配置 动态获取

This commit is contained in:
zeaslity
2023-02-13 15:48:03 +08:00
parent ac4c0399c1
commit 601b6a678c
13 changed files with 393 additions and 95 deletions

View File

@@ -12,9 +12,8 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;
import static io.wdd.agent.config.utils.NacosConfigurationCollector.ALL_FUNCTION_MAP;
import static io.wdd.agent.executor.config.ExecutorFunctionNacosCollector.ALL_FUNCTION_MAP;
@Component
public class OMHandlerExecutor extends AbstractOctopusMessageHandler {

View File

@@ -3,7 +3,7 @@ package io.wdd.agent.executor;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import io.wdd.agent.config.utils.AgentCommonThreadPool;
import io.wdd.agent.config.utils.NacosConfigurationCollector;
import io.wdd.agent.executor.config.ExecutorFunctionNacosCollector;
import io.wdd.common.beans.executor.ExecutionMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
@@ -14,8 +14,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.Executor;
import static io.wdd.agent.config.utils.NacosConfigurationCollector.ALL_FUNCTION_MAP;
import static io.wdd.agent.config.utils.NacosConfigurationCollector.NacosConfigService;
import static io.wdd.agent.executor.config.ExecutorFunctionNacosCollector.ALL_FUNCTION_MAP;
import static io.wdd.agent.executor.config.ExecutorFunctionNacosCollector.NacosConfigService;
@Service
@Slf4j
@@ -26,7 +26,7 @@ public class FunctionExecutor {
// todo called by timer
@Resource
NacosConfigurationCollector nacosConfigurationCollector;
ExecutorFunctionNacosCollector executorFunctionNacosCollector;
@@ -78,7 +78,7 @@ public class FunctionExecutor {
// add listener to listen to the real-time change of the Function Shell Scripts
try {
NacosConfigService.addListener(nacosConfigurationCollector.executorFunctionDataId + "." + nacosConfigurationCollector.fileExtension, nacosConfigurationCollector.group, new Listener() {
NacosConfigService.addListener(executorFunctionNacosCollector.executorFunctionDataId + "." + executorFunctionNacosCollector.fileExtension, executorFunctionNacosCollector.group, new Listener() {
@Override
public Executor getExecutor() {
return null;
@@ -89,7 +89,7 @@ public class FunctionExecutor {
log.info("detected nacos function shell update ! {}", s);
nacosConfigurationCollector.parseNacosFunctionYamlToMap(s);
executorFunctionNacosCollector.parseNacosFunctionYamlToMap(s);
}
});

View File

@@ -1,4 +1,4 @@
package io.wdd.agent.config.utils;
package io.wdd.agent.executor.config;
import com.alibaba.nacos.api.NacosFactory;
@@ -22,7 +22,7 @@ import static io.wdd.agent.executor.status.AppStatusExecutor.ALL_APP_NEED_TO_MON
@Component
@Lazy
@Slf4j
public class NacosConfigurationCollector {
public class ExecutorFunctionNacosCollector {
/**
@@ -80,6 +80,7 @@ public class NacosConfigurationCollector {
* https://nacos.io/zh-cn/docs/v2/guide/user/sdk.html
*
* dynamically listen to the nacos
* 动态监听Nacos的变化
*
* Actively get the executor functions configuration.
* */
@@ -175,37 +176,4 @@ public class NacosConfigurationCollector {
}
/**
* due to can't get shell from the jar file
* this is deprecated
*/
// @PostConstruct
// private void CollectAllFunctionShellScriptName() {
//
// // scan current package files name and store them to FUNCTION_REFLECTION
//
//
// Path absolutePath = Paths.get("").toAbsolutePath();
// log.info("current absolute path is {}", absolutePath);
//
// Path currentDirectory = Path.of(absolutePath + "/src/main/java/io/wdd/agent/executor/function").toAbsolutePath();
//
//
// IOFileFilter fileFilter = FileFilterUtils.suffixFileFilter(".sh");
// IOFileFilter directoryFileFilter = DirectoryFileFilter.INSTANCE;
//
// Collection<File> functionFileList = FileUtils.listFiles(currentDirectory.toFile(), fileFilter, directoryFileFilter);
//
// log.debug("all function shell script files are : {}", functionFileList);
//
// Map<String, String> collect = functionFileList.stream().collect(Collectors.toMap(
// functionFile -> functionFile.getName().split("\\.")[0],
// functionFile -> functionFile.getAbsolutePath()
// ));
//
// ALL_FUNCTION_MAP.putAll(collect);
//
// }
}

View File

@@ -276,7 +276,7 @@ EOF
InstallDocker() {
Docker_Source="cn"
local dockerVersion=$(echo $DOCKER_VERSION | cut -d"." -f-2)
dockerVersion=$(echo $DOCKER_VERSION | cut -d"." -f-2)
if [[ "$1" -ne " " ]]; then
Docker_Source="$1"
@@ -362,7 +362,9 @@ InstallDocker() {
colorEcho ${GREEN} "开始安装docker-ce版本为${DOCKER_VERSION}"
realDockerSTag=$(apt-cache madison docker-ce | grep -w ${dockerVersion} | awk '{print$3}' | grep ${DOCKER_VERSION})
installDemandSoftwares docker-ce=${realDockerSTag} || return $?
echo " real is $realDockerSTag"
installDemandSoftwares "docker-ce=${realDockerSTag}" || return $?
fi
echo ""

View File

@@ -1,6 +1,6 @@
package io.wdd.agent;
import io.wdd.agent.config.utils.NacosConfigurationCollector;
import io.wdd.agent.executor.config.ExecutorFunctionNacosCollector;
import io.wdd.agent.executor.FunctionExecutor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils;
@@ -25,7 +25,7 @@ class AgentApplicationTests {
FunctionExecutor functionExecutor;
@Resource
NacosConfigurationCollector nacosConfigurationCollector;
ExecutorFunctionNacosCollector executorFunctionNacosCollector;
// @Test