void cleanupEngineHost(MonitorEngine engine) throws ResourceException { Host host = engine.getHost(); // TODO 如果是默认引擎所在的主机,其还与监控服务器,以及其他应用存在RunAt关系这些关系还没清除掉 // 最终逻辑,应该是监控引擎删除/尝试删除所依赖的组件(存在server的情况下删除不掉) // 而后删除 引擎 + 主机的 RunAt关系 // 尝试删除主机(但是由于未能将server, mysql, redis等组件删除,所以主机存在关系,无法删除) if (host != null) { LinkService linkService = serviceLocator.locateLinkService(LinkType.RunOn.name()); if (linkService == null) throw new IllegalStateException( "Can't find link service for link type = " + LinkType.RunOn); linkService.unlink(engine, host, LinkType.RunOn); //noinspection unchecked HostService<Host> hostService = (HostService<Host>) serviceLocator.locate(host.getType()); try { hostService.delete(host); } catch (ResourceException e) { logger.warn("Can't delete the engine host, because of there are some legacy links ", e); } } }