Skip to content

Commit

Permalink
Update style
Browse files Browse the repository at this point in the history
  • Loading branch information
wukong121 committed Sep 22, 2023
1 parent a5ac102 commit f0a3a5e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
* @author wangyixing
*/
@Service
public class KubernetesConfigMapSyncServer implements ConfigMapSyncService {
public class ConfigMapSyncServiceImpl implements ConfigMapSyncService {

private Gson gson = new Gson();

Expand Down Expand Up @@ -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");
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class ConfigMapSyncTask {
private ConfigMapSyncConfig configMapSyncConfig;

@Autowired
private KubernetesConfigMapSyncServer kubernetesConfigMapSyncServer;
private ConfigMapSyncServiceImpl configMapSyncService;

/**
* Initialize ConfigMapSyncTask.
Expand All @@ -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();
Expand All @@ -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());
}
}
}
Expand Down Expand Up @@ -145,7 +145,6 @@ private boolean isPair(String line) {
if (containsDoubleEqual) {
newLine = line.replace("==", "");
}
boolean containsEqual = newLine.contains("=");
return containsEqual;
return newLine.contains("=");
}
}

0 comments on commit f0a3a5e

Please sign in to comment.