new feature for 2.7 & bug fix metadata
authornzomkxia <z82507200@gmail.com>
Mon, 24 Dec 2018 09:45:46 +0000 (17:45 +0800)
committernzomkxia <z82507200@gmail.com>
Mon, 24 Dec 2018 09:45:46 +0000 (17:45 +0800)
19 files changed:
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/util/Constants.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/util/OverrideUtils.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/common/util/RouteRule.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/LoadBalanceController.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/controller/TagRoutesController.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/dto/DynamicConfigDTO.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/dto/TagRouteDTO.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/OverrideDTO.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/RoutingRule.java [moved from dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/RoutingRuleDTO.java with 98% similarity]
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/TagRoute.java [new file with mode: 0644]
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/service/RouteService.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/service/impl/OverrideServiceImpl.java
dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/service/impl/RouteServiceImpl.java
dubbo-admin-frontend/src/components/governance/AccessControl.vue
dubbo-admin-frontend/src/components/governance/LoadBalance.vue
dubbo-admin-frontend/src/components/governance/Overrides.vue
dubbo-admin-frontend/src/components/governance/RoutingRule.vue
dubbo-admin-frontend/src/components/governance/TagRule.vue
dubbo-admin-frontend/src/components/governance/WeightAdjust.vue

index b429ca64bb8886bf4ffdd380043bbafa0afa7b10..6d54b0a5cc3d82073b87e3415f77e7ccb65a0fc5 100644 (file)
@@ -29,6 +29,8 @@ public class Constants {
     public static final String PATH_SEPARATOR = "/";
     public static final String GROUP_KEY = "group";
     public static final String CONFIG_KEY = "config";
+    public static final String PROVIDER_SIDE = "provider";
+    public static final String CONSUMER_SIDE = "consumer";
     public static final String CATEGORY_KEY = "category";
     public static final String ROUTERS_CATEGORY = "routers";
     public static final String CONDITION_ROUTE = "condition_route";
index dccf1b935202320a8bc9e8eb286382bb201c1b1a..cdad8365c393d3132bd018bbfc5f0f901e3492fb 100644 (file)
@@ -60,11 +60,12 @@ public class OverrideUtils {
 
     public static OverrideConfig weightDTOtoConfig(WeightDTO weightDTO) {
         OverrideConfig overrideConfig = new OverrideConfig();
-        overrideConfig.setType("weight");
+        overrideConfig.setType(Constants.WEIGHT);
         overrideConfig.setEnabled(true);
+        overrideConfig.setSide(Constants.PROVIDER_SIDE);
         overrideConfig.setAddresses(weightDTO.getAddresses());
         Map<String, Object> parameters = new HashMap<>();
-        parameters.put("weight", weightDTO.getWeight());
+        parameters.put(Constants.WEIGHT, weightDTO.getWeight());
         overrideConfig.setParameters(parameters);
         return overrideConfig;
     }
@@ -87,7 +88,6 @@ public class OverrideUtils {
         } else {
             dynamicConfigDTO.setService(overrideDTO.getKey());
         }
-        dynamicConfigDTO.setRuntime(overrideDTO.isRuntime());
         dynamicConfigDTO.setEnabled(overrideDTO.isEnabled());
         return dynamicConfigDTO;
     }
@@ -109,6 +109,7 @@ public class OverrideUtils {
         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());
index 6ff7b61fb104297edaff204d1af29024b27f3d33..7c48e1438f4aaa0080cf9417fb0e985936387df4 100644 (file)
@@ -19,8 +19,10 @@ package org.apache.dubbo.admin.common.util;
 import org.apache.dubbo.admin.model.domain.Route;
 import org.apache.dubbo.admin.model.dto.AccessDTO;
 import org.apache.dubbo.admin.model.dto.ConditionRouteDTO;
+import org.apache.dubbo.admin.model.dto.TagRouteDTO;
 import org.apache.dubbo.admin.model.store.BlackWhiteList;
-import org.apache.dubbo.admin.model.store.RoutingRuleDTO;
+import org.apache.dubbo.admin.model.store.RoutingRule;
+import org.apache.dubbo.admin.model.store.TagRoute;
 import org.apache.dubbo.common.utils.StringUtils;
 
 import java.text.ParseException;
@@ -193,9 +195,31 @@ public class RouteRule {
         }
     }
 
-    public static RoutingRuleDTO insertConditionRule(RoutingRuleDTO existRule, ConditionRouteDTO conditionRoute) {
+    public static TagRoute convertTagroutetoStore(TagRouteDTO tagRoute) {
+        TagRoute store = new TagRoute();
+        store.setKey(tagRoute.getApplication());
+        store.setEnabled(tagRoute.isEnabled());
+        store.setForce(tagRoute.isForce());
+        store.setPriority(tagRoute.getPriority());
+        store.setRuntime(tagRoute.isRuntime());
+        store.setTags(tagRoute.getTags());
+        return store;
+    }
+
+    public static TagRouteDTO convertTagroutetoDisplay(TagRoute tagRoute) {
+        TagRouteDTO tagRouteDTO = new TagRouteDTO();
+        tagRouteDTO.setApplication(tagRoute.getKey());
+        tagRouteDTO.setRuntime(tagRoute.isRuntime());
+        tagRouteDTO.setPriority(tagRoute.getPriority());
+        tagRouteDTO.setTags(tagRoute.getTags());
+        tagRouteDTO.setForce(tagRoute.isForce());
+        tagRouteDTO.setEnabled(tagRoute.isEnabled());
+        return tagRouteDTO;
+    }
+
+    public static RoutingRule insertConditionRule(RoutingRule existRule, ConditionRouteDTO conditionRoute) {
         if (existRule == null) {
-            existRule = new RoutingRuleDTO();
+            existRule = new RoutingRule();
             if (StringUtils.isNotEmpty(conditionRoute.getApplication())) {
                 existRule.setKey(conditionRoute.getApplication());
                 existRule.setScope(Constants.APPLICATION);
@@ -299,18 +323,18 @@ public class RouteRule {
         return route;
     }
 
-    public static ConditionRouteDTO createConditionRouteFromRule(RoutingRuleDTO routingRuleDTO) {
+    public static ConditionRouteDTO createConditionRouteFromRule(RoutingRule routingRule) {
         ConditionRouteDTO conditionRouteDTO = new ConditionRouteDTO();
-        if (routingRuleDTO.getScope().equals(Constants.SERVICE)) {
-            conditionRouteDTO.setService(routingRuleDTO.getKey());
+        if (routingRule.getScope().equals(Constants.SERVICE)) {
+            conditionRouteDTO.setService(routingRule.getKey());
         } else {
-            conditionRouteDTO.setApplication(routingRuleDTO.getKey());
+            conditionRouteDTO.setApplication(routingRule.getKey());
         }
-        conditionRouteDTO.setConditions(routingRuleDTO.getConditions());
-        conditionRouteDTO.setPriority(routingRuleDTO.getPriority());
-        conditionRouteDTO.setEnabled(routingRuleDTO.isEnabled());
-        conditionRouteDTO.setForce(routingRuleDTO.isForce());
-        conditionRouteDTO.setRuntime(routingRuleDTO.isRuntime());
+        conditionRouteDTO.setConditions(routingRule.getConditions());
+        conditionRouteDTO.setPriority(routingRule.getPriority());
+        conditionRouteDTO.setEnabled(routingRule.isEnabled());
+        conditionRouteDTO.setForce(routingRule.isForce());
+        conditionRouteDTO.setRuntime(routingRule.isRuntime());
         return conditionRouteDTO;
     }
 
index 146b6042a57c79577f8fa81c0eaba36722126f2e..3d1221eef8958816acd9a595c38212b0035fda84 100644 (file)
@@ -70,17 +70,7 @@ public class LoadBalanceController {
         if (balancing == null) {
             throw new ResourceNotFoundException("Unknown ID!");
         }
-//        Override override = overrideService.findById(id);
-//        if (override == null) {
-//            throw new ResourceNotFoundException("Unknown ID!");
-//        }
-//        LoadBalance old = overrideToLoadBalance(override);
-//        LoadBalance loadBalance = new LoadBalance();
-//        loadBalance.setStrategy(balancingDTO.getStrategy());
-//        loadBalance.setMethod(formatMethodName(balancingDTO.getMethodName()));
-//        loadBalance.setService(old.getService());
-//        loadBalance.setHash(id);
-//        overrideService.updateOverride(OverrideUtils.loadBalanceToOverride(loadBalance));
+
         overrideService.saveBalance(balancingDTO);
         return true;
     }
index 25522eb330f2f71b991adee3f47a709a8147b4d2..40b81bf4ebabb4f54730a56e054889991e131ec8 100644 (file)
@@ -93,7 +93,6 @@ public class TagRoutesController {
             tagRoute = routeService.findTagRoute(application);
         }
         if (tagRoute != null) {
-            tagRoute = convertTagrouteToDisplay(tagRoute);
             result.add(tagRoute);
         }
         return result;
@@ -106,8 +105,7 @@ public class TagRoutesController {
         if (tagRoute == null) {
             throw new ResourceNotFoundException("Unknown ID!");
         }
-        TagRouteDTO tagRouteDTO = convertTagrouteToDisplay(tagRoute);
-        return tagRouteDTO;
+        return tagRoute;
     }
 
     @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
@@ -130,12 +128,5 @@ public class TagRoutesController {
         routeService.disableTagRoute(id);
         return true;
     }
-
-    private TagRouteDTO convertTagrouteToDisplay(TagRouteDTO tagRouteDTO) {
-        tagRouteDTO.setApplication(tagRouteDTO.getKey());
-        tagRouteDTO.setScope(null);
-        tagRouteDTO.setKey(null);
-        return tagRouteDTO;
-    }
 }
 
index 6bc0719a7826a2cdaae65fd691a1b6781d929d11..9b62e8eaa855c01ea22909eeab846eefdbf9852b 100644 (file)
@@ -24,7 +24,6 @@ import java.util.List;
 public class DynamicConfigDTO extends BaseDTO {
 
     private String configVersion;
-    private boolean runtime;
     private boolean enabled;
     private List<OverrideConfig> configs;
 
@@ -44,14 +43,6 @@ public class DynamicConfigDTO extends BaseDTO {
         this.configVersion = configVersion;
     }
 
-    public boolean isRuntime() {
-        return runtime;
-    }
-
-    public void setRuntime(boolean runtime) {
-        this.runtime = runtime;
-    }
-
     public boolean isEnabled() {
         return enabled;
     }
index 85c84f1d7f6fac37124fdd07a3d7dc5232f264e6..5595572b7fce2d805b3829a6c7df269a9bd63ab2 100644 (file)
@@ -22,26 +22,8 @@ import org.apache.dubbo.admin.model.domain.Tag;
 import java.util.List;
 
 public class TagRouteDTO extends RouteDTO{
-    private String scope;
-    private String key;
     private List<Tag> tags;
 
-    public String getScope() {
-        return scope;
-    }
-
-    public void setScope(String scope) {
-        this.scope = scope;
-    }
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
-
     public List<Tag> getTags() {
         return tags;
     }
index a91781556e05db38cec05fefa126d99d656f8b73..c99854aee8de0046665bde0dfd4854a3f02a8084 100644 (file)
@@ -23,7 +23,6 @@ public class OverrideDTO {
     private String key;
     private String scope;
     private String configVersion;
-    private boolean runtime;
     private boolean enabled;
     private List<OverrideConfig> configs;
 
@@ -51,14 +50,6 @@ public class OverrideDTO {
         this.configVersion = configVersion;
     }
 
-    public boolean isRuntime() {
-        return runtime;
-    }
-
-    public void setRuntime(boolean runtime) {
-        this.runtime = runtime;
-    }
-
     public boolean isEnabled() {
         return enabled;
     }
similarity index 98%
rename from dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/RoutingRuleDTO.java
rename to dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/RoutingRule.java
index 70ba2acfc9fcc083424e0c6aad7ebe948d2125c9..46b012f491b1d10b5e7609f1a69d90de49d41a8f 100644 (file)
@@ -19,7 +19,7 @@ package org.apache.dubbo.admin.model.store;
 
 import java.util.List;
 
-public class RoutingRuleDTO {
+public class RoutingRule {
 
     private String key;
     private String scope;
diff --git a/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/TagRoute.java b/dubbo-admin-backend/src/main/java/org/apache/dubbo/admin/model/store/TagRoute.java
new file mode 100644 (file)
index 0000000..968a518
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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.store;
+
+import org.apache.dubbo.admin.model.domain.Tag;
+
+import java.util.List;
+
+public class TagRoute {
+    private int priority;
+    private boolean enabled;
+    private boolean force;
+    private boolean runtime;
+    private String key;
+    private List<Tag> tags;
+
+    public int getPriority() {
+        return priority;
+    }
+
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean enabled) {
+        this.enabled = enabled;
+    }
+
+    public boolean isForce() {
+        return force;
+    }
+
+    public void setForce(boolean force) {
+        this.force = force;
+    }
+
+    public boolean isRuntime() {
+        return runtime;
+    }
+
+    public void setRuntime(boolean runtime) {
+        this.runtime = runtime;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public List<Tag> getTags() {
+        return tags;
+    }
+
+    public void setTags(List<Tag> tags) {
+        this.tags = tags;
+    }
+}
index 6827103d658dbe5c2e51d64267bc1d4eddc1944b..4f5acb8cfa4f271e5d0c127c61d40f55c40c194f 100644 (file)
@@ -61,7 +61,7 @@ public interface RouteService {
     void disableTagRoute(String id);
 
 
-    TagRouteDTO findTagRoute(String serviceName);
+    TagRouteDTO findTagRoute(String id);
 
 
 }
index a7774a2c47acfb18682eae3f74c1e073e07e70aa..f69e7bbff32c8661cb7e58943f0469fe02d7f084 100644 (file)
@@ -64,7 +64,6 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
         }
         configs.addAll(override.getConfigs());
         existOverride.setEnabled(override.isEnabled());
-        existOverride.setRuntime(override.isRuntime());
         existOverride.setConfigs(configs);
         dynamicConfiguration.setConfig(path, YamlParser.dumpObject(existOverride));
 
@@ -98,7 +97,6 @@ public class OverrideServiceImpl extends AbstractService implements OverrideServ
         }
         configs.addAll(update.getConfigs());
         overrideDTO.setConfigs(configs);
-        overrideDTO.setRuntime(update.isRuntime());
         overrideDTO.setEnabled(update.isEnabled());
         dynamicConfiguration.setConfig(path, YamlParser.dumpObject(overrideDTO));
 
index 346d01dcda708015709b8b06e515932fa9074f06..f88811302dd4d2f5db5b19720af13a383c0c3b03 100644 (file)
@@ -26,13 +26,13 @@ import org.apache.dubbo.admin.model.dto.AccessDTO;
 import org.apache.dubbo.admin.model.dto.ConditionRouteDTO;
 import org.apache.dubbo.admin.model.dto.TagRouteDTO;
 import org.apache.dubbo.admin.model.store.BlackWhiteList;
-import org.apache.dubbo.admin.model.store.RoutingRuleDTO;
+import org.apache.dubbo.admin.model.store.RoutingRule;
+import org.apache.dubbo.admin.model.store.TagRoute;
 import org.apache.dubbo.admin.service.RouteService;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.common.utils.StringUtils;
 import org.springframework.stereotype.Component;
 
-import java.time.YearMonth;
 import java.util.List;
 
 /**
@@ -49,9 +49,9 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String id = ConvertUtil.getIdFromDTO(conditionRoute);
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String existConfig = dynamicConfiguration.getConfig(path);
-        RoutingRuleDTO existRule = null;
+        RoutingRule existRule = null;
         if (existConfig != null) {
-            existRule = YamlParser.loadObject(existConfig, RoutingRuleDTO.class);
+            existRule = YamlParser.loadObject(existConfig, RoutingRule.class);
         }
         existRule = RouteRule.insertConditionRule(existRule, conditionRoute);
         //register2.7
@@ -73,10 +73,10 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         if (existConfig == null) {
             throw new ResourceNotFoundException("no existing condition route for path: " + path);
         }
-        RoutingRuleDTO routingRuleDTO = YamlParser.loadObject(existConfig, RoutingRuleDTO.class);
-        ConditionRouteDTO oldConditionRoute = RouteRule.createConditionRouteFromRule(routingRuleDTO);
-        routingRuleDTO = RouteRule.insertConditionRule(routingRuleDTO, newConditionRoute);
-        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(routingRuleDTO));
+        RoutingRule routingRule = YamlParser.loadObject(existConfig, RoutingRule.class);
+        ConditionRouteDTO oldConditionRoute = RouteRule.createConditionRouteFromRule(routingRule);
+        routingRule = RouteRule.insertConditionRule(routingRule, newConditionRoute);
+        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(routingRule));
 
         //for 2.6
         if (StringUtils.isNotEmpty(newConditionRoute.getService())) {
@@ -97,7 +97,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         if (config == null) {
             //throw exception
         }
-        RoutingRuleDTO route = YamlParser.loadObject(config, RoutingRuleDTO.class);
+        RoutingRule route = YamlParser.loadObject(config, RoutingRule.class);
         if (route.getBlackWhiteList() != null) {
            route.setConditions(null);
             dynamicConfiguration.setConfig(path, YamlParser.dumpObject(route));
@@ -107,7 +107,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
 
         //for 2.6
         if (route.getScope().equals(Constants.SERVICE)) {
-            RoutingRuleDTO originRule = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule originRule = YamlParser.loadObject(config, RoutingRule.class);
             ConditionRouteDTO conditionRouteDTO = RouteRule.createConditionRouteFromRule(originRule);
             Route old = convertRouteToOldRoute(conditionRouteDTO);
             registry.unregister(old.toUrl().addParameter(Constants.COMPATIBLE_CONFIG, true));
@@ -119,7 +119,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO ruleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule ruleDTO = YamlParser.loadObject(config, RoutingRule.class);
             BlackWhiteList old = ruleDTO.getBlackWhiteList();
             if (ruleDTO.getConditions() == null) {
                 dynamicConfiguration.deleteConfig(path);
@@ -141,9 +141,9 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         BlackWhiteList blackWhiteList = RouteRule.convertToBlackWhiteList(accessDTO);
-        RoutingRuleDTO ruleDTO;
+        RoutingRule ruleDTO;
         if (config == null) {
-            ruleDTO = new RoutingRuleDTO();
+            ruleDTO = new RoutingRule();
             ruleDTO.setEnabled(true);
             if (StringUtils.isNoneEmpty(accessDTO.getApplication())) {
                 ruleDTO.setScope(Constants.APPLICATION);
@@ -153,7 +153,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
             ruleDTO.setKey(id);
             ruleDTO.setBlackWhiteList(blackWhiteList);
         } else {
-            ruleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            ruleDTO = YamlParser.loadObject(config, RoutingRule.class);
             if (ruleDTO.getBlackWhiteList() != null) {
                 //todo throw exception
             }
@@ -174,7 +174,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO ruleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule ruleDTO = YamlParser.loadObject(config, RoutingRule.class);
             BlackWhiteList blackWhiteList = ruleDTO.getBlackWhiteList();
             return RouteRule.convertToAccessDTO(blackWhiteList, ruleDTO.getScope(), ruleDTO.getKey());
         }
@@ -189,7 +189,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         BlackWhiteList old = null;
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO ruleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule ruleDTO = YamlParser.loadObject(config, RoutingRule.class);
             old = ruleDTO.getBlackWhiteList();
             ruleDTO.setBlackWhiteList(blackWhiteList);
             dynamicConfiguration.setConfig(path, YamlParser.dumpObject(ruleDTO));
@@ -209,7 +209,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO ruleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule ruleDTO = YamlParser.loadObject(config, RoutingRule.class);
 
             if (ruleDTO.getScope().equals(Constants.SERVICE)) {
                 //for2.6
@@ -231,7 +231,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(serviceName, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO routeRule = YamlParser.loadObject(config, RoutingRuleDTO.class);
+            RoutingRule routeRule = YamlParser.loadObject(config, RoutingRule.class);
 
             if (routeRule.getScope().equals(Constants.SERVICE)) {
                 //for 2.6
@@ -253,8 +253,8 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.CONDITION_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            RoutingRuleDTO routingRuleDTO = YamlParser.loadObject(config, RoutingRuleDTO.class);
-            ConditionRouteDTO conditionRouteDTO = RouteRule.createConditionRouteFromRule(routingRuleDTO);
+            RoutingRule routingRule = YamlParser.loadObject(config, RoutingRule.class);
+            ConditionRouteDTO conditionRouteDTO = RouteRule.createConditionRouteFromRule(routingRule);
             return conditionRouteDTO;
         }
         return null;
@@ -264,7 +264,8 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
     public void createTagRoute(TagRouteDTO tagRoute) {
         String id = ConvertUtil.getIdFromDTO(tagRoute);
         String path = getPath(id,Constants.TAG_ROUTE);
-        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(tagRoute));
+        TagRoute store = RouteRule.convertTagroutetoStore(tagRoute);
+        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(store));
     }
 
     @Override
@@ -275,7 +276,8 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
             throw new ResourceNotFoundException("can not find tagroute: " + id);
             //throw exception
         }
-        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(tagRoute));
+        TagRoute store = RouteRule.convertTagroutetoStore(tagRoute);
+        dynamicConfiguration.setConfig(path, YamlParser.dumpObject(store));
 
     }
 
@@ -290,7 +292,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.TAG_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            TagRouteDTO tagRoute = YamlParser.loadObject(config, TagRouteDTO.class);
+            TagRoute tagRoute = YamlParser.loadObject(config, TagRoute.class);
             tagRoute.setEnabled(true);
             dynamicConfiguration.setConfig(path, YamlParser.dumpObject(tagRoute));
         }
@@ -302,7 +304,7 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.TAG_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            TagRouteDTO tagRoute = YamlParser.loadObject(config, TagRouteDTO.class);
+            TagRoute tagRoute = YamlParser.loadObject(config, TagRoute.class);
             tagRoute.setEnabled(false);
             dynamicConfiguration.setConfig(path, YamlParser.dumpObject(tagRoute));
         }
@@ -314,7 +316,8 @@ public class RouteServiceImpl extends AbstractService implements RouteService {
         String path = getPath(id, Constants.TAG_ROUTE);
         String config = dynamicConfiguration.getConfig(path);
         if (config != null) {
-            return YamlParser.loadObject(config, TagRouteDTO.class);
+            TagRoute tagRoute = YamlParser.loadObject(config, TagRoute.class);
+            return RouteRule.convertTagroutetoDisplay(tagRoute);
         }
         return null;
     }
index 5e5397cc378a46da743837ada09c21335a142c0c..bfbb274d54821b8c7210433bf7f19180c11211c5 100644 (file)
@@ -263,6 +263,7 @@ export default {
   }),
   methods: {
     search () {
+      this.filter = document.querySelector('#serviceSearch').value.trim()
       if (!this.filter) {
         return
       }
index 4d62e77a88d8db553bb3ae39e8d9722550eca903..650cc8f36f7bea99f35ed101e347adf3a03bbcaa 100644 (file)
       loadBalances: [
       ],
       template:
-        'methodName: sayHello  # * for all methods\n' +
+        'methodName: *  # * for all methods\n' +
         'strategy:  # leastactive, random, roundrobin',
       ruleText: '',
       readonly: false,
     }),
     methods: {
       submit: function () {
+        this.filter = document.querySelector('#serviceSearch').value.trim()
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
index 9da0b7f42cbe576a1ca7610bddb679f9a82ec72f..89c9aa4bd6e4f0fa432001d79ff2cbf6f94e954f 100644 (file)
 
         'configVersion: v2.7\n' +
         'enabled: true\n' +
-        'runtime: true\n' +
         'configs: \n' +
         '  - addresses: [0.0.0.0]  # 0.0.0.0 for all addresses\n' +
         '    side: consumer        # effective side, consumer or addresses\n' +
     }),
     methods: {
       submit: function () {
+        this.filter = document.querySelector('#serviceSearch').value.trim()
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
         delete config.service
         delete config.application
         delete config.id
+        for (let i = 0; i < config.configs.length; i++) {
+          delete config.configs[i].enabled
+        }
         this.removeEmpty(config)
         this.ruleText = yaml.safeDump(config)
         this.readonly = readonly
index 9ca652a71efccffd6982570f6e88b67501f9016f..d87ae45123bb2f14014fdc2bf125733d7a5d175a 100644 (file)
@@ -72,7 +72,6 @@
             <template slot="items" slot-scope="props">
               <td class="text-xs-left">{{ props.item.service }}</td>
               <td class="text-xs-left">{{ props.item.group }}</td>
-              <td class="text-xs-left">{{ props.item.priority }}</td>
               <td class="text-xs-left">{{ props.item.enabled }}</td>
               <td class="text-xs-center px-0">
                 <v-tooltip bottom v-for="op in operations" :key="op.id">
@@ -94,7 +93,6 @@
           >
             <template slot="items" slot-scope="props">
               <td class="text-xs-left">{{ props.item.application }}</td>
-              <td class="text-xs-left">{{ props.item.priority }}</td>
               <td class="text-xs-left">{{ props.item.enabled }}</td>
               <td class="text-xs-center px-0">
                 <v-tooltip bottom v-for="op in operations" :key="op.id">
       ],
       selected: 0,
       dropdown_font: [ 'Service', 'App', 'IP' ],
-      ruleKeys: ['enabled', 'force', 'runtime', 'group', 'version', 'rule', 'priority'],
+      ruleKeys: ['enabled', 'force', 'runtime', 'group', 'version', 'rule'],
       pattern: 'Service',
       filter: '',
       dialog: false,
       ],
       template:
         'enabled: true\n' +
-        'priority: 100\n' +
         'runtime: false\n' +
         'force: true\n' +
         'conditions:\n' +
           value: 'application',
           align: 'left'
         },
-        {
-          text: 'Priority',
-          value: 'priority',
-          sortable: false
-        },
         {
           text: 'Enabled',
           value: 'enabled',
           align: 'left'
 
         },
-        {
-          text: 'Priority',
-          value: 'priority',
-          sortable: false
-        },
         {
           text: 'Enabled',
           value: 'enabled',
     }),
     methods: {
       submit: function () {
+        this.filter = document.querySelector('#serviceSearch').value.trim()
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
         delete conditionRoute.app
         delete conditionRoute.group
         delete conditionRoute.application
+        delete conditionRoute.priority
         this.ruleText = yaml.safeDump(conditionRoute)
         this.readonly = readonly
         this.dialog = true
index dce9724fdfb5fed14ec069ec9c95248fe571734e..17b3bb27af3ae76f6b517e5b72737dd8908397bc 100644 (file)
@@ -19,7 +19,7 @@
   <v-container grid-list-xl fluid >
     <v-layout row wrap>
       <v-flex xs12 >
-        <search v-model="filter" :submit="submit" label="Search Routing Rule by service name"></search>
+        <search id="serviceSearch" v-model="filter" :submit="submit" label="Search Routing Rule by application name"></search>
       </v-flex>
     </v-layout>
     <v-flex lg12>
@@ -39,7 +39,6 @@
           >
             <template slot="items" slot-scope="props">
               <td class="text-xs-left">{{ props.item.application }}</td>
-              <td class="text-xs-left">{{ props.item.priority }}</td>
               <td class="text-xs-left">{{ props.item.enabled }}</td>
               <td class="text-xs-center px-0">
                 <v-tooltip bottom v-for="op in operations" :key="op.id">
     },
     data: () => ({
       dropdown_font: [ 'Service', 'App', 'IP' ],
-      ruleKeys: ['enabled', 'force', 'dynamic', 'runtime', 'group', 'version', 'rule', 'priority'],
+      ruleKeys: ['enabled', 'force', 'dynamic', 'runtime', 'group', 'version', 'rule'],
       pattern: 'Service',
       filter: '',
       dialog: false,
         'force: false\n' +
         'enabled: true\n' +
         'runtime: false\n' +
-        'priority: 100\n' +
         'tags:\n' +
         ' - name: tag1\n' +
         '   addresses: [192.168.0.1:20881]\n' +
           value: 'application',
           align: 'left'
         },
-        {
-          text: 'Priority',
-          value: 'priority',
-          sortable: false
-        },
         {
           text: 'Enabled',
           value: 'enabled',
     }),
     methods: {
       submit: function () {
+        this.filter = document.querySelector('#serviceSearch').value.trim()
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {
           case 'visibility':
             this.$axios.get('/rules/route/tag/' + itemId)
               .then(response => {
-                let conditionRoute = response.data
-                this.handleBalance(conditionRoute, true)
+                let tagRoute = response.data
+                this.handleBalance(tagRoute, true)
                 this.updateId = 'close'
               })
             break
         delete tagRoute.app
         delete tagRoute.group
         delete tagRoute.application
+        delete tagRoute.service
+        delete tagRoute.priority
         this.ruleText = yaml.safeDump(tagRoute)
         this.readonly = readonly
         this.dialog = true
index 7cd057b7531eb948111410c9143f48ba6f02f377..433ba02e2354ec32b8f548288efe7bfc7b3f8690 100644 (file)
     }),
     methods: {
       submit: function () {
+        this.filter = document.querySelector('#serviceSearch').value.trim()
         this.search(this.filter, true)
       },
       search: function (filter, rewrite) {