diff --git a/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisCenterImpl.java b/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisCenterImpl.java index 5b696726..f887c579 100644 --- a/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisCenterImpl.java +++ b/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisCenterImpl.java @@ -458,17 +458,23 @@ private Table getAccumulationDiff( */ private Table getCommandsDiff(Map> currentInfoMap, Map lastInfoMap) { - //没有上一次统计快照,忽略差值统计 + //没有上一次统计快照,忽略差值统计 if (lastInfoMap == null || lastInfoMap.isEmpty()) { return HashBasedTable.create(); } Map map = currentInfoMap.get(RedisConstant.Commandstats); Map currentMap = transferLongMap(map); - Map lastObjectMap; + Map lastObjectMap=null; if (lastInfoMap.get(RedisConstant.Commandstats.getValue()) == null) { lastObjectMap = new HashMap(); } else { - lastObjectMap = (Map) lastInfoMap.get(RedisConstant.Commandstats.getValue()); + Object lastObj=lastInfoMap.get(RedisConstant.Commandstats.getValue()); + if(lastObj instanceof Map){ + lastObjectMap = (Map) lastObj; + }else{ + logger.error("can't cast (Object)lastObj:{} to Map",lastObj.toString()); + throw new RuntimeException("can't cast (Object)lastObj to Map"); + } } Map lastMap = transferLongMap(lastObjectMap); diff --git a/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisDeployCenterImpl.java b/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisDeployCenterImpl.java index 500a070b..23ce56ac 100644 --- a/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisDeployCenterImpl.java +++ b/cachecloud-open-web/src/main/java/com/sohu/cache/redis/impl/RedisDeployCenterImpl.java @@ -36,6 +36,7 @@ /** * Created by yijunzhang on 14-8-25. + * @author Hezf */ public class RedisDeployCenterImpl implements RedisDeployCenter { private final Logger logger = LoggerFactory.getLogger(this.getClass()); @@ -274,56 +275,58 @@ private String getClusterNodeId(Jedis jedis) { @Override public boolean deploySentinelInstance(long appId, String masterHost, String slaveHost, int maxMemory, List sentinelList) { - if (!isExist(appId)) { - return false; - } - //获取端口 - Integer masterPort = machineCenter.getAvailablePort(masterHost, ConstUtils.CACHE_REDIS_STANDALONE); - if (masterPort == null) { - logger.error("masterHost={} getAvailablePort is null", masterHost); - return false; - } - Integer slavePort = machineCenter.getAvailablePort(slaveHost, ConstUtils.CACHE_REDIS_STANDALONE); - if (slavePort == null) { - logger.error("slaveHost={} getAvailablePort is null", slavePort); - return false; - } - //运行实例 - boolean isMasterRun = runInstance(masterHost, masterPort, maxMemory, false); - if (!isMasterRun) { - return false; - } - boolean isSlaveRun = runInstance(slaveHost, slavePort, maxMemory, false); - if (!isSlaveRun) { - return false; - } - //添加slaveof配置 - boolean isSlave = slaveOf(masterHost, masterPort, slaveHost, slavePort); - if (!isSlave) { - return false; - } - - //运行sentinel实例组 - boolean isRunSentinel = runSentinelGroup(sentinelList, masterHost, masterPort, appId); - if (!isRunSentinel) { - return false; - } - - //写入instanceInfo 信息 - saveInstance(appId, masterHost, masterPort, maxMemory, - ConstUtils.CACHE_REDIS_STANDALONE, ""); - saveInstance(appId, slaveHost, slavePort, maxMemory, ConstUtils.CACHE_REDIS_STANDALONE, ""); - - //启动监控trigger - boolean isMasterDeploy = redisCenter.deployRedisCollection(appId, masterHost, masterPort); - boolean isSlaveDeploy = redisCenter.deployRedisCollection(appId, slaveHost, slavePort); - if (!isMasterDeploy) { - logger.warn("host={},port={},isMasterDeploy=false", masterHost, masterPort); - } - if (!isSlaveDeploy) { - logger.warn("host={},port={},isSlaveDeploy=false", slaveHost, slavePort); - } - return true; + if (!isExist(appId)) { + return false; + } + //master + Integer masterPort = machineCenter.getAvailablePort(masterHost, ConstUtils.CACHE_REDIS_STANDALONE); + if (masterPort == null) { + logger.error("masterHost={} getAvailablePort is null", masterHost); + return false; + } + boolean isMasterRun = runInstance(masterHost, masterPort, maxMemory, false); + if (!isMasterRun) { + return false; + } + saveInstance(appId, masterHost, masterPort, maxMemory, + ConstUtils.CACHE_REDIS_STANDALONE, ""); + + //slave + Integer slavePort = machineCenter.getAvailablePort(slaveHost, ConstUtils.CACHE_REDIS_STANDALONE); + if (slavePort == null) { + logger.error("slaveHost={} getAvailablePort is null", slavePort); + return false; + } + boolean isSlaveRun = runInstance(slaveHost, slavePort, maxMemory, false); + if (!isSlaveRun) { + return false; + } + saveInstance(appId, slaveHost, slavePort, maxMemory, ConstUtils.CACHE_REDIS_STANDALONE, ""); + + //添加slaveof配置 + boolean isSlave = slaveOf(masterHost, masterPort, slaveHost, slavePort); + if (!isSlave) { + return false; + } + + //运行sentinel实例组 + boolean isRunSentinel = runSentinelGroup(sentinelList, masterHost, masterPort, appId); + if (!isRunSentinel) { + return false; + } + + + + //启动监控trigger + boolean isMasterDeploy = redisCenter.deployRedisCollection(appId, masterHost, masterPort); + boolean isSlaveDeploy = redisCenter.deployRedisCollection(appId, slaveHost, slavePort); + if (!isMasterDeploy) { + logger.warn("host={},port={},isMasterDeploy=false", masterHost, masterPort); + } + if (!isSlaveDeploy) { + logger.warn("host={},port={},isSlaveDeploy=false", slaveHost, slavePort); + } + return true; } @Override diff --git a/cachecloud-open-web/src/main/resources/mapper/AppClientValueStatDao.xml b/cachecloud-open-web/src/main/resources/mapper/AppClientValueStatDao.xml index b43122f5..63a6f0b1 100644 --- a/cachecloud-open-web/src/main/resources/mapper/AppClientValueStatDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/AppClientValueStatDao.xml @@ -30,5 +30,9 @@ group by distribute_type order by distribute_type + + delete from app_client_value_minute_stats where collect_time <#{collectTime} + + \ No newline at end of file diff --git a/cachecloud-open-web/src/main/resources/mapper/AppDao.xml b/cachecloud-open-web/src/main/resources/mapper/AppDao.xml index d7402a01..78f1d01e 100644 --- a/cachecloud-open-web/src/main/resources/mapper/AppDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/AppDao.xml @@ -6,7 +6,7 @@ app_id,name,user_id,status,intro,create_time,passed_time,type,officer, ver_id,is_test,has_back_store,need_persistence,need_hot_back_up,forecase_qps, - forecast_obj_num,mem_alert_value,client_machine_room + forecast_obj_num,mem_alert_value,client_machine_room,app_key,client_conn_alert_value select @@ -59,7 +59,7 @@ select count(app_id) from app_desc where 1=1 - and name like '${appName}%' + and name like CONCAT(SUBSTR(#{appName}, 1, LENGTH(#{appName})),'%') @@ -85,7 +85,7 @@ from app_desc where 1=1 - and name like '${appName}%' + and name like CONCAT(SUBSTR(#{appName}, 1, LENGTH(#{appName})),'%') @@ -115,13 +115,12 @@ - - - - update app_desc set mem_alert_value=#{memAlertValue} where app_id=#{appId} + + update app_desc set app_key=#{appKey} where app_id=#{appId} + diff --git a/cachecloud-open-web/src/main/resources/mapper/AppDataMigrateStatusDao.xml b/cachecloud-open-web/src/main/resources/mapper/AppDataMigrateStatusDao.xml new file mode 100644 index 00000000..d3867064 --- /dev/null +++ b/cachecloud-open-web/src/main/resources/mapper/AppDataMigrateStatusDao.xml @@ -0,0 +1,78 @@ + + + + + + migrate_machine_ip,migrate_machine_port,source_migrate_type,source_servers,target_migrate_type,target_servers, + source_app_id,target_app_id,user_id,status,start_time,end_time,log_path,config_path + + + + insert into app_data_migrate_status + () + values + (#{migrateMachineIp},#{migrateMachinePort},#{sourceMigrateType},#{sourceServers},#{targetMigrateType},#{targetServers}, + #{sourceAppId},#{targetAppId},#{userId},#{status},#{startTime},#{endTime},#{logPath},#{configPath}) + + + + + + + + + + + update app_data_migrate_status set status = #{status}, end_time=now() where id = #{id} + + + + + diff --git a/cachecloud-open-web/src/main/resources/mapper/AppStatsDao.xml b/cachecloud-open-web/src/main/resources/mapper/AppStatsDao.xml index 079d7ab5..62de2d5d 100644 --- a/cachecloud-open-web/src/main/resources/mapper/AppStatsDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/AppStatsDao.xml @@ -113,14 +113,32 @@ command_count = command_count + #{commandCount}, modify_time = #{modifyTime} - - select , create_time from where app_id = #{appId} and collect_time between #{td.begin} and #{td.end} + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cachecloud-open-web/src/main/resources/mapper/AppUserDao.xml b/cachecloud-open-web/src/main/resources/mapper/AppUserDao.xml index 0407c925..d6423b1b 100644 --- a/cachecloud-open-web/src/main/resources/mapper/AppUserDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/AppUserDao.xml @@ -14,7 +14,7 @@ table_schema = 'cache-cloud' and table_name = @tn; --> - id,name,ch_name,email,mobile,type + id,name,ch_name,email,mobile,type,avatar,nick_name,show_name,boss_id + + + select id, from instance_config where type = #{type} + + + + + + + + + + + insert into instance_config() + values(#{configKey},#{configValue},#{info},now(),#{type},#{status}) + on duplicate key update + config_value = #{configValue}, info = #{info}, + update_time = now(),status = #{status} + + + + update instance_config set status = #{status} where id = #{id} + + + + delete from instance_config where id = #{id} + + + \ No newline at end of file diff --git a/cachecloud-open-web/src/main/resources/mapper/InstanceSlowLogDao.xml b/cachecloud-open-web/src/main/resources/mapper/InstanceSlowLogDao.xml index 95365711..0f594dd0 100644 --- a/cachecloud-open-web/src/main/resources/mapper/InstanceSlowLogDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/InstanceSlowLogDao.xml @@ -30,5 +30,10 @@ select concat(ip,":",port) as hostPort,count(*) as count from instance_slow_log where app_id = #{appId} and create_time between DATE_FORMAT(#{startDate}, '%Y-%m-%d') and DATE_FORMAT(#{endDate}, '%Y-%m-%d') group by hostPort order by count desc + + \ No newline at end of file diff --git a/cachecloud-open-web/src/main/resources/mapper/InstanceStatsDao.xml b/cachecloud-open-web/src/main/resources/mapper/InstanceStatsDao.xml index 3ff27917..9d9042f9 100644 --- a/cachecloud-open-web/src/main/resources/mapper/InstanceStatsDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/InstanceStatsDao.xml @@ -4,19 +4,14 @@ - inst_id,app_id,host_id,ip,port,role,max_memory,used_memory,curr_items,curr_connections,misses,hits,modify_time + inst_id,app_id,host_id,ip,port,role,max_memory,used_memory,curr_items,curr_connections,misses,hits,modify_time,mem_fragmentation_ratio,aof_delayed_fsync - INSERT INTO instance_statistics () VALUES (#{instId},#{appId},#{hostId},#{ip},#{port},#{role},#{maxMemory},#{usedMemory},#{currItems},#{currConnections},#{misses},#{hits}, - #{modifyTime} ) + #{modifyTime},#{memFragmentationRatio},#{aofDelayedFsync}) ON DUPLICATE KEY UPDATE inst_id = #{instId}, host_id = #{hostId}, @@ -27,7 +22,9 @@ curr_connections = #{currConnections}, misses = #{misses}, hits = #{hits}, - modify_time = #{modifyTime} + modify_time = #{modifyTime}, + mem_fragmentation_ratio = #{memFragmentationRatio}, + aof_delayed_fsync = #{aofDelayedFsync} - select - id, modify_time, - from machine_info - where available = 1 - - - - - - - - - - + select + id, modify_time, + from machine_info + where available = 1 + + + + + + + + + + + + insert into machine_info + () + values + () + on duplicate key + update ssh_user=#{sshUser},ssh_passwd=#{sshPasswd},room=#{room},mem=#{mem},cpu=#{cpu}, `virtual`=#{virtual},real_ip=#{realIp},service_time=#{serviceTime},fault_count=#{faultCount}, - warn=#{warn},available=#{available},type=#{type},groupId=#{groupId},extra_desc=#{extraDesc} - - - - - DELETE FROM machine_info - WHERE ip = #{ip} - - \ No newline at end of file + warn=#{warn},available=#{available},type=#{type},groupId=#{groupId},extra_desc=#{extraDesc},collect=#{collect} + + + + + update machine_info set available = 0 WHERE ip = #{ip} + + + + + + + + update machine_info set type = #{type} where id = #{id} + + + diff --git a/cachecloud-open-web/src/main/resources/mapper/MachineStatsDao.xml b/cachecloud-open-web/src/main/resources/mapper/MachineStatsDao.xml index 1d4612ed..fbeaa4b3 100644 --- a/cachecloud-open-web/src/main/resources/mapper/MachineStatsDao.xml +++ b/cachecloud-open-web/src/main/resources/mapper/MachineStatsDao.xml @@ -64,7 +64,7 @@ from machine_statistics - where ip like '%${ipLike}%' + where ip like CONCAT('%',SUBSTR(#{ipLike}, 1, LENGTH(#{ipLike})),'%') diff --git a/cachecloud-open-web/src/main/resources/mapper/ServerStatusDao.xml b/cachecloud-open-web/src/main/resources/mapper/ServerStatusDao.xml new file mode 100644 index 00000000..1ea54c50 --- /dev/null +++ b/cachecloud-open-web/src/main/resources/mapper/ServerStatusDao.xml @@ -0,0 +1,90 @@ + + + + + + + + + + + insert ignore into server(ip,dist) values (#{ip},#{dist}) + + + + + + + + insert into server (ip,host,nmon,cpus,cpu_model,kernel,ulimit) + values (#{server.ip},#{server.host},#{server.nmon},#{server.cpus},#{server.cpuModel},#{server.kernel},#{server.ulimit}) + on duplicate key update host=values(host), nmon=values(nmon), cpus=values(cpus), + cpu_model=values(cpu_model), kernel=values(kernel), ulimit=values(ulimit) + + + + + + + + + + + + + + + + + + + + insert ignore into server_stat(ip,cdate,ctime,cuser,csys,cwio,c_ext, + cload1,cload5,cload15, + mtotal,mfree,mcache,mbuffer,mswap,mswap_free, + nin,nout,nin_ext,nout_ext, + tuse,torphan,twait, + dread,dwrite,diops,dbusy,d_ext,dspace) + values(#{server.ip},#{server.collectTime},#{server.time}, + #{server.cpu.user},#{server.cpu.sys},#{server.cpu.wait},#{server.cpu.ext}, + #{server.load.load1},#{server.load.load5},#{server.load.load15}, + #{server.mem.total},#{server.mem.totalFree},#{server.mem.cache}, + #{server.mem.buffer},#{server.mem.swap},#{server.mem.swapFree}, + #{server.net.nin},#{server.net.nout},#{server.net.ninDetail},#{server.net.noutDetail}, + #{server.connection.established},#{server.connection.orphan},#{server.connection.timeWait}, + #{server.disk.read},#{server.disk.write},#{server.disk.iops},#{server.disk.busy}, + #{server.disk.ext},#{server.disk.space}) + + \ No newline at end of file diff --git a/cachecloud-open-web/src/main/webapp/WEB-INF/jsp/user/userRegister.jsp b/cachecloud-open-web/src/main/webapp/WEB-INF/jsp/user/userRegister.jsp index 6dc371c7..8c1cceef 100644 --- a/cachecloud-open-web/src/main/webapp/WEB-INF/jsp/user/userRegister.jsp +++ b/cachecloud-open-web/src/main/webapp/WEB-INF/jsp/user/userRegister.jsp @@ -6,7 +6,7 @@ CacheCloud用户申请