use of io.jpom.system.AuthorizeException in project Jpom by dromara.
the class NodeStatService method checkList.
private void checkList(List<NodeModel> nodeModels) {
if (CollUtil.isEmpty(nodeModels)) {
return;
}
nodeModels.forEach(nodeModel -> {
//
nodeModel.setName(nodeModel.getUrl());
List<NodeModel> modelList = this.getListByUrl(nodeModel.getUrl());
boolean match = modelList.stream().allMatch(NodeModel::isOpenStatus);
if (!match) {
// 节点都关闭
try {
BaseServerController.resetInfo(UserModel.EMPTY);
this.save(modelList, 4, "节点禁用中");
} finally {
BaseServerController.removeEmpty();
}
return;
}
nodeModel.setOpenStatus(1);
nodeModel.setTimeOut(5);
//
ThreadUtil.execute(() -> {
try {
BaseServerController.resetInfo(UserModel.EMPTY);
JSONObject nodeTopInfo = this.getNodeTopInfo(nodeModel);
//
long timeMillis = SystemClock.now();
JsonMessage<Object> jsonMessage = NodeForward.requestBySys(nodeModel, NodeUrl.Status, "nodeId", nodeModel.getId());
int networkTime = (int) (System.currentTimeMillis() - timeMillis);
JSONObject jsonObject;
if (jsonMessage.getCode() == 200) {
jsonObject = jsonMessage.getData(JSONObject.class);
} else {
// 状态码错
jsonObject = new JSONObject();
jsonObject.put("status", 3);
jsonObject.put("failureMsg", jsonMessage.toString());
}
jsonObject.put("networkTime", networkTime);
if (nodeTopInfo != null) {
nodeTopInfo.put("networkTime", networkTime);
}
this.save(modelList, nodeTopInfo, jsonObject);
} catch (AuthorizeException agentException) {
this.save(modelList, 2, agentException.getMessage());
} catch (Exception e) {
this.save(modelList, 1, e.getMessage());
DefaultSystemLog.getLog().error("获取节点监控信息失败", e);
} finally {
BaseServerController.removeEmpty();
}
});
});
}
Aggregations