Support organizing gateway group by service

This commit is contained in:
hongqiaowei
2021-09-30 15:23:06 +08:00
parent a95415346b
commit 2916ffc7d5
2 changed files with 4 additions and 45 deletions

View File

@@ -51,8 +51,8 @@ public class GatewayGroup {
public void setGateways(String gateways) {
if (StringUtils.isNotBlank(gateways)) {
Arrays.stream(StringUtils.split(gateways, ',')).forEach(
ip -> {
this.gateways.add(ip.trim());
gw -> {
this.gateways.add(gw.trim());
}
);
}

View File

@@ -33,9 +33,6 @@ import java.util.Set;
public class GatewayGroup2apiConfig {
// private static final Logger log = LoggerFactory.getLogger(GatewayGroup2apiConfig.class);
// private Map<String/*gg*/, Map<String/*a*/, ApiConfig>> configMap = new HashMap<>(8);
private Map<String/*gg*/, Set<ApiConfig>> configMap = new HashMap<>(8);
@JsonProperty(value = "configs", access = JsonProperty.Access.READ_ONLY)
@@ -43,24 +40,11 @@ public class GatewayGroup2apiConfig {
return configMap;
}
// public void setConfigMap(Map<String, Map<String, ApiConfig>> configMap) {
// this.configMap = configMap;
// }
public void add(ApiConfig ac) {
for (String gg : ac.gatewayGroups) {
// Map<String, ApiConfig> app2apiConfigMap = configMap.get(gg);
// if (app2apiConfigMap == null) {
// app2apiConfigMap = new HashMap<>();
// configMap.put(gg, app2apiConfigMap);
// }
// for (String a : ac.apps) {
// app2apiConfigMap.put(a, ac);
// log.info("expose " + ac + " to " + gg + " group and " + a + " app");
// }
Set<ApiConfig> acs = configMap.get(gg);
if (acs == null) {
acs = new HashSet<>(6);
acs = new HashSet<>(8);
configMap.put(gg, acs);
}
acs.add(ac);
@@ -69,13 +53,6 @@ public class GatewayGroup2apiConfig {
public void remove(ApiConfig ac) {
for (String gg : ac.gatewayGroups) {
// Map<String, ApiConfig> app2apiConfigMap = configMap.get(gg);
// if (app2apiConfigMap != null) {
// for (String a : ac.apps) {
// ApiConfig r = app2apiConfigMap.remove(a);
// log.info("remove " + r + " from " + gg + " group and " + a + " app");
// }
// }
Set<ApiConfig> acs = configMap.get(gg);
if (acs != null) {
acs.remove(ac);
@@ -88,33 +65,15 @@ public class GatewayGroup2apiConfig {
public void update(ApiConfig ac) {
for (String gg : ac.gatewayGroups) {
// Map<String, ApiConfig> app2apiConfigMap = configMap.get(gg);
// if (app2apiConfigMap == null) {
// app2apiConfigMap = new HashMap<>();
// configMap.put(gg, app2apiConfigMap);
// }
// for (String a : ac.apps) {
// ApiConfig old = app2apiConfigMap.put(a, ac);
// log.info(gg + " group and " + a + " app update " + old + " with " + ac);
// }
Set<ApiConfig> acs = configMap.get(gg);
if (acs == null) {
acs = new HashSet<>(6);
acs = new HashSet<>(8);
configMap.put(gg, acs);
}
acs.add(ac);
}
}
// public ApiConfig get(String gatewayGroup, String app) {
// Map<String, ApiConfig> app2apiConfigMap = configMap.get(gatewayGroup);
// if (app2apiConfigMap == null) {
// return null;
// } else {
// return app2apiConfigMap.get(app);
// }
// }
public Set<ApiConfig> get(String gatewayGroup) {
return configMap.get(gatewayGroup);
}