Authored by zhaoqi

Merge branch 'dev_degrade'

@@ -12,6 +12,8 @@ public class DegradeConfig { @@ -12,6 +12,8 @@ public class DegradeConfig {
12 12
13 private String configName; 13 private String configName;
14 14
  15 + private String configShowName;
  16 +
15 private String configDesc; 17 private String configDesc;
16 18
17 private Integer level; 19 private Integer level;
@@ -13,6 +13,8 @@ public class DegradeInfoReq extends PageRequest { @@ -13,6 +13,8 @@ public class DegradeInfoReq extends PageRequest {
13 13
14 private String configName; 14 private String configName;
15 15
  16 + private String configShowName;
  17 +
16 private Integer level; 18 private Integer level;
17 19
18 private String switchOn; 20 private String switchOn;
@@ -4,13 +4,14 @@ @@ -4,13 +4,14 @@
4 <resultMap id="BaseResultMap" type="com.monitor.model.domain.DegradeConfig" > 4 <resultMap id="BaseResultMap" type="com.monitor.model.domain.DegradeConfig" >
5 <id column="id" property="id" jdbcType="INTEGER" /> 5 <id column="id" property="id" jdbcType="INTEGER" />
6 <result column="config_name" property="configName" jdbcType="VARCHAR" /> 6 <result column="config_name" property="configName" jdbcType="VARCHAR" />
  7 + <result column="config_show_name" property="configShowName" jdbcType="VARCHAR" />
7 <result column="switch_on" property="switchOn" jdbcType="CHAR" /> 8 <result column="switch_on" property="switchOn" jdbcType="CHAR" />
8 <result column="config_desc" property="configDesc" jdbcType="VARCHAR" /> 9 <result column="config_desc" property="configDesc" jdbcType="VARCHAR" />
9 <result column="level" property="level" jdbcType="TINYINT" /> 10 <result column="level" property="level" jdbcType="TINYINT" />
10 <result column="img_url" property="imgUrl" jdbcType="VARCHAR" /> 11 <result column="img_url" property="imgUrl" jdbcType="VARCHAR" />
11 </resultMap> 12 </resultMap>
12 <sql id="Base_Column_List" > 13 <sql id="Base_Column_List" >
13 - id, config_name, switch_on, config_desc, level, img_url 14 + id, config_name, config_show_name, switch_on, config_desc, level, img_url
14 </sql> 15 </sql>
15 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > 16 <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
16 select 17 select
@@ -23,9 +24,6 @@ @@ -23,9 +24,6 @@
23 <include refid="Base_Column_List" /> 24 <include refid="Base_Column_List" />
24 from degrade_info 25 from degrade_info
25 where 1=1 26 where 1=1
26 - <if test="configName != null &amp;&amp; configName !='' " >  
27 - and config_name = #{configName}  
28 - </if>  
29 <if test="switchOn != null &amp;&amp; switchOn != '' " > 27 <if test="switchOn != null &amp;&amp; switchOn != '' " >
30 and switch_on = #{switchOn} 28 and switch_on = #{switchOn}
31 </if> 29 </if>
@@ -38,10 +36,10 @@ @@ -38,10 +36,10 @@
38 where id = #{id,jdbcType=INTEGER} 36 where id = #{id,jdbcType=INTEGER}
39 </delete> 37 </delete>
40 <insert id="insert" parameterType="com.monitor.model.domain.DegradeConfig" > 38 <insert id="insert" parameterType="com.monitor.model.domain.DegradeConfig" >
41 - insert into degrade_info (id, config_name, switch_on, 39 + insert into degrade_info (id, config_name, config_show_name, switch_on,
42 config_desc, level, img_url 40 config_desc, level, img_url
43 ) 41 )
44 - values (#{id,jdbcType=INTEGER}, #{configName,jdbcType=VARCHAR}, #{switchOn,jdbcType=CHAR}, 42 + values (#{id,jdbcType=INTEGER}, #{configName,jdbcType=VARCHAR}, #{configShowName,jdbcType=VARCHAR}, #{switchOn,jdbcType=CHAR},
45 #{configDesc,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT}, #{imgUrl,jdbcType=VARCHAR} 43 #{configDesc,jdbcType=VARCHAR}, #{level,jdbcType=TINYINT}, #{imgUrl,jdbcType=VARCHAR}
46 ) 44 )
47 </insert> 45 </insert>
@@ -51,6 +49,9 @@ @@ -51,6 +49,9 @@
51 <if test="configName != null" > 49 <if test="configName != null" >
52 config_name, 50 config_name,
53 </if> 51 </if>
  52 + <if test="configShowName != null" >
  53 + config_show_name,
  54 + </if>
54 <if test="switchOn != null" > 55 <if test="switchOn != null" >
55 switch_on, 56 switch_on,
56 </if> 57 </if>
@@ -68,6 +69,9 @@ @@ -68,6 +69,9 @@
68 <if test="configName != null" > 69 <if test="configName != null" >
69 #{configName,jdbcType=VARCHAR}, 70 #{configName,jdbcType=VARCHAR},
70 </if> 71 </if>
  72 + <if test="configShowName != null" >
  73 + #{configShowName,jdbcType=VARCHAR},
  74 + </if>
71 <if test="switchOn != null" > 75 <if test="switchOn != null" >
72 #{switchOn,jdbcType=CHAR}, 76 #{switchOn,jdbcType=CHAR},
73 </if> 77 </if>
@@ -85,6 +89,9 @@ @@ -85,6 +89,9 @@
85 <update id="updateByPrimaryKeySelective" parameterType="com.monitor.model.domain.DegradeConfig" > 89 <update id="updateByPrimaryKeySelective" parameterType="com.monitor.model.domain.DegradeConfig" >
86 update degrade_info 90 update degrade_info
87 <set > 91 <set >
  92 + <if test="configShowName != null" >
  93 + config_show_name = #{configShowName,jdbcType=VARCHAR},
  94 + </if>
88 <if test="switchOn != null" > 95 <if test="switchOn != null" >
89 switch_on = #{switchOn,jdbcType=CHAR}, 96 switch_on = #{switchOn,jdbcType=CHAR},
90 </if> 97 </if>
@@ -103,6 +110,7 @@ @@ -103,6 +110,7 @@
103 <update id="updateByPrimaryKey" parameterType="com.monitor.model.domain.DegradeConfig" > 110 <update id="updateByPrimaryKey" parameterType="com.monitor.model.domain.DegradeConfig" >
104 update degrade_info 111 update degrade_info
105 set config_name = #{configName,jdbcType=VARCHAR}, 112 set config_name = #{configName,jdbcType=VARCHAR},
  113 + config_show_name = #{configShowName,jdbcType=VARCHAR},
106 switch_on = #{switchOn,jdbcType=CHAR}, 114 switch_on = #{switchOn,jdbcType=CHAR},
107 config_desc = #{configDesc,jdbcType=VARCHAR}, 115 config_desc = #{configDesc,jdbcType=VARCHAR},
108 level = #{level,jdbcType=TINYINT}, 116 level = #{level,jdbcType=TINYINT},
@@ -16,6 +16,8 @@ import javax.annotation.Resource; @@ -16,6 +16,8 @@ import javax.annotation.Resource;
16 import java.util.ArrayList; 16 import java.util.ArrayList;
17 import java.util.List; 17 import java.util.List;
18 import java.util.Objects; 18 import java.util.Objects;
  19 +import java.util.regex.Matcher;
  20 +import java.util.regex.Pattern;
19 21
20 /** 22 /**
21 * Created by zhaoqi on 2016/8/26 0026. 23 * Created by zhaoqi on 2016/8/26 0026.
@@ -76,10 +78,10 @@ public class DegradeServiceImpl implements DegradeService { @@ -76,10 +78,10 @@ public class DegradeServiceImpl implements DegradeService {
76 zkTreeAllReq.setZkValue(req.getSwitchOn().equals("Y")?"true":"false"); 78 zkTreeAllReq.setZkValue(req.getSwitchOn().equals("Y")?"true":"false");
77 79
78 if ("all".equals(req.getCloudType())) { 80 if ("all".equals(req.getCloudType())) {
79 - zkTreeAllReq.setIp("zookeeper_aws"); 81 + zkTreeAllReq.setIp(AWS);
80 zkMoitorService.editZkMonitorDetail(zkTreeAllReq); 82 zkMoitorService.editZkMonitorDetail(zkTreeAllReq);
81 83
82 - zkTreeAllReq.setIp("zookeeper_qq"); 84 + zkTreeAllReq.setIp(QQ);
83 zkMoitorService.editZkMonitorDetail(zkTreeAllReq); 85 zkMoitorService.editZkMonitorDetail(zkTreeAllReq);
84 return ; 86 return ;
85 } 87 }
@@ -105,6 +107,7 @@ public class DegradeServiceImpl implements DegradeService { @@ -105,6 +107,7 @@ public class DegradeServiceImpl implements DegradeService {
105 config.setSwitchOn("true".equals(configZk.getZkValue())?"Y":"N"); 107 config.setSwitchOn("true".equals(configZk.getZkValue())?"Y":"N");
106 for (DegradeConfig configDb : configListDb) { 108 for (DegradeConfig configDb : configListDb) {
107 if (configZk.getZkName().equals(configDb.getConfigName())) { 109 if (configZk.getZkName().equals(configDb.getConfigName())) {
  110 + config.setConfigShowName(configDb.getConfigShowName());
108 config.setConfigDesc(configDb.getConfigDesc()); 111 config.setConfigDesc(configDb.getConfigDesc());
109 config.setImgUrl(configDb.getImgUrl()); 112 config.setImgUrl(configDb.getImgUrl());
110 config.setId(configDb.getId()); 113 config.setId(configDb.getId());
@@ -114,6 +117,7 @@ public class DegradeServiceImpl implements DegradeService { @@ -114,6 +117,7 @@ public class DegradeServiceImpl implements DegradeService {
114 } 117 }
115 degradeConfigList.add(config); 118 degradeConfigList.add(config);
116 } 119 }
  120 + // 进行过滤
117 degradeConfigList = dealFilter(req,degradeConfigList); 121 degradeConfigList = dealFilter(req,degradeConfigList);
118 result.setRows(getPageRows(degradeConfigList,req)); 122 result.setRows(getPageRows(degradeConfigList,req));
119 result.setCurrentPage(req.getCurrentPage()); 123 result.setCurrentPage(req.getCurrentPage());
@@ -130,8 +134,13 @@ public class DegradeServiceImpl implements DegradeService { @@ -130,8 +134,13 @@ public class DegradeServiceImpl implements DegradeService {
130 continue; 134 continue;
131 } 135 }
132 } 136 }
  137 + if (StringUtils.isNotBlank(req.getConfigShowName())) {
  138 + if (!findByRegex(req.getConfigShowName(),degradeConfig.getConfigShowName())) {
  139 + continue;
  140 + }
  141 + }
133 if (StringUtils.isNotBlank(req.getConfigName())) { 142 if (StringUtils.isNotBlank(req.getConfigName())) {
134 - if (!degradeConfig.getConfigName().equals(req.getConfigName())) { 143 + if (!findByRegex(req.getConfigName(),degradeConfig.getConfigName())) {
135 continue; 144 continue;
136 } 145 }
137 } 146 }
@@ -149,6 +158,17 @@ public class DegradeServiceImpl implements DegradeService { @@ -149,6 +158,17 @@ public class DegradeServiceImpl implements DegradeService {
149 return afterFilter; 158 return afterFilter;
150 } 159 }
151 160
  161 + private boolean findByRegex(String p, String to) {
  162 + if (StringUtils.isBlank(to)) {
  163 + return false;
  164 + }
  165 + p = p.replaceAll("\\.","\\\\.");
  166 + String regex = ".*"+p+".*";
  167 + Pattern showNamePattern = Pattern.compile(regex);
  168 + Matcher matcher = showNamePattern.matcher(to);
  169 + return matcher.find();
  170 + }
  171 +
152 private List<DegradeConfig> getPageRows(List<DegradeConfig> degradeConfigList, DegradeInfoReq req) { 172 private List<DegradeConfig> getPageRows(List<DegradeConfig> degradeConfigList, DegradeInfoReq req) {
153 int start = req.getPageSize()*(req.getCurrentPage()-1); 173 int start = req.getPageSize()*(req.getCurrentPage()-1);
154 int end = start+req.getPageSize() > degradeConfigList.size() ? degradeConfigList.size() : start+req.getPageSize() ; 174 int end = start+req.getPageSize() > degradeConfigList.size() ? degradeConfigList.size() : start+req.getPageSize() ;