diff --git a/cachecloud-web/pom.xml b/cachecloud-web/pom.xml index 1a204e89..0a21654d 100644 --- a/cachecloud-web/pom.xml +++ b/cachecloud-web/pom.xml @@ -86,11 +86,6 @@ spring-context-support - - com.alibaba - druid - - javax.servlet jstl @@ -105,6 +100,10 @@ slf4j-api org.slf4j + + HikariCP-java7 + com.zaxxer + @@ -153,6 +152,7 @@ org.projectlombok lombok + 1.18.30 provided diff --git a/cachecloud-web/src/main/java/com/sohu/cache/dao/AppAlertRecordDao.java b/cachecloud-web/src/main/java/com/sohu/cache/dao/AppAlertRecordDao.java index 15737920..3e4c911a 100644 --- a/cachecloud-web/src/main/java/com/sohu/cache/dao/AppAlertRecordDao.java +++ b/cachecloud-web/src/main/java/com/sohu/cache/dao/AppAlertRecordDao.java @@ -7,12 +7,12 @@ /** * @Author: zengyizhao * @DateTime: 2021/9/3 13:38 - * @Description: 报警记录 + * @Description: 鎶ヨ璁板綍 */ public interface AppAlertRecordDao { /** - * 保存报警信息 + * 淇濆瓨鎶ヨ淇℃伅 * * @param appAlertRecord * @return @@ -20,7 +20,7 @@ public interface AppAlertRecordDao { public int save(AppAlertRecord appAlertRecord); /** - * 批量保存报警信息 + * 鎵归噺淇濆瓨鎶ヨ淇℃伅 * * @param appAlertRecordList * @return diff --git a/cachecloud-web/src/main/java/com/sohu/cache/task/tasks/RedisClusterAppDeployTask.java b/cachecloud-web/src/main/java/com/sohu/cache/task/tasks/RedisClusterAppDeployTask.java index f593ba31..6e1551f8 100644 --- a/cachecloud-web/src/main/java/com/sohu/cache/task/tasks/RedisClusterAppDeployTask.java +++ b/cachecloud-web/src/main/java/com/sohu/cache/task/tasks/RedisClusterAppDeployTask.java @@ -155,7 +155,7 @@ public TaskFlowStatusEnum init() { //masterPerMachine masterPerMachine = MapUtils.getIntValue(paramMap, TaskConstants.MASTER_PER_MACHINE_KEY); - if (masterPerMachine <= 0 || masterPerMachine > TaskConstants.MAX_MASTER_PER_MACHINE) { + if (masterPerMachine < 0 || masterPerMachine > TaskConstants.MAX_MASTER_PER_MACHINE) { logger.error(marker, "task {} masterPerMachine {} is wrong", taskId, masterPerMachine); return TaskFlowStatusEnum.ABORT; } @@ -227,7 +227,12 @@ public TaskFlowStatusEnum checkResourceAllow() { } //鍏 long memoryFree = NumberUtils.toLong(machineStats.getMemoryFree()) / 1024 / 1024; - long memoryNeed = Long.valueOf(masterPerMachine) * maxMemory; + long memoryNeed = 0L; + if (masterPerMachine == 0) { + memoryNeed = maxMemory; + } else { + memoryNeed = Long.valueOf(masterPerMachine) * maxMemory; + } if (memoryNeed > memoryFree * 0.85) { logger.error(marker, "{} need {} MB, but memoryFree is {} MB", redisServerIp, memoryNeed, memoryFree); return TaskFlowStatusEnum.ABORT; @@ -256,7 +261,7 @@ public TaskFlowStatusEnum checkMachineConnect() { */ public TaskFlowStatusEnum generateInstanceNodes() { - redisServerNodes = instancePortService.generateRedisServerNodeList(appId, appDeployInfoList, masterPerMachine, maxMemory); + redisServerNodes = instancePortService.generateRedisServerNodeListWithDeployInfo(appId, appDeployInfoList, masterPerMachine, maxMemory); if (CollectionUtils.isEmpty(redisServerNodes)) { logger.warn(marker, "redisServerNodes is empty, appId is {}, redisServerMachineList is {}, masterPerMachine is {}, maxMemory is {}", appId, redisServerMachineList, masterPerMachine, maxMemory); diff --git a/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatFilter.java b/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatFilter.java deleted file mode 100644 index 387d29e2..00000000 --- a/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatFilter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.sohu.cache.web.druid; - -import com.alibaba.druid.support.http.WebStatFilter; - -import javax.servlet.*; -import javax.servlet.annotation.WebFilter; -import javax.servlet.annotation.WebInitParam; -import java.io.IOException; - -@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*", - initParams={ - @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,*.htm,*.woff,/druid/*")//蹇界暐璧勬簮 - } -) -public class DruidStatFilter extends WebStatFilter { - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - super.doFilter(request, response, chain); - } - - @Override - public void init(FilterConfig config) throws ServletException { - super.init(config); - } - - @Override - public void destroy() { - super.destroy(); - } -} diff --git a/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatViewServlet.java b/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatViewServlet.java deleted file mode 100644 index cc0547a0..00000000 --- a/cachecloud-web/src/main/java/com/sohu/cache/web/druid/DruidStatViewServlet.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.sohu.cache.web.druid; - -import com.alibaba.druid.support.http.StatViewServlet; - -import javax.servlet.ServletException; -import javax.servlet.annotation.WebInitParam; -import javax.servlet.annotation.WebServlet; - -@WebServlet(urlPatterns="/druid/*", - initParams={ - @WebInitParam(name="loginUsername",value="admin"),// 鐢ㄦ埛鍚 - @WebInitParam(name="loginPassword",value="admin"),// 瀵嗙爜 - @WebInitParam(name="resetEnable",value="false")// 绂佺敤HTML椤甸潰涓婄殑鈥淩eset All鈥濆姛鑳 -}) -public class DruidStatViewServlet extends StatViewServlet { - - private static final long serialVersionUID = -2688872071445249539L; - - @Override - public void init() throws ServletException { - super.init(); - } - - @Override - protected String process(String url) { - return super.process(url); - } -} diff --git a/cachecloud-web/src/main/java/com/sohu/cache/web/service/InstancePortService.java b/cachecloud-web/src/main/java/com/sohu/cache/web/service/InstancePortService.java index 9c5d91d8..ea5d4345 100644 --- a/cachecloud-web/src/main/java/com/sohu/cache/web/service/InstancePortService.java +++ b/cachecloud-web/src/main/java/com/sohu/cache/web/service/InstancePortService.java @@ -51,6 +51,17 @@ public interface InstancePortService { public List generateRedisServerNodeList(long appId, List redisServerMachineList, int masterPerMachine, int maxMemory); + /** + * 鐢熸垚redis server 瀹炰緥鍒楄〃 + * @param appId + * @param appDeployInfoList (masterIp:maxmemory:slaveIp) + * @param masterPerMachine + * @param maxMemory + * @return + */ + public List generateRedisServerNodeListWithDeployInfo(long appId, List appDeployInfoList, + int masterPerMachine, int maxMemory); + /** * 鐢熸垚redis sentinel 瀹炰緥鍒楄〃 * @param appId diff --git a/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/AppServiceImpl.java b/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/AppServiceImpl.java index d2f6ca8b..98962f23 100644 --- a/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/AppServiceImpl.java +++ b/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/AppServiceImpl.java @@ -934,7 +934,7 @@ public void getResMachines(List machineCandi, Integer machin /** * @param machinelist 鏈哄櫒淇℃伅 * @param type 搴旂敤绫诲瀷 - * @param instanceNum 瀹炰緥鏁伴噺 + * @param instanceNum 瀹炰緥鏁伴噺 瀹炰緥鏁版嵁涓0鏃讹紝鍒欐瘡涓満鍣ㄩ儴缃蹭竴涓疄渚 * @param maxMemory 鍐呭瓨澶у皬 * @param hasSalve 鏄惁鏈変粠鑺傜偣 * @return 娣诲姞閮ㄧ讲Redis/Pika鑺傜偣淇℃伅 @@ -956,6 +956,29 @@ public List generateInstanceInfo(List machinelist, int type, deployInfoList.add(deployInfo); } } + //姣忓彴鏈哄櫒浠呴儴缃蹭竴涓疄渚嬪鐞嗛昏緫 + if (instanceNum == 0) { + for (int index = 0; index < machinelist.size() - 1; ) { + DeployInfo deployInfo = null; + if (DeployInfo.isRedisNode(type)) { + deployInfo = hasSalve == 1 + ? DeployInfo.getRedisInfo(appType, machinelist.get(index), maxMemory, machinelist.get(index + 1)) + : DeployInfo.getRedisInfo(appType, machinelist.get(index), maxMemory, null); + } else { + deployInfo = hasSalve == 1 + ? DeployInfo.getPikaInfo(appType, machinelist.get(index), maxMemory, machinelist.get(index + 1)) + : DeployInfo.getPikaInfo(appType, machinelist.get(index), maxMemory, null); + } + if (deployInfo != null) { + deployInfoList.add(deployInfo); + } + if(hasSalve == 1) { + index += 2; + } else { + index += 1; + } + } + } } return deployInfoList; } diff --git a/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/InstancePortServiceImpl.java b/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/InstancePortServiceImpl.java index b60f2b94..dd701f00 100644 --- a/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/InstancePortServiceImpl.java +++ b/cachecloud-web/src/main/java/com/sohu/cache/web/service/impl/InstancePortServiceImpl.java @@ -66,15 +66,15 @@ public class InstancePortServiceImpl implements InstancePortService { @Autowired @Lazy private RedisCenter redisCenter; - - - /** - * 1. 涓讳粠涓嶅悓鏈哄櫒 - * 2. 绔彛浠庤捣濮嬬鍙e紑濮嬭嚜澧1 - */ - @Override - public List generateRedisServerNodeList(long appId, List appDeployInfoList, - int masterPerMachine, int maxMemory) { + + + /** + * 1. 涓讳粠涓嶅悓鏈哄櫒 + * 2. 绔彛浠庤捣濮嬬鍙e紑濮嬭嚜澧1 + */ + @Override + public List generateRedisServerNodeList(long appId, List redisServerMachineList, + int masterPerMachine, int maxMemory) { // 鏈缁堢粨鏋 List redisServerNodeList = new ArrayList(); @@ -83,29 +83,7 @@ public List generateRedisServerNodeList(long appId, List> ipPortSetMap = new HashMap>(); - for (int i=0; i < appDeployInfoList.size(); i++) { - String masterAndSlaveHost = appDeployInfoList.get(i); - String[] hostInfoArray = masterAndSlaveHost.split(":"); - String masterHost = hostInfoArray[0]; - maxMemory = Integer.parseInt(hostInfoArray[1]); - while (checkHostPortExist(ipPortSetMap, masterHost, masterPort)) { - masterPort++; - } - redisServerNodeList.add(new RedisServerNode(masterHost, masterPort, InstanceRoleEnum.MASTER.getRole(), - maxMemory, "", 0)); - - if (hostInfoArray.length >= 3) { - String slaveHost = hostInfoArray[2]; - int slavePort = masterPort + ConstUtils.SLAVE_PORT_INCREASE; - while (checkHostPortExist(ipPortSetMap, slaveHost, slavePort)) { - slavePort++; - } - redisServerNodeList.add(new RedisServerNode(slaveHost, slavePort, InstanceRoleEnum.SLAVE.getRole(), - maxMemory, masterHost, masterPort)); - } - masterPort += 1; - } - /* + for (int i = 0; i < redisServerMachineList.size(); i++) { String masterHost = redisServerMachineList.get(i); @@ -132,7 +110,47 @@ public List generateRedisServerNodeList(long appId, List generateRedisServerNodeListWithDeployInfo(long appId, List appDeployInfoList, + int masterPerMachine, int maxMemory) { + + // 鏈缁堢粨鏋 + List redisServerNodeList = new ArrayList(); + // 璧峰鑺傜偣 + int masterPort = (int) (ConstUtils.REDIS_SERVER_BASE_PORT + (appId % 10) * 10); + + // 璁板綍鏈姣忎釜鏈哄櫒鍒嗛厤鐨刾ort + Map> ipPortSetMap = new HashMap>(); + for (int i=0; i < appDeployInfoList.size(); i++) { + String masterAndSlaveHost = appDeployInfoList.get(i); + String[] hostInfoArray = masterAndSlaveHost.split(":"); + String masterHost = hostInfoArray[0]; + maxMemory = Integer.parseInt(hostInfoArray[1]); + while (checkHostPortExist(ipPortSetMap, masterHost, masterPort)) { + masterPort++; + } + redisServerNodeList.add(new RedisServerNode(masterHost, masterPort, InstanceRoleEnum.MASTER.getRole(), + maxMemory, "", 0)); + + if (hostInfoArray.length >= 3) { + String slaveHost = hostInfoArray[2]; + int slavePort = masterPort + ConstUtils.SLAVE_PORT_INCREASE; + while (checkHostPortExist(ipPortSetMap, slaveHost, slavePort)) { + slavePort++; + } + redisServerNodeList.add(new RedisServerNode(slaveHost, slavePort, InstanceRoleEnum.SLAVE.getRole(), + maxMemory, masterHost, masterPort)); + } + masterPort += 1; + } return redisServerNodeList; } diff --git a/cachecloud-web/src/main/resources/spring/spring-quartz.xml b/cachecloud-web/src/main/resources/spring/spring-quartz.xml index 89d96b53..856839a9 100644 --- a/cachecloud-web/src/main/resources/spring/spring-quartz.xml +++ b/cachecloud-web/src/main/resources/spring/spring-quartz.xml @@ -108,7 +108,7 @@ CacheCloudScheduler AUTO - org.quartz.impl.jdbcjobstore.JobStoreTX + org.springframework.scheduling.quartz.LocalDataSourceJobStore 200 org.quartz.impl.jdbcjobstore.StdJDBCDelegate diff --git a/cachecloud-web/src/main/resources/static/wiki/quickstart/index.md b/cachecloud-web/src/main/resources/static/wiki/quickstart/index.md index ee7d2fea..1ee995f8 100644 --- a/cachecloud-web/src/main/resources/static/wiki/quickstart/index.md +++ b/cachecloud-web/src/main/resources/static/wiki/quickstart/index.md @@ -26,10 +26,16 @@ a.涓嬭浇war鍖咃細 [3.1鐗堟湰 cachecloud-web.war](http://43.137.44.6/redis-ecs/3.1/cachecloud-web.war) +[3.2鐗堟湰 cachecloud-web.war](http://43.137.44.6/redis-ecs/3.2/cachecloud-web.war) + b.涔熷彲浠lone婧愮爜锛岃嚜琛屾墦鍖咃細 //clone椤圭洰 git clone https://github.com/sohutv/cachecloud.git + //鍒囨崲鍒版寚瀹氬垎鏀 + git checkout 3.2 + //淇敼鎸囧畾搴旂敤鍜屾暟鎹簱閰嶇疆 + [鍙傝 涓夈佸惎鍔ㄥ伐绋媇(#cc3) //鎵撳寘 mvn clean package @@ -44,12 +50,13 @@ b.涔熷彲浠lone婧愮爜锛岃嚜琛屾墦鍖咃細 user: xxx password: xxx -瀵煎叆寤鸿〃鏂囦欢锛/cachecloud-open/cachecloud-web/sql/cc2.0.sql +瀵煎叆寤鸿〃鏂囦欢锛/cachecloud-web/sql/cc3.2.sql +锛堟牴鎹寚瀹氱増鏈鍏ワ紝濡備负鍗囩骇锛岃鎵цupdate {婧愮増鏈瑌 to {鐩爣鐗堟湰}.sql鏂囦欢锛 ### 涓夈佸惎鍔ㄥ伐绋 -鍑嗗閰嶇疆鏂囦欢锛歛pplication-open.yml锛屾斁鍒皐ar鍖呭悓鐩綍涓 +鍑嗗閰嶇疆鏂囦欢锛歝achecloud-web/src/main/resources/application-open.yml锛屼慨鏀规寚瀹氬簲鐢ㄥ拰鏁版嵁搴撻厤缃 #閰嶇疆搴旂敤鍚嶇О spring: diff --git a/cachecloud-web/src/main/webapp/WEB-INF/jsp/manage/appAudit/deploy/appDeployDetail.jsp b/cachecloud-web/src/main/webapp/WEB-INF/jsp/manage/appAudit/deploy/appDeployDetail.jsp index c74f7ff5..16b585fa 100644 --- a/cachecloud-web/src/main/webapp/WEB-INF/jsp/manage/appAudit/deploy/appDeployDetail.jsp +++ b/cachecloud-web/src/main/webapp/WEB-INF/jsp/manage/appAudit/deploy/appDeployDetail.jsp @@ -395,18 +395,19 @@
-   閮ㄧ讲涓诲疄渚嬫暟锛 +   瀹炰緥鏁帮細
@@ -470,10 +471,15 @@


閮ㄧ讲淇℃伅棰勮:(*):
- + +
+ +
+
+ +
+
-
-