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.");
}
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");
}
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;
}
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;
}
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;
}
Aggregations