Search in sources :

Example 61 with NodeModel

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;
}
Also used : NodeModel(io.jpom.model.data.NodeModel) NodeService(io.jpom.service.node.NodeService)

Example 62 with NodeModel

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);
    }
}
Also used : NodeModel(io.jpom.model.data.NodeModel)

Example 63 with NodeModel

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());
    }
}
Also used : NodeModel(io.jpom.model.data.NodeModel) NodeClient(io.jpom.socket.client.NodeClient) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException)

Example 64 with NodeModel

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();
}
Also used : NodeModel(io.jpom.model.data.NodeModel) BackupInfoService(io.jpom.service.dblog.BackupInfoService) NodeScriptServer(io.jpom.service.node.script.NodeScriptServer) NodeService(io.jpom.service.node.NodeService) PreLoadMethod(cn.jiangzeyin.common.PreLoadMethod)

Aggregations

NodeModel (io.jpom.model.data.NodeModel)64 JSONObject (com.alibaba.fastjson.JSONObject)27 Feature (io.jpom.permission.Feature)23 MethodFeature (io.jpom.permission.MethodFeature)23 ClassFeature (io.jpom.permission.ClassFeature)22 UserModel (io.jpom.model.data.UserModel)17 StrUtil (cn.hutool.core.util.StrUtil)12 NodeService (io.jpom.service.node.NodeService)12 Collectors (java.util.stream.Collectors)12 JsonMessage (cn.jiangzeyin.common.JsonMessage)11 List (java.util.List)11 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 CollUtil (cn.hutool.core.collection.CollUtil)9 DefaultSystemLog (cn.jiangzeyin.common.DefaultSystemLog)9 NodeForward (io.jpom.common.forward.NodeForward)8 NodeUrl (io.jpom.common.forward.NodeUrl)8 Assert (org.springframework.util.Assert)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 JSONArray (com.alibaba.fastjson.JSONArray)7 BaseServerController (io.jpom.common.BaseServerController)7