コード例 #1
0
 GroupNode findOrCreateSystemNode(MonitorEngine engine) {
   ManagedNode infNode = nodeService.findByPath(ManagedNode.INFRASTRUCTURE_PATH);
   // 兼容手工创建时,引擎资源节点存在对应管理节点的情况
   // 创建 引擎系统 群组,其中存放监控服务器,监控引擎,相关redis/mysql/nginx等自带应用
   GroupNode engineSystemGroupNode;
   try {
     engineSystemGroupNode = (GroupNode) nodeService.findByPath(engine.getSystemPath());
   } catch (IllegalArgumentException e) {
     // Not found exception
     engineSystemGroupNode = new GroupNode();
     engineSystemGroupNode.cascadeCreating();
     engineSystemGroupNode.setPath(engine.getSystemPath());
     if (engine.isDefault()) {
       engineSystemGroupNode.setLabel("缺省监控系统");
     } else {
       engineSystemGroupNode.setLabel(engine.getLabel() + "系统");
     }
     engineSystemGroupNode.setIcon("monitor_system");
     engineSystemGroupNode.setComment("Auto created system group node for " + engine.getLabel());
     try {
       nodeService.create(infNode, engineSystemGroupNode);
     } catch (NodeException ex) {
       throw new ApplicationContextException("Can't auto create engine group node", ex);
     }
   }
   return engineSystemGroupNode;
 }
コード例 #2
0
 void createEngineNode(MonitorEngine engine, GroupNode engineSystemGroupNode) {
   // 在引擎系统中,添加引擎自身这个节点
   String enginePath = engine.getSystemPath() + "/engine";
   ResourceNode engineNode;
   try {
     nodeService.findByPath(enginePath);
   } catch (Exception e) {
     engineNode = new ResourceNode();
     // 说明该节点是在创建引擎后被级联自动创建的
     engineNode.cascadeCreating();
     engineNode.setResource(engine);
     engineNode.setPath(enginePath);
     engineNode.setLabel(engine.getLabel());
     engineNode.setIcon("monitor_engine");
     engineNode.setState(State.Running);
     engineNode.setComment("Auto created engine node for " + engine.getLabel());
     try {
       nodeService.create(engineSystemGroupNode, engineNode);
     } catch (NodeException ex) {
       throw new ApplicationContextException("Can't auto create engine node", ex);
     }
   }
 }