use of com.sohu.cache.entity.AppClientVersion in project cachecloud by sohutv.
the class ClientReportExceptionServiceImpl method generate.
private AppClientExceptionStat generate(String clientIp, long collectTime, long reportTime, Map<String, Object> map) {
// 异常信息
String exceptionClass = MapUtils.getString(map, ClientReportConstant.EXCEPTION_CLASS, "");
Long exceptionCount = MapUtils.getLong(map, ClientReportConstant.EXCEPTION_COUNT, 0L);
int exceptionType = MapUtils.getInteger(map, ClientReportConstant.EXCEPTION_TYPE, ClientExceptionType.REDIS_TYPE.getType());
String host = null;
Integer port = null;
Integer instanceId = null;
long appId;
if (ClientExceptionType.REDIS_TYPE.getType() == exceptionType) {
// 实例host:port
String hostPort = MapUtils.getString(map, ClientReportConstant.EXCEPTION_HOST_PORT, "");
if (StringUtils.isEmpty(hostPort)) {
logger.warn("hostPort is empty", hostPort);
return null;
}
int index = hostPort.indexOf(":");
if (index <= 0) {
logger.warn("hostPort {} format is wrong", hostPort);
return null;
}
host = hostPort.substring(0, index);
port = NumberUtils.toInt(hostPort.substring(index + 1));
// 实例信息
InstanceInfo instanceInfo = clientReportInstanceService.getInstanceInfoByHostPort(host, port);
if (instanceInfo == null) {
// logger.warn("instanceInfo is empty, host is {}, port is {}", host, port);
return null;
}
// 实例id
instanceId = instanceInfo.getId();
// 应用id
appId = instanceInfo.getAppId();
} else {
List<AppClientVersion> appClientVersion = appClientVersionDao.getByClientIp(clientIp);
if (CollectionUtils.isNotEmpty(appClientVersion)) {
appId = appClientVersion.get(0).getAppId();
} else {
appId = 0;
}
}
// 组装AppClientExceptionStat
AppClientExceptionStat stat = new AppClientExceptionStat();
stat.setAppId(appId);
stat.setClientIp(clientIp);
stat.setReportTime(new Date(reportTime));
stat.setCollectTime(collectTime);
stat.setCreateTime(new Date());
stat.setExceptionClass(exceptionClass);
stat.setExceptionCount(exceptionCount);
stat.setInstanceHost(host);
stat.setInstancePort(port);
stat.setInstanceId(instanceId);
stat.setType(exceptionType);
return stat;
}
use of com.sohu.cache.entity.AppClientVersion in project cachecloud by sohutv.
the class ClientVersionServiceImpl method saveOrUpdateClientVersion.
@Override
public void saveOrUpdateClientVersion(long appId, String appClientIp, String clientVersion) {
try {
AppClientVersion appClientVersion = new AppClientVersion();
appClientVersion.setAppId(appId);
appClientVersion.setClientIp(appClientIp);
appClientVersion.setClientVersion(clientVersion);
appClientVersion.setReportTime(new Date());
appClientVersionDao.saveOrUpdateClientVersion(appClientVersion);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
}
use of com.sohu.cache.entity.AppClientVersion in project cachecloud by sohutv.
the class ClientVersionServiceImpl method getAppAllServerClientVersion.
@Override
public List<AppClientVersion> getAppAllServerClientVersion(long appId) {
List<AppClientVersion> appClientVersionList = getAppAllClientVersion(appId);
if (CollectionUtils.isEmpty(appClientVersionList)) {
return Collections.emptyList();
}
List<AppClientVersion> appClientVersionServerList = new ArrayList<AppClientVersion>();
for (AppClientVersion appClientVersion : appClientVersionList) {
String clientIp = appClientVersion.getClientIp();
String[] items = clientIp.split(".");
//过滤办公网段ip
if (!OFFICE_IP.contains(items[0] + "." + items[1])) {
appClientVersionServerList.add(appClientVersion);
}
}
return appClientVersionServerList;
}
Aggregations