Search in sources :

Example 11 with MachineInfo

use of com.sohu.cache.entity.MachineInfo in project cachecloud by sohutv.

the class MachineInitLoad method initAsync.

/**
     * 为机器部署trigger,主要两类:统计机器的信息以及监控机器的状态
     */
public void initAsync() {
    List<MachineInfo> machineInfoList = machineDao.getAllMachines();
    for (MachineInfo machineInfo : machineInfoList) {
        long hostId = machineInfo.getId();
        String ip = machineInfo.getIp();
        Assert.hasText(ip);
        Assert.isTrue(hostId > 0);
        machineCenter.deployMachineCollection(hostId, ip);
        machineCenter.deployMachineMonitor(hostId, ip);
        if (machineInfo.getCollect() == 1) {
            machineCenter.deployServerCollection(hostId, ip);
        }
    }
    logger.info("init deploy all host and monitor done.");
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo)

Example 12 with MachineInfo

use of com.sohu.cache.entity.MachineInfo in project cachecloud by sohutv.

the class MachineManageController method doDelete.

@RequestMapping(value = "/delete")
public ModelAndView doDelete(HttpServletRequest request, HttpServletResponse response, Model model) {
    String machineIp = request.getParameter("machineIp");
    if (StringUtils.isNotBlank(machineIp)) {
        MachineInfo machineInfo = machineCenter.getMachineInfoByIp(machineIp);
        boolean success = machineDeployCenter.removeMachine(machineInfo);
        logger.warn("delete machine {}, result is {}", machineIp, success);
    } else {
        logger.warn("machineIp is empty!");
    }
    return new ModelAndView("redirect:/manage/machine/list");
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with MachineInfo

use of com.sohu.cache.entity.MachineInfo in project cachecloud by sohutv.

the class MachineCenterImpl method getAllMachineStats.

@Override
public List<MachineStats> getAllMachineStats() {
    List<MachineStats> list = machineStatsDao.getAllMachineStats();
    for (MachineStats ms : list) {
        String ip = ms.getIp();
        MachineInfo machineInfo = machineDao.getMachineInfoByIp(ip);
        if (machineInfo == null || machineInfo.isOffline()) {
            continue;
        }
        int memoryHost = instanceDao.getMemoryByHost(ip);
        getMachineMemoryDetail(ms.getIp());
        //获取机器申请和使用内存
        long applyMem = 0;
        long usedMem = 0;
        List<InstanceStats> instanceStats = instanceStatsDao.getInstanceStatsByIp(ip);
        for (InstanceStats instance : instanceStats) {
            applyMem += instance.getMaxMemory();
            usedMem += instance.getUsedMemory();
        }
        MachineMemInfo machineMemInfo = new MachineMemInfo();
        machineMemInfo.setIp(ip);
        machineMemInfo.setApplyMem(applyMem);
        machineMemInfo.setUsedMem(usedMem);
        ms.setMachineMemInfo(machineMemInfo);
        ms.setMemoryAllocated(memoryHost);
        ms.setInfo(machineInfo);
    }
    return list;
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo) InstanceStats(com.sohu.cache.entity.InstanceStats) MachineStats(com.sohu.cache.entity.MachineStats) MachineMemInfo(com.sohu.cache.entity.MachineMemInfo)

Example 14 with MachineInfo

use of com.sohu.cache.entity.MachineInfo in project cachecloud by sohutv.

the class RedisDeployCenterImpl method saveInstance.

private InstanceInfo saveInstance(long appId, String host, int port, int maxMemory, int type, String cmd) {
    InstanceInfo instanceInfo = new InstanceInfo();
    instanceInfo.setAppId(appId);
    MachineInfo machineInfo = machineDao.getMachineInfoByIp(host);
    instanceInfo.setHostId(machineInfo.getId());
    instanceInfo.setConn(0);
    instanceInfo.setMem(maxMemory);
    instanceInfo.setStatus(InstanceStatusEnum.GOOD_STATUS.getStatus());
    instanceInfo.setPort(port);
    instanceInfo.setType(type);
    instanceInfo.setCmd(cmd);
    instanceInfo.setIp(host);
    instanceDao.saveInstance(instanceInfo);
    return instanceInfo;
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo) InstanceInfo(com.sohu.cache.entity.InstanceInfo)

Example 15 with MachineInfo

use of com.sohu.cache.entity.MachineInfo in project cachecloud by sohutv.

the class TriggerCenterImpl method addTrigger.

/**
     * 增加一个新trigger
     *
     * @param jobGroup  trigger所属的job分组:redis/machine/machineMonitor
     * @param ip
     * @param port
     * @return
     */
@Override
public boolean addTrigger(String jobGroup, String ip, int port) {
    Assert.hasText(jobGroup, "jobGroup is invalid: " + jobGroup);
    Assert.hasText(ip, "ip is invalid, ip: " + ip);
    Assert.isTrue(port > 0, "port is invalid, port: " + port);
    boolean opResult = false;
    if (jobGroup.equals(ConstUtils.REDIS_JOB_GROUP)) {
        InstanceInfo instanceInfo = instanceDao.getInstByIpAndPort(ip, port);
        opResult = redisCenter.deployRedisCollection(instanceInfo.getAppId(), ip, port);
    } else if (jobGroup.equals(ConstUtils.REDIS_SLOWLOG_JOB_GROUP)) {
        InstanceInfo instanceInfo = instanceDao.getInstByIpAndPort(ip, port);
        opResult = redisCenter.deployRedisSlowLogCollection(instanceInfo.getAppId(), ip, port);
    } else if (jobGroup.equals(ConstUtils.MACHINE_JOB_GROUP)) {
        MachineInfo machineInfo = machineDao.getMachineInfoByIp(ip);
        opResult = machineCenter.deployMachineCollection(machineInfo.getId(), ip);
    } else if (jobGroup.equals(ConstUtils.MACHINE_MONITOR_JOB_GROUP)) {
        MachineInfo machineInfo = machineDao.getMachineInfoByIp(ip);
        opResult = machineCenter.deployMachineMonitor(machineInfo.getId(), ip);
    } else if (jobGroup.equals(ConstUtils.SERVER_TRIGGER_GROUP)) {
        MachineInfo machineInfo = machineDao.getMachineInfoByIp(ip);
        opResult = machineCenter.deployServerCollection(machineInfo.getId(), ip);
    }
    return opResult;
}
Also used : MachineInfo(com.sohu.cache.entity.MachineInfo) InstanceInfo(com.sohu.cache.entity.InstanceInfo)

Aggregations

MachineInfo (com.sohu.cache.entity.MachineInfo)16 InstanceInfo (com.sohu.cache.entity.InstanceInfo)5 InstanceStats (com.sohu.cache.entity.InstanceStats)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ModelAndView (org.springframework.web.servlet.ModelAndView)3 MachineStats (com.sohu.cache.entity.MachineStats)2 BaseTest (com.sohu.test.BaseTest)2 Date (java.util.Date)2 Test (org.junit.Test)2 AppDesc (com.sohu.cache.entity.AppDesc)1 MachineMemInfo (com.sohu.cache.entity.MachineMemInfo)1 SSHException (com.sohu.cache.exception.SSHException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1