diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostEventsHandler.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostEventsHandler.java index a2959d8b57..f321d6c8dc 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostEventsHandler.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostEventsHandler.java @@ -70,12 +70,12 @@ void handleEvent(ResourceEvent event) { private void handleOneEventRelatedToApp(ResourceEvent event) { try { - log.info("start to handle event:{}", JsonUtils.toJson(event)); + log.info("start to handle host event:{}", JsonUtils.toJson(event)); handleOneEventIndeed(event); } catch (Throwable t) { log.error(String.format("Fail to handle hostEvent:%s", event), t); } finally { - log.info("end to handle event"); + log.info("end to handle host event"); } } diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostRelationEventsHandler.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostRelationEventsHandler.java index 76ceef8fed..f1cf156db4 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostRelationEventsHandler.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/service/impl/sync/HostRelationEventsHandler.java @@ -28,6 +28,7 @@ import com.tencent.bk.job.common.cc.model.result.HostRelationEventDetail; import com.tencent.bk.job.common.cc.model.result.ResourceEvent; import com.tencent.bk.job.common.model.dto.ApplicationHostDTO; +import com.tencent.bk.job.common.util.json.JsonUtils; import com.tencent.bk.job.manage.dao.ApplicationHostDAO; import com.tencent.bk.job.manage.dao.HostTopoDAO; import com.tencent.bk.job.manage.manager.host.HostCache; @@ -70,6 +71,7 @@ void handleEvent(ResourceEvent event) { } private void handleOneEvent(ResourceEvent event) { + log.info("start to handle host relation event:{}", JsonUtils.toJson(event)); HostTopoDTO hostTopoDTO = HostTopoDTO.fromHostRelationEvent(event.getDetail()); Long appId = hostTopoDTO.getBizId(); try { @@ -84,6 +86,8 @@ private void handleOneEvent(ResourceEvent event) { } } catch (Throwable t) { log.error(String.format("Fail to handle hostRelationEvent of appId %d, event:%s", appId, event), t); + } finally { + log.info("end to handle host relation event"); } } @@ -129,9 +133,11 @@ private void handleOneEventIndeed(ResourceEvent event) private void updateTopoToHost(HostTopoDTO hostTopoDTO) { // 若主机存在需将拓扑信息同步至主机信息冗余字段 int affectedNum = applicationHostDAO.syncHostTopo(dslContext, hostTopoDTO.getHostId()); - if (affectedNum == 0) { + if (affectedNum > 0) { + log.info("host topo synced: affectedNum={}", affectedNum); + } else if (affectedNum == 0) { log.info("no host topo synced"); - } else if (affectedNum < 0) { + } else { FormattingTuple msg = MessageFormatter.format( "cannot find hostInfo by hostId:{}, wait for host event or sync", hostTopoDTO.getHostId() @@ -149,6 +155,7 @@ private void updateHostCacheWhenRelCreated(HostTopoDTO hostTopoDTO) { ApplicationHostDTO host = applicationHostDAO.getHostById(hostTopoDTO.getHostId()); if (host != null && applicationService.existBiz(host.getBizId())) { hostCache.addOrUpdateHost(host); + log.info("host cached updated: hostId={}", host.getHostId()); } } @@ -174,10 +181,12 @@ private void updateHostCacheWhenRelationDeleted(HostTopoDTO hostTopoDTO) { if (hostRelationCount == 0) { // 主机被移除 hostCache.deleteHost(host); + log.info("host cached deleted: hostId={}", host.getHostId()); } else { // 主机被转移到其他业务下 if (applicationService.existBiz(host.getBizId())) { hostCache.addOrUpdateHost(host); + log.info("host cached updated: hostId={}", host.getHostId()); } } }