diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncService.java b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncService.java index 64827de92da..5a410e325a8 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncService.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncService.java @@ -23,11 +23,31 @@ import java.io.IOException; +/** + * ConfigMap synchronize service. + * + * @author wangyixing + */ public interface ConfigMapSyncService { + /** + * publish k8s configMap. + * @param configMap configMap entry + * @param srcIp client's Ip + * @throws NacosException exception + */ void publishConfigMap(V1ConfigMap configMap, String srcIp) throws NacosException; + /** + * delete k8s configMap. + * @param configMap configMap entry + * @param clientIp client's Ip + */ void deleteConfigMap(V1ConfigMap configMap, String clientIp); + /** + * start watch function. + * @throws IOException exception + */ void startWatchConfigMap() throws IOException; } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/KubernetesConfigMapSyncServer.java b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncServiceImpl.java similarity index 99% rename from config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/KubernetesConfigMapSyncServer.java rename to config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncServiceImpl.java index 35ac9b517bc..0605b5aca14 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/KubernetesConfigMapSyncServer.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncServiceImpl.java @@ -65,7 +65,7 @@ * @author wangyixing */ @Service -public class KubernetesConfigMapSyncServer implements ConfigMapSyncService { +public class ConfigMapSyncServiceImpl implements ConfigMapSyncService { private Gson gson = new Gson(); @@ -99,7 +99,7 @@ public void start() throws IOException { startWatchConfigMap(); Runtime.getRuntime().addShutdownHook(new Thread(() -> { Loggers.MAIN.info("[{}] stopping...", "configMap-sync"); - KubernetesConfigMapSyncServer.this.stop(); + ConfigMapSyncServiceImpl.this.stop(); Loggers.MAIN.info("[{}] stopped.", "configMap-sync"); })); } diff --git a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncTask.java b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncTask.java index f503b7fc879..23b253d1ada 100644 --- a/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncTask.java +++ b/config/src/main/java/com/alibaba/nacos/config/server/service/kubernetes/ConfigMapSyncTask.java @@ -57,7 +57,7 @@ public class ConfigMapSyncTask { private ConfigMapSyncConfig configMapSyncConfig; @Autowired - private KubernetesConfigMapSyncServer kubernetesConfigMapSyncServer; + private ConfigMapSyncServiceImpl configMapSyncService; /** * Initialize ConfigMapSyncTask. @@ -66,7 +66,7 @@ public class ConfigMapSyncTask { @PostConstruct public void init() throws IOException { if (configMapSyncConfig.isOutsideCluster()) { - apiClient = kubernetesConfigMapSyncServer.getOutsideApiClient(); + apiClient = configMapSyncService.getOutsideApiClient(); coreV1Api = new CoreV1Api(apiClient); } else { coreV1Api = new CoreV1Api(); @@ -92,11 +92,11 @@ public void checkAndSyncConfigMaps() { ConfigInfoWrapper configInfo = configInfoPersistService.findConfigInfo(dataId, group, namespace); if (configInfo == null) { Loggers.MAIN.info("[{}] find a missed config.", "configMap-sync"); - kubernetesConfigMapSyncServer.publishConfigMap(configMap, apiClient.getBasePath()); + configMapSyncService.publishConfigMap(configMap, apiClient.getBasePath()); } else { if (!compareContent(content, configInfo.getContent())) { Loggers.MAIN.info("[{}] find content difference.", "configMap-sync"); - kubernetesConfigMapSyncServer.publishConfigMap(configMap, apiClient.getBasePath()); + configMapSyncService.publishConfigMap(configMap, apiClient.getBasePath()); } } } @@ -145,7 +145,6 @@ private boolean isPair(String line) { if (containsDoubleEqual) { newLine = line.replace("==", ""); } - boolean containsEqual = newLine.contains("="); - return containsEqual; + return newLine.contains("="); } }