use of com.baidu.disconf.web.service.config.vo.MachineListVo in project disconf by knightliao.
the class ConfigReadController method getZkInfo.
/**
* 获取 zk
*
* @param configId
*
* @return
*/
@RequestMapping(value = "/zk/{configId}", method = RequestMethod.GET)
@ResponseBody
public JsonObjectBase getZkInfo(@PathVariable long configId) {
// 业务校验
configValidator.valideConfigExist(configId);
MachineListVo machineListVo = configMgr.getConfVoWithZk(configId);
return buildSuccess(machineListVo);
}
use of com.baidu.disconf.web.service.config.vo.MachineListVo in project disconf by knightliao.
the class ConfigMgrImpl method getZkData.
/**
* 获取ZK data
*/
private MachineListVo getZkData(List<ZkDisconfDataItem> datalist, Config config) {
int errorNum = 0;
for (ZkDisconfDataItem zkDisconfDataItem : datalist) {
if (config.getType().equals(DisConfigTypeEnum.FILE.getType())) {
List<String> errorKeyList = compareConfig(zkDisconfDataItem.getValue(), config.getValue());
if (errorKeyList.size() != 0) {
zkDisconfDataItem.setErrorList(errorKeyList);
errorNum++;
}
} else {
if (zkDisconfDataItem.getValue().trim().equals(config.getValue().trim())) {
} else {
List<String> errorKeyList = new ArrayList<String>();
errorKeyList.add(config.getValue().trim());
zkDisconfDataItem.setErrorList(errorKeyList);
errorNum++;
}
}
}
MachineListVo machineListVo = new MachineListVo();
machineListVo.setDatalist(datalist);
machineListVo.setErrorNum(errorNum);
machineListVo.setMachineSize(datalist.size());
return machineListVo;
}
use of com.baidu.disconf.web.service.config.vo.MachineListVo in project disconf by knightliao.
the class ConfigMgrImpl method convert.
/**
* 转换成配置返回
*
* @param config
*
* @return
*/
private ConfListVo convert(Config config, String appNameString, String envName, ZkDisconfData zkDisconfData) {
ConfListVo confListVo = new ConfListVo();
confListVo.setConfigId(config.getId());
confListVo.setAppId(config.getAppId());
confListVo.setAppName(appNameString);
confListVo.setEnvName(envName);
confListVo.setEnvId(config.getEnvId());
confListVo.setCreateTime(config.getCreateTime());
confListVo.setModifyTime(config.getUpdateTime().substring(0, 12));
confListVo.setKey(config.getName());
// StringEscapeUtils.escapeHtml escape
confListVo.setValue(CodeUtils.unicodeToUtf8(config.getValue()));
confListVo.setVersion(config.getVersion());
confListVo.setType(DisConfigTypeEnum.getByType(config.getType()).getModelName());
confListVo.setTypeId(config.getType());
//
if (zkDisconfData != null) {
confListVo.setMachineSize(zkDisconfData.getData().size());
List<ZkDisconfDataItem> datalist = zkDisconfData.getData();
MachineListVo machineListVo = getZkData(datalist, config);
confListVo.setErrorNum(machineListVo.getErrorNum());
confListVo.setMachineList(machineListVo.getDatalist());
confListVo.setMachineSize(machineListVo.getMachineSize());
}
return confListVo;
}
use of com.baidu.disconf.web.service.config.vo.MachineListVo in project disconf by knightliao.
the class ConfigMgrImpl method getConfVoWithZk.
/**
* 根据 配置ID获取ZK对比数据
*/
@Override
public MachineListVo getConfVoWithZk(Long configId) {
Config config = configDao.get(configId);
App app = appMgr.getById(config.getAppId());
Env env = envMgr.getById(config.getEnvId());
//
//
//
DisConfigTypeEnum disConfigTypeEnum = DisConfigTypeEnum.FILE;
if (config.getType().equals(DisConfigTypeEnum.ITEM.getType())) {
disConfigTypeEnum = DisConfigTypeEnum.ITEM;
}
ZkDisconfData zkDisconfData = zkDeployMgr.getZkDisconfData(app.getName(), env.getName(), config.getVersion(), disConfigTypeEnum, config.getName());
if (zkDisconfData == null) {
return new MachineListVo();
}
MachineListVo machineListVo = getZkData(zkDisconfData.getData(), config);
return machineListVo;
}
Aggregations