use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class ServerWebSocketInterceptor method checkNode.
private boolean checkNode(HttpServletRequest httpServletRequest, Map<String, Object> attributes, UserModel userModel) {
// 验证 node 权限
String nodeId = httpServletRequest.getParameter("nodeId");
if (!JpomApplication.SYSTEM_ID.equals(nodeId)) {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeModel nodeModel = nodeService.getByKey(nodeId, userModel);
if (nodeModel == null) {
return false;
}
//
attributes.put("nodeInfo", nodeModel);
}
return true;
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class NodeService method updateDuplicateNode.
/**
* 更新相同节点对 授权信息
*
* @param info 节点信息
*/
private void updateDuplicateNode(NodeModel info) {
if (StrUtil.hasEmpty(info.getUrl(), info.getLoginName(), info.getLoginPwd())) {
return;
}
NodeModel update = new NodeModel();
update.setLoginName(info.getLoginName());
update.setLoginPwd(info.getLoginPwd());
//
NodeModel where = new NodeModel();
where.setUrl(info.getUrl());
int updateCount = super.update(super.dataBeanToEntity(update), super.dataBeanToEntity(where));
if (updateCount > 1) {
DefaultSystemLog.getLog().debug("update duplicate node {} {}", info.getUrl(), updateCount);
}
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class NodeUpdateHandler method updateNodeItem.
private void updateNodeItem(String id, WebSocketSession session, AgentFileModel agentFileModel, boolean http) {
try {
NodeModel node = nodeService.getByKey(id);
if (node == null) {
this.onError(session, "没有对应的节点:" + id);
return;
}
NodeClient client = clientMap.get(node.getId());
if (client == null) {
this.onError(session, "对应的插件端还没有被初始化:" + id);
return;
}
if (client.isOpen()) {
if (http) {
this.updateNodeItemHttp(node, session, agentFileModel);
} else {
this.updateNodeItemWebSocket(client, id, session, agentFileModel);
}
} else {
this.onError(session, "节点连接丢失");
}
} catch (Exception e) {
DefaultSystemLog.getLog().error("升级失败:" + id, e);
this.onError(session, "节点升级失败:" + e.getMessage());
}
}
use of io.jpom.model.data.NodeModel in project Jpom by dromara.
the class CheckMonitor method init.
@PreLoadMethod
private static void init() {
// 缓存检测调度
CronUtils.upsert("cache_manger_schedule", "0 0/10 * * * ?", () -> {
BuildUtil.reloadCacheSize();
ConfigBean.getInstance().dataSize();
});
// 开启版本检测调度
CronUtils.upsert("system_monitor", "0 0 0,12 * * ?", () -> {
try {
BackupInfoService backupInfoService = SpringUtil.getBean(BackupInfoService.class);
backupInfoService.checkAutoBackup();
//
RemoteVersion.loadRemoteInfo();
} catch (Exception e) {
DefaultSystemLog.getLog().error("系统调度执行出现错误", e);
}
});
// 拉取 脚本模版日志
CronUtils.upsert("pull_script_log", "0 0/1 * * * ?", () -> {
NodeService nodeService = SpringUtil.getBean(NodeService.class);
NodeScriptServer nodeScriptServer = SpringUtil.getBean(NodeScriptServer.class);
List<String> nodeIds = nodeScriptServer.hasScriptNode();
if (nodeIds == null) {
return;
}
for (String nodeId : nodeIds) {
NodeModel nodeModel = nodeService.getByKey(nodeId);
if (nodeModel == null) {
continue;
}
ThreadUtil.execute(() -> CheckMonitor.pullScriptLogItem(nodeModel));
}
});
// 异步加载
CheckMonitor.asyncLoad();
}
Aggregations