Commit 9d2cf93e by Jason Song

Merge pull request #61 from yiming187/bug_fix

Fix AdminService bugs
parents 6b98de3d e74556fe
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-adminservice</artifactId>
<name>Apollo AdminService</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-biz</artifactId>
</dependency>
<!-- end of apollo -->
<!-- redis -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
<!-- end of redis -->
<!-- eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apollo-adminservice</artifactId>
<name>Apollo AdminService</name>
<dependencies>
<!-- apollo -->
<dependency>
<groupId>com.ctrip.apollo</groupId>
<artifactId>apollo-biz</artifactId>
</dependency>
<!-- end of apollo -->
<!-- eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<!-- end of eureka -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
......@@ -9,6 +9,6 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@EnableEurekaClient
public class AdminServiceApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(AdminServiceApplication.class).web(true).run(args);
new SpringApplicationBuilder(AdminServiceApplication.class).run(args);
}
}
......@@ -3,6 +3,7 @@ package com.ctrip.apollo.adminservice.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
......@@ -12,22 +13,29 @@ import com.ctrip.apollo.biz.entity.App;
import com.ctrip.apollo.biz.service.AppService;
import com.ctrip.apollo.biz.utils.BeanUtils;
import com.ctrip.apollo.core.dto.AppDTO;
import com.google.common.base.Strings;
@RestController
public class AppController {
@Autowired
private AppService appService;
@RequestMapping("/apps/{appId}")
public AppDTO findByAppId(@PathVariable("appId") String appId) {
App app = appService.findByAppId(appId);
return BeanUtils.transfrom(AppDTO.class, app);
public AppDTO getApp(@PathVariable("appId") String appId) {
App app = appService.findOne(appId);
return BeanUtils.transfrom(AppDTO.class, app);
}
@RequestMapping("/apps")
public List<AppDTO> findByName(@RequestParam("name") String name) {
List<App> app = appService.findByName(name);
return BeanUtils.batchTransform(AppDTO.class, app);
public List<AppDTO> findApps(@RequestParam(value = "name", required = false) String name,
Pageable pageable) {
List<App> app = null;
if (Strings.isNullOrEmpty(name)) {
app = appService.findAll(pageable);
} else {
app = appService.findByName(name);
}
return BeanUtils.batchTransform(AppDTO.class, app);
}
}
......@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ctrip.apollo.biz.entity.Cluster;
import com.ctrip.apollo.biz.service.ClusterService;
import com.ctrip.apollo.biz.service.ViewService;
import com.ctrip.apollo.biz.utils.BeanUtils;
import com.ctrip.apollo.core.dto.ClusterDTO;
......@@ -18,9 +19,19 @@ public class ClusterController {
@Autowired
private ViewService viewService;
@Autowired
private ClusterService clusterService;
@RequestMapping("/apps/{appId}/clusters")
public List<ClusterDTO> findClusters(@PathVariable("appId") String appId) {
List<Cluster> clusters = viewService.findClusters(appId);
return BeanUtils.batchTransform(ClusterDTO.class, clusters);
}
@RequestMapping("/apps/{appId}/clusters/{clusterName}")
public ClusterDTO getCluster(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
Cluster cluster = clusterService.findOne(appId, clusterName);
return BeanUtils.transfrom(ClusterDTO.class, cluster);
}
}
......@@ -14,24 +14,33 @@ import com.ctrip.apollo.biz.utils.BeanUtils;
import com.ctrip.apollo.core.dto.NamespaceDTO;
@RestController
public class GroupController {
public class NamespaceController {
@Autowired
private ViewService viewService;
@Autowired
private NamespaceService groupService;
private NamespaceService namespaceService;
@RequestMapping("/apps/{appId}/clusters/{clusterName}/groups")
public List<NamespaceDTO> findGroups(@PathVariable("appId") String appId,
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces")
public List<NamespaceDTO> findNamespaces(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName) {
List<Namespace> groups = viewService.findNamespaces(appId, clusterName);
return BeanUtils.batchTransform(NamespaceDTO.class, groups);
}
@RequestMapping("/groups/{groupId}")
public NamespaceDTO findOne(@PathVariable("groupId") Long groupId) {
Namespace group = groupService.findOne(groupId);
return BeanUtils.transfrom(NamespaceDTO.class, group);
@RequestMapping("/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}")
public NamespaceDTO getNamespace(@PathVariable("appId") String appId,
@PathVariable("clusterName") String clusterName,
@PathVariable("namespaceName") String namespaceName) {
Namespace namespace = namespaceService.findOne(appId,
clusterName, namespaceName);
return BeanUtils.transfrom(NamespaceDTO.class, namespace);
}
@RequestMapping("/namespaces/{namespaceId}")
public NamespaceDTO getNamespace(@PathVariable("namespaceId") Long namespaceId) {
Namespace namespace = namespaceService.findOne(namespaceId);
return BeanUtils.transfrom(NamespaceDTO.class, namespace);
}
}
package com.ctrip.apollo.adminservice.controller;
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@EnableWebMvc
public class WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
PageableHandlerMethodArgumentResolver resolver = new PageableHandlerMethodArgumentResolver();
resolver.setFallbackPageable(new PageRequest(0, 10));
argumentResolvers.add(resolver);
}
}
package com.ctrip.apollo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class SampleAdminServiceApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SampleAdminServiceApplication.class).run(args);
}
}
spring.datasource.url = jdbc:h2:mem:~/fxapolloconfigdb;mode=mysql
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.h2.console.enabled = true
spring.h2.console.settings.web-allow-others=true
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003171','apollo-config-service','刘一鸣','liuym@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003172','apollo-admin-service','宋顺','song_s@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('100003173','apollo-portal','张乐','zhanglea@ctrip.com');
INSERT INTO App (AppId, Name, OwnerName, OwnerEmail) VALUES ('fxhermesproducer','fx-hermes-producer','梁锦华','jhliang@ctrip.com');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003171', 'cluster1');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003172', 'cluster2');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'default');
INSERT INTO Cluster (AppId, Name) VALUES ('100003173', 'cluster3');
INSERT INTO Cluster (AppId, Name) VALUES ('fxhermesproducer', 'default');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003171', 'apollo-config-service');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003172', 'apollo-admin-service');
INSERT INTO AppNamespace (AppId, Name) VALUES ('100003173', 'apollo-portal-service');
INSERT INTO AppNamespace (AppID, Name) VALUES ('fxhermesproducer', 'fx-hermes-producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (1, '100003171', 'default', 'apollo-config-service');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (2, 'fxhermesproducer', 'default', 'fx-hermes-producer');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (3, '100003172', 'default', 'apollo-admin-service');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (4, '100003173', 'default', 'apollo-portal');
INSERT INTO Namespace (Id, AppId, ClusterName, NamespaceName) VALUES (5, '100003171', 'default', 'fx-hermes-producer');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k1', 'v1', 'comment1');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (1, 'k2', 'v2', 'comment2');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (2, 'k3', 'v3', 'comment3');
INSERT INTO Item (NamespaceId, `Key`, Value, Comment) VALUES (5, 'k3', 'v4', 'comment4');
INSERT INTO `RELEASE` (Name, Comment, AppId, ClusterName, NamespaceName, Configurations) VALUES ('REV1','First Release','100003171', 'default', 'apollo-config-service', '{"k1":"v1"}');
......@@ -19,12 +19,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<artifactId>logback-classic</artifactId>
<groupId>ch.qos.logback</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<profiles>
......
......@@ -7,14 +7,14 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@Entity
@SQLDelete(sql = "Update App set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update App set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class App extends BaseEntity {
@Column(nullable = false)
private String name;
@Column(nullable = false)
@Column(nullable = false, unique = true)
private String appId;
@Column(nullable = false)
......
......@@ -7,11 +7,11 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@Entity
@SQLDelete(sql = "Update AppNamespace set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update AppNamespace set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class AppNamespace extends BaseEntity{
@Column(nullable = false)
@Column(nullable = false, unique = true)
private String name;
@Column(nullable = false)
......
......@@ -10,8 +10,8 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@SQLDelete(sql = "Update Cluster set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update Cluster set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class Cluster extends BaseEntity {
@Column(nullable = false)
......
......@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@Entity
@SQLDelete(sql = "Update Item set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update Item set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class Item extends BaseEntity {
@Column(nullable = false)
......
......@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@Entity
@SQLDelete(sql = "Update Namespace set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update Namespace set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class Namespace extends BaseEntity {
@Column(nullable = false)
......
......@@ -7,8 +7,8 @@ import org.hibernate.annotations.SQLDelete;
import org.hibernate.annotations.Where;
@Entity
@SQLDelete(sql = "Update Privilege set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update Privilege set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class Privilege extends BaseEntity {
@Column
......
......@@ -11,8 +11,8 @@ import org.hibernate.annotations.Where;
* @author Jason Song(song_s@ctrip.com)
*/
@Entity
@SQLDelete(sql = "Update Release set isDeleted = 1 where id = ?")
@Where(clause = "isDeleted = 0")
@SQLDelete(sql = "Update Release set isDeleted = 'false' where id = ?")
@Where(clause = "isDeleted = 'false'")
public class Release extends BaseEntity {
@Column(nullable = false)
......
......@@ -29,7 +29,7 @@ public class AppService {
return appRepository.findByName(name);
}
public App findByAppId(String appId){
public App findOne(String appId){
return appRepository.findByAppId(appId);
}
}
package com.ctrip.apollo.biz.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ctrip.apollo.biz.entity.Cluster;
import com.ctrip.apollo.biz.repository.ClusterRepository;
@Service
public class ClusterService {
@Autowired
private ClusterRepository clusterRepository;
public Cluster findOne(String appId, String name) {
return clusterRepository.findByAppIdAndName(appId, name);
}
}
......@@ -11,8 +11,14 @@ public class NamespaceService {
@Autowired
private NamespaceRepository namespaceRepository;
public Namespace findOne(Long namespaceId){
public Namespace findOne(Long namespaceId) {
return namespaceRepository.findOne(namespaceId);
}
public Namespace findOne(String appId, String clusterName,
String namespaceName) {
return namespaceRepository.findByAppIdAndClusterNameAndNamespaceName(appId, clusterName,
namespaceName);
}
}
......@@ -3,7 +3,6 @@ package com.ctrip.apollo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.ConfigurableApplicationContext;
/**
* Spring boot application entry point
......@@ -12,11 +11,10 @@ import org.springframework.context.ConfigurableApplicationContext;
*/
@SpringBootApplication
@EnableEurekaServer
public class ServerApplication {
public class ConfigServiceApplication {
public static void main(String[] args) throws Exception {
ConfigurableApplicationContext context =
new SpringApplicationBuilder(ServerApplication.class).web(true).run(args);
new SpringApplicationBuilder(ConfigServiceApplication.class).run(args);
}
}
......@@ -12,7 +12,7 @@ public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(ServerApplication.class);
return application.sources(ConfigServiceApplication.class);
}
}
package com.ctrip.apollo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class SampleConfigServiceApplication {
public static void main(String[] args) {
new SpringApplicationBuilder(SampleConfigServiceApplication.class).run(args);
}
}
package com.ctrip.apollo.configservice;
import com.ctrip.apollo.ServerApplication;
import com.ctrip.apollo.ConfigServiceApplication;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ServerApplication.class)
@SpringApplicationConfiguration(classes = ConfigServiceApplication.class)
public abstract class AbstractConfigServiceTest {
}
spring:
application:
name: apollo-configservice
datasource:
url: jdbc:h2:mem:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE
server:
port: 8888
port: ${port:8080}
logging:
level:
org.springframework.cloud: 'DEBUG'
file: /opt/logs/${ctrip.appid}/apollo-configservice.log
spring:
application:
name: apollo-configservice
datasource:
url: jdbc:h2:file:~/fxapolloconfigdb;DB_CLOSE_ON_EXIT=FALSE
username: sa
password:
ctrip:
appid: 100003171
\ No newline at end of file
eureka:
instance:
hostname: localhost
hostname: ${hostname:localhost}
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:8761/eureka/
defaultZone: http://${eureka.instance.hostname}:8080/eureka/
healthcheck:
enabled: true
\ No newline at end of file
......@@ -2,6 +2,8 @@ package com.ctrip.apollo.core.dto;
public class AppDTO {
private long id;
private String name;
private String appId;
......@@ -14,6 +16,10 @@ public class AppDTO {
return appId;
}
public long getId() {
return id;
}
public String getName() {
return name;
}
......@@ -30,6 +36,10 @@ public class AppDTO {
this.appId = appId;
}
public void setId(long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
......
......@@ -4,11 +4,7 @@ public class ItemDTO {
private long id;
private long clusterId;
private String clusterName;
private String appId;
private long namespaceId;
private String key;
......@@ -25,59 +21,43 @@ public class ItemDTO {
this.value = value;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public long getClusterId() {
return clusterId;
public String getComment() {
return comment;
}
public void setClusterId(long clusterId) {
this.clusterId = clusterId;
public long getId() {
return id;
}
public String getClusterName() {
return clusterName;
public String getKey() {
return key;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
public long getNamespaceId() {
return namespaceId;
}
public String getAppId() {
return appId;
public String getValue() {
return value;
}
public void setAppId(String appId) {
this.appId = appId;
public void setComment(String comment) {
this.comment = comment;
}
public String getKey() {
return key;
public void setId(long id) {
this.id = id;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
}
public void setValue(String value) {
this.value = value;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}
......@@ -4,41 +4,41 @@ public class NamespaceDTO {
private long id;
private long clusterId;
private String appId;
private String clusterName;
private long namespaceId;
private String namespaceName;
private String name;
public String getAppId() {
return appId;
}
public long getClusterId() {
return clusterId;
public String getClusterId() {
return clusterName;
}
public long getId() {
return id;
}
public String getName() {
return name;
public String getNamespaceName() {
return namespaceName;
}
public long getNamespaceId() {
return namespaceId;
public void setAppId(String appId) {
this.appId = appId;
}
public void setClusterId(long clusterId) {
this.clusterId = clusterId;
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
public void setId(long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setNamespaceId(long namespaceId) {
this.namespaceId = namespaceId;
public void setNamespaceName(String namespaceName) {
this.namespaceName = namespaceName;
}
}
......@@ -4,45 +4,72 @@ public class ReleaseDTO {
private long id;
private long releaseId;
private String name;
private String appId;
private String clusterName;
private String namespaceName;
private String configurations;
public ReleaseDTO() {
private String comment;
public String getAppId() {
return appId;
}
public long getId() {
return id;
public String getClusterName() {
return clusterName;
}
public void setId(long id) {
this.id = id;
public String getComment() {
return comment;
}
public long getReleaseId() {
return releaseId;
public String getConfigurations() {
return configurations;
}
public void setReleaseId(long releaseId) {
this.releaseId = releaseId;
public long getId() {
return id;
}
public String getClusterName() {
return clusterName;
public String getName() {
return name;
}
public String getNamespaceName() {
return namespaceName;
}
public void setAppId(String appId) {
this.appId = appId;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
}
public String getConfigurations() {
return configurations;
public void setComment(String comment) {
this.comment = comment;
}
public void setConfigurations(String configurations) {
this.configurations = configurations;
}
public void setId(long id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setNamespaceName(String namespaceName) {
this.namespaceName = namespaceName;
}
}
......@@ -180,16 +180,16 @@ public class ConfigService {
private Map<String, List<ItemDTO>> groupConfigByCluster(List<ItemDTO> configItems) {
Map<String, List<ItemDTO>> groupedClusterConfigs = new HashMap<>();
String clusterName;
for (ItemDTO configItem : configItems) {
clusterName = configItem.getClusterName();
List<ItemDTO> clusterConfigs = groupedClusterConfigs.get(clusterName);
if (clusterConfigs == null) {
clusterConfigs = new LinkedList<>();
groupedClusterConfigs.put(clusterName, clusterConfigs);
}
clusterConfigs.add(configItem);
}
// String clusterName;
// for (ItemDTO configItem : configItems) {
// clusterName = configItem.getClusterName();
// List<ItemDTO> clusterConfigs = groupedClusterConfigs.get(clusterName);
// if (clusterConfigs == null) {
// clusterConfigs = new LinkedList<>();
// groupedClusterConfigs.put(clusterName, clusterConfigs);
// }
// clusterConfigs.add(configItem);
// }
return groupedClusterConfigs;
}
......@@ -227,28 +227,28 @@ public class ConfigService {
Map<String, AppConfigVO.OverrideAppConfig> appIdMapOverrideAppConfig = null;
for (ItemDTO config : clusterConfigs) {
String targetAppId = config.getAppId();
if (appId.equals(targetAppId)) {// app self's configs
defaultClusterConfigs.add(config);
} else {// override other app configs
if (appIdMapOverrideAppConfig == null) {
appIdMapOverrideAppConfig = new HashMap<>();
}
AppConfigVO.OverrideAppConfig overrideAppConfig =
appIdMapOverrideAppConfig.get(targetAppId);
if (overrideAppConfig == null) {
overrideAppConfig = new AppConfigVO.OverrideAppConfig();
appIdMapOverrideAppConfig.put(targetAppId, overrideAppConfig);
overrideAppConfigs.add(overrideAppConfig);
}
overrideAppConfig.setAppId(targetAppId);
overrideAppConfig.addConfig(config);
}
}
// for (ItemDTO config : clusterConfigs) {
// String targetAppId = config.getAppId();
// if (appId.equals(targetAppId)) {// app self's configs
// defaultClusterConfigs.add(config);
// } else {// override other app configs
// if (appIdMapOverrideAppConfig == null) {
// appIdMapOverrideAppConfig = new HashMap<>();
// }
//
// AppConfigVO.OverrideAppConfig overrideAppConfig =
// appIdMapOverrideAppConfig.get(targetAppId);
//
// if (overrideAppConfig == null) {
// overrideAppConfig = new AppConfigVO.OverrideAppConfig();
// appIdMapOverrideAppConfig.put(targetAppId, overrideAppConfig);
// overrideAppConfigs.add(overrideAppConfig);
// }
//
// overrideAppConfig.setAppId(targetAppId);
// overrideAppConfig.addConfig(config);
// }
// }
}
private void collectSpecialClusterConfigs(String clusterName, List<ItemDTO> clusterConfigs,
......
......@@ -187,7 +187,7 @@ public class ConfigServiceTest {
private ReleaseDTO assembleReleaseSnapShot(long releaseId, String clusterName,
String configurations) {
ReleaseDTO releaseSnapShot = new ReleaseDTO();
releaseSnapShot.setReleaseId(releaseId);
// releaseSnapShot.setReleaseId(releaseId);
releaseSnapShot.setClusterName(clusterName);
releaseSnapShot.setConfigurations(configurations);
return releaseSnapShot;
......@@ -221,9 +221,9 @@ public class ConfigServiceTest {
private ItemDTO assembleConfigItem(long clusterId, String clusterName, String appId,
String key, String value) {
ItemDTO configItem = new ItemDTO();
configItem.setClusterName(clusterName);
configItem.setClusterId(clusterId);
configItem.setAppId(appId);
// configItem.setClusterName(clusterName);
// configItem.setClusterId(clusterId);
// configItem.setAppId(appId);
configItem.setKey(key);
configItem.setValue(value);
return configItem;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment