You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by mi...@apache.org on 2019/02/18 06:27:18 UTC
[incubator-dubbo-ops] branch develop updated: Cleanup (#304)
This is an automated email from the ASF dual-hosted git repository.
min pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/incubator-dubbo-ops.git
The following commit(s) were added to refs/heads/develop by this push:
new 9f7aeea Cleanup (#304)
9f7aeea is described below
commit 9f7aeea62c9faa313802ec8c68f5bbc161bdb811
Author: kezhenxu94 <ke...@163.com>
AuthorDate: Mon Feb 18 14:27:13 2019 +0800
Cleanup (#304)
* replace local constants with global constants
* remove unnecessary declarations
* create adapter for util method
* remove unused imports
* remove unnecessary code. issue #307
---
.../apache/dubbo/admin/DubboAdminApplication.java | 5 +-
.../dubbo/admin/common/util/OverrideUtils.java | 137 ---------------------
.../apache/dubbo/admin/config/ConfigCenter.java | 4 +-
.../dubbo/admin/controller/AccessesController.java | 5 +-
.../admin/controller/LoadBalanceController.java | 6 -
.../BalancingDTO2OverrideConfigAdapter.java | 38 ++++++
.../DynamicConfigDTO2OverrideDTOAdapter.java | 36 ++++++
.../adapter/LoadBalance2OverrideAdapter.java} | 69 ++++++-----
.../adapter/WeightToOverrideAdapter.java} | 63 +++++-----
.../admin/service/impl/GenericServiceImpl.java | 6 -
.../admin/service/impl/OverrideServiceImpl.java | 31 ++---
11 files changed, 163 insertions(+), 237 deletions(-)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
index 11be510..e12b0ca 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
@@ -19,14 +19,11 @@ package org.apache.dubbo.admin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ApplicationContext;
@SpringBootApplication
public class DubboAdminApplication {
public static void main(String[] args) {
- ApplicationContext act = SpringApplication.run(DubboAdminApplication.class, args);
-
-
+ SpringApplication.run(DubboAdminApplication.class, args);
}
}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/OverrideUtils.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/OverrideUtils.java
index fb18d56..5ca8d9f 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/OverrideUtils.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/common/util/OverrideUtils.java
@@ -16,18 +16,13 @@
*/
package org.apache.dubbo.admin.common.util;
-import org.apache.dubbo.admin.model.domain.LoadBalance;
-import org.apache.dubbo.admin.model.domain.Override;
-import org.apache.dubbo.admin.model.domain.Weight;
import org.apache.dubbo.admin.model.dto.BalancingDTO;
import org.apache.dubbo.admin.model.dto.DynamicConfigDTO;
import org.apache.dubbo.admin.model.dto.WeightDTO;
import org.apache.dubbo.admin.model.store.OverrideConfig;
import org.apache.dubbo.admin.model.store.OverrideDTO;
-import org.apache.dubbo.common.utils.StringUtils;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -37,32 +32,6 @@ import java.util.Map;
*
*/
public class OverrideUtils {
- public static List<Weight> overridesToWeights(List<Override> overrides) {
- List<Weight> weights = new ArrayList<Weight>();
- if (overrides == null) {
- return weights;
- }
- for (Override o : overrides) {
- if (StringUtils.isEmpty(o.getParams())) {
- continue;
- } else {
- Map<String, String> params = StringUtils.parseQueryString(o.getParams());
- for (Map.Entry<String, String> entry : params.entrySet()) {
- if (entry.getKey().equals("weight")) {
- Weight weight = new Weight();
- weight.setAddress(o.getAddress());
- weight.setId(o.getId());
- weight.setHash(o.getHash());
- weight.setService(o.getService());
- weight.setWeight(Integer.valueOf(entry.getValue()));
- weights.add(weight);
- }
- }
- }
- }
- return weights;
- }
-
public static OverrideConfig weightDTOtoConfig(WeightDTO weightDTO) {
OverrideConfig overrideConfig = new OverrideConfig();
overrideConfig.setType(Constants.WEIGHT);
@@ -96,34 +65,6 @@ public class OverrideUtils {
dynamicConfigDTO.setEnabled(overrideDTO.isEnabled());
return dynamicConfigDTO;
}
- public static OverrideDTO createFromDynamicConfig(DynamicConfigDTO dynamicConfigDTO) {
- OverrideDTO overrideDTO = new OverrideDTO();
- if (StringUtils.isNotEmpty(dynamicConfigDTO.getApplication())) {
- overrideDTO.setScope(Constants.APPLICATION);
- overrideDTO.setKey(dynamicConfigDTO.getApplication());
- } else {
- overrideDTO.setScope(Constants.SERVICE);
- overrideDTO.setKey(dynamicConfigDTO.getService());
- }
- overrideDTO.setConfigVersion(dynamicConfigDTO.getConfigVersion());
- overrideDTO.setConfigs(dynamicConfigDTO.getConfigs());
- return overrideDTO;
- }
-
- public static OverrideConfig balanceDTOtoConfig(BalancingDTO balancingDTO) {
- OverrideConfig overrideConfig = new OverrideConfig();
- overrideConfig.setType(Constants.BALANCING);
- overrideConfig.setEnabled(true);
- overrideConfig.setSide(Constants.CONSUMER_SIDE);
- Map<String, Object> parameters = new HashMap<>();
- if (balancingDTO.getMethodName().equals("*")) {
- parameters.put("loadbalance", balancingDTO.getStrategy());
- } else {
- parameters.put(balancingDTO.getMethodName() + ".loadbalance", balancingDTO.getStrategy());
- }
- overrideConfig.setParameters(parameters);
- return overrideConfig;
- }
public static WeightDTO configtoWeightDTO(OverrideConfig config, String scope, String key) {
WeightDTO weightDTO = new WeightDTO();
@@ -157,82 +98,4 @@ public class OverrideUtils {
}
return balancingDTO;
}
-
- public static Weight overrideToWeight(Override override) {
- List<Weight> weights = OverrideUtils.overridesToWeights(Arrays.asList(override));
- if (weights != null && weights.size() > 0) {
- return overridesToWeights(Arrays.asList(override)).get(0);
- }
- return null;
- }
-
- public static Override weightToOverride(Weight weight) {
- Override override = new Override();
- override.setId(weight.getId());
- override.setHash(weight.getHash());
- override.setAddress(weight.getAddress());
- override.setEnabled(true);
- override.setParams("weight=" + weight.getWeight());
- override.setService(weight.getService());
- return override;
- }
-
- public static List<LoadBalance> overridesToLoadBalances(List<Override> overrides) {
- List<LoadBalance> loadBalances = new ArrayList<>();
- if (overrides == null) {
- return loadBalances;
- }
- for (Override o : overrides) {
- if (StringUtils.isEmpty(o.getParams())) {
- continue;
- } else {
- Map<String, String> params = StringUtils.parseQueryString(o.getParams());
- for (Map.Entry<String, String> entry : params.entrySet()) {
- if (entry.getKey().endsWith("loadbalance")) {
- LoadBalance loadBalance = new LoadBalance();
- String method = null;
- if (entry.getKey().endsWith(".loadbalance")) {
- method = entry.getKey().split(".loadbalance")[0];
- } else {
- method = "*";
- }
-
- loadBalance.setMethod(method);
- loadBalance.setId(o.getId());
- loadBalance.setHash(o.getHash());
- loadBalance.setService(o.getService());
- loadBalance.setStrategy(entry.getValue());
- loadBalances.add(loadBalance);
-
- }
- }
- }
- }
- return loadBalances;
- }
-
- public static LoadBalance overrideToLoadBalance(Override override) {
- List<LoadBalance> loadBalances = OverrideUtils.overridesToLoadBalances(Arrays.asList(override));
- if (loadBalances != null && loadBalances.size() > 0) {
- return loadBalances.get(0);
- }
- return null;
- }
-
- public static Override loadBalanceToOverride(LoadBalance loadBalance) {
- Override override = new Override();
- override.setId(loadBalance.getId());
- override.setHash(loadBalance.getHash());
- override.setService(loadBalance.getService());
- override.setEnabled(true);
- String method = loadBalance.getMethod();
- String strategy = loadBalance.getStrategy();
- if (StringUtils.isEmpty(method) || method.equals("*")) {
- override.setParams("loadbalance=" + strategy);
- } else {
- override.setParams(method + ".loadbalance=" + strategy);
- }
- return override;
- }
-
}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/config/ConfigCenter.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/config/ConfigCenter.java
index 53026f2..369bb73 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/config/ConfigCenter.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/config/ConfigCenter.java
@@ -60,8 +60,6 @@ public class ConfigCenter {
@Value("${admin.config-center.password:}")
private String password;
- private static String globalConfigPath = "config/dubbo/dubbo.properties";
-
private static final Logger logger = LoggerFactory.getLogger(ConfigCenter.class);
private URL configCenterUrl;
@@ -82,7 +80,7 @@ public class ConfigCenter {
dynamicConfiguration = ExtensionLoader.getExtensionLoader(GovernanceConfiguration.class).getExtension(configCenterUrl.getProtocol());
dynamicConfiguration.setUrl(configCenterUrl);
dynamicConfiguration.init();
- String config = dynamicConfiguration.getConfig(globalConfigPath);
+ String config = dynamicConfiguration.getConfig(Constants.GLOBAL_CONFIG_PATH);
if (StringUtils.isNotEmpty(config)) {
Arrays.stream(config.split("\n")).forEach( s -> {
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/AccessesController.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/AccessesController.java
index 055b48c..3510e54 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/AccessesController.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/AccessesController.java
@@ -37,7 +37,6 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
-import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -59,7 +58,7 @@ public class AccessesController {
@RequestMapping(method = RequestMethod.GET)
public List<AccessDTO> searchAccess(@RequestParam(required = false) String service,
@RequestParam(required = false) String application,
- @PathVariable String env) throws ParseException {
+ @PathVariable String env) {
if (StringUtils.isBlank(service) && StringUtils.isBlank(application)) {
throw new ParamValidationException("Either service or application is required");
}
@@ -78,7 +77,7 @@ public class AccessesController {
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
- public AccessDTO detailAccess(@PathVariable String id, @PathVariable String env) throws ParseException {
+ public AccessDTO detailAccess(@PathVariable String id, @PathVariable String env) {
id = id.replace(Constants.ANY_VALUE, Constants.PATH_SEPARATOR);
AccessDTO accessDTO = routeService.findAccess(id);
return accessDTO;
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
index 4325731..3daad1f 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
@@ -110,12 +110,6 @@ public class LoadBalanceController {
throw new ResourceNotFoundException("Unknown ID!");
}
return balancingDTO;
-
-// LoadBalance loadBalance = OverrideUtils.overrideToLoadBalance(override);
-// BalancingDTO balancingDTO = new BalancingDTO();
-// balancingDTO.setService(loadBalance.getService());
-// balancingDTO.setMethodName(loadBalance.getMethod());
-// balancingDTO.setStrategy(loadBalance.getStrategy());
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/BalancingDTO2OverrideConfigAdapter.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/BalancingDTO2OverrideConfigAdapter.java
new file mode 100644
index 0000000..97032af
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/BalancingDTO2OverrideConfigAdapter.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.admin.model.adapter;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.dubbo.admin.common.util.Constants;
+import org.apache.dubbo.admin.model.dto.BalancingDTO;
+import org.apache.dubbo.admin.model.store.OverrideConfig;
+
+public class BalancingDTO2OverrideConfigAdapter extends OverrideConfig {
+ public BalancingDTO2OverrideConfigAdapter(BalancingDTO balancingDTO) {
+ setType(Constants.BALANCING);
+ setEnabled(true);
+ setSide(Constants.CONSUMER_SIDE);
+ Map<String, Object> parameters = new HashMap<>();
+ if (balancingDTO.getMethodName().equals("*")) {
+ parameters.put("loadbalance", balancingDTO.getStrategy());
+ } else {
+ parameters.put(balancingDTO.getMethodName() + ".loadbalance", balancingDTO.getStrategy());
+ }
+ setParameters(parameters);
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/DynamicConfigDTO2OverrideDTOAdapter.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/DynamicConfigDTO2OverrideDTOAdapter.java
new file mode 100644
index 0000000..739485a
--- /dev/null
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/DynamicConfigDTO2OverrideDTOAdapter.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.admin.model.adapter;
+
+import org.apache.dubbo.admin.common.util.Constants;
+import org.apache.dubbo.admin.model.dto.DynamicConfigDTO;
+import org.apache.dubbo.admin.model.store.OverrideDTO;
+import org.apache.dubbo.common.utils.StringUtils;
+
+public class DynamicConfigDTO2OverrideDTOAdapter extends OverrideDTO {
+ public DynamicConfigDTO2OverrideDTOAdapter(DynamicConfigDTO dynamicConfigDTO) {
+ if (StringUtils.isNotEmpty(dynamicConfigDTO.getApplication())) {
+ setScope(Constants.APPLICATION);
+ setKey(dynamicConfigDTO.getApplication());
+ } else {
+ setScope(Constants.SERVICE);
+ setKey(dynamicConfigDTO.getService());
+ }
+ setConfigVersion(dynamicConfigDTO.getConfigVersion());
+ setConfigs(dynamicConfigDTO.getConfigs());
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/LoadBalance2OverrideAdapter.java
similarity index 50%
copy from dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
copy to dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/LoadBalance2OverrideAdapter.java
index 11be510..c3e5497 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/LoadBalance2OverrideAdapter.java
@@ -1,32 +1,37 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.admin;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ApplicationContext;
-
-@SpringBootApplication
-public class DubboAdminApplication {
-
- public static void main(String[] args) {
- ApplicationContext act = SpringApplication.run(DubboAdminApplication.class, args);
-
-
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.admin.model.adapter;
+
+import org.apache.dubbo.admin.model.domain.LoadBalance;
+import org.apache.dubbo.admin.model.domain.Override;
+import org.apache.dubbo.common.utils.StringUtils;
+
+public class LoadBalance2OverrideAdapter extends Override {
+ public LoadBalance2OverrideAdapter(final LoadBalance loadBalance) {
+ setId(loadBalance.getId());
+ setHash(loadBalance.getHash());
+ setService(loadBalance.getService());
+ setEnabled(true);
+ String method = loadBalance.getMethod();
+ String strategy = loadBalance.getStrategy();
+ if (StringUtils.isEmpty(method) || method.equals("*")) {
+ setParams("loadbalance=" + strategy);
+ } else {
+ setParams(method + ".loadbalance=" + strategy);
+ }
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/WeightToOverrideAdapter.java
similarity index 62%
copy from dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
copy to dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/WeightToOverrideAdapter.java
index 11be510..64ab875 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/DubboAdminApplication.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/model/adapter/WeightToOverrideAdapter.java
@@ -1,32 +1,31 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.dubbo.admin;
-
-import org.springframework.boot.SpringApplication;
-import org.springframework.boot.autoconfigure.SpringBootApplication;
-import org.springframework.context.ApplicationContext;
-
-@SpringBootApplication
-public class DubboAdminApplication {
-
- public static void main(String[] args) {
- ApplicationContext act = SpringApplication.run(DubboAdminApplication.class, args);
-
-
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.admin.model.adapter;
+
+import org.apache.dubbo.admin.model.domain.Override;
+import org.apache.dubbo.admin.model.domain.Weight;
+
+public class WeightToOverrideAdapter extends Override {
+ public WeightToOverrideAdapter(Weight weight) {
+ setId(weight.getId());
+ setHash(weight.getHash());
+ setAddress(weight.getAddress());
+ setEnabled(true);
+ setParams("weight=" + weight.getWeight());
+ setService(weight.getService());
+ }
+}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/GenericServiceImpl.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/GenericServiceImpl.java
index d05c479..bdd00df 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/GenericServiceImpl.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/GenericServiceImpl.java
@@ -56,10 +56,4 @@ public class GenericServiceImpl {
GenericService genericService = reference.get();
return genericService.$invoke(method, parameterTypes, params);
}
-
- public static void main(String[] args) {
- GenericServiceImpl genericService = new GenericServiceImpl();
- genericService.init();
- genericService.invoke("org.apache.dubbo.demo.api.DemoService", "sayHello", new String[]{"java.lang.String"}, new Object[]{"hello"});
- }
}
diff --git a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/OverrideServiceImpl.java b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/OverrideServiceImpl.java
index f69e7bb..662de12 100644
--- a/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/OverrideServiceImpl.java
+++ b/dubbo-admin-server/src/main/java/org/apache/dubbo/admin/service/impl/OverrideServiceImpl.java
@@ -21,6 +21,10 @@ import org.apache.dubbo.admin.common.util.Constants;
import org.apache.dubbo.admin.common.util.ConvertUtil;
import org.apache.dubbo.admin.common.util.OverrideUtils;
import org.apache.dubbo.admin.common.util.YamlParser;
+import org.apache.dubbo.admin.model.adapter.BalancingDTO2OverrideConfigAdapter;
+import org.apache.dubbo.admin.model.adapter.DynamicConfigDTO2OverrideDTOAdapter;
+import org.apache.dubbo.admin.model.adapter.LoadBalance2OverrideAdapter;
+import org.apache.dubbo.admin.model.adapter.WeightToOverrideAdapter;
import org.apache.dubbo.admin.model.domain.LoadBalance;
import org.apache.dubbo.admin.model.domain.Override;
import org.apache.dubbo.admin.model.domain.Weight;
@@ -51,7 +55,7 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
String path = getPath(id);
String exitConfig = dynamicConfiguration.getConfig(path);
List<OverrideConfig> configs = new ArrayList<>();
- OverrideDTO existOverride = OverrideUtils.createFromDynamicConfig(override);
+ OverrideDTO existOverride = new DynamicConfigDTO2OverrideDTOAdapter(override);
if (exitConfig != null) {
existOverride = YamlParser.loadObject(exitConfig, OverrideDTO.class);
if (existOverride.getConfigs() != null) {
@@ -335,7 +339,7 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
String scope = ConvertUtil.getScopeFromDTO(balancingDTO);
String path = getPath(id);
String config = dynamicConfiguration.getConfig(path);
- OverrideConfig overrideConfig = OverrideUtils.balanceDTOtoConfig(balancingDTO);
+ OverrideConfig overrideConfig = new BalancingDTO2OverrideConfigAdapter(balancingDTO);
OverrideDTO overrideDTO = insertConfig(config, overrideConfig, id, scope, Constants.BALANCING);
dynamicConfiguration.setConfig(path, YamlParser.dumpObject(overrideDTO));
@@ -363,7 +367,7 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
oldBalancing = OverrideUtils.configtoBalancingDTO(overrideConfig, Constants.SERVICE, overrideDTO.getKey());
}
int index = configs.indexOf(overrideConfig);
- OverrideConfig newConfig = OverrideUtils.balanceDTOtoConfig(balancingDTO);
+ OverrideConfig newConfig = new BalancingDTO2OverrideConfigAdapter(balancingDTO);
configs.set(index, newConfig);
break;
}
@@ -521,12 +525,12 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
private void unregisterWeight(WeightDTO weightDTO) {
List<String> addresses = weightDTO.getAddresses();
if (addresses != null) {
+ Weight weight = new Weight();
+ weight.setService(weightDTO.getService());
+ weight.setWeight(weightDTO.getWeight());
for (String address : addresses) {
- Weight weight = new Weight();
- weight.setService(weightDTO.getService());
weight.setAddress(address);
- weight.setWeight(weightDTO.getWeight());
- Override override = OverrideUtils.weightToOverride(weight);
+ Override override = new WeightToOverrideAdapter(weight);
registry.unregister(override.toUrl());
}
}
@@ -535,15 +539,14 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
private void registerWeight(WeightDTO weightDTO) {
List<String> addresses = weightDTO.getAddresses();
if (addresses != null) {
+ Weight weight = new Weight();
+ weight.setService(weightDTO.getService());
+ weight.setWeight(weightDTO.getWeight());
for (String address : addresses) {
- Weight weight = new Weight();
- weight.setService(weightDTO.getService());
weight.setAddress(address);
- weight.setWeight(weightDTO.getWeight());
- Override override = OverrideUtils.weightToOverride(weight);
+ Override override = new WeightToOverrideAdapter(weight);
registry.register(override.toUrl());
}
-
}
}
@@ -552,7 +555,7 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
loadBalance.setService(balancingDTO.getService());
loadBalance.setMethod(balancingDTO.getMethodName());
loadBalance.setStrategy(balancingDTO.getStrategy());
- registry.unregister(OverrideUtils.loadBalanceToOverride(loadBalance).toUrl());
+ registry.unregister(new LoadBalance2OverrideAdapter(loadBalance).toUrl());
}
private void registerBalancing(BalancingDTO balancingDTO) {
@@ -560,7 +563,7 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
loadBalance.setService(balancingDTO.getService());
loadBalance.setMethod(balancingDTO.getMethodName());
loadBalance.setStrategy(balancingDTO.getStrategy());
- registry.register(OverrideUtils.loadBalanceToOverride(loadBalance).toUrl());
+ registry.register(new LoadBalance2OverrideAdapter(loadBalance).toUrl());
}
}