/** * At the time of writing (4.10) platform top level services don't have children so this will be quick, but * write it to handle any future children. In general this will still be a relatively small number of resources. * * @param topLevelServices * @return The top level service hierarchy sync info */ private Set<ResourceSyncInfo> getToplevelServiceSyncInfo(Set<Resource> topLevelServices) { Set<ResourceSyncInfo> result = new HashSet<ResourceSyncInfo>(topLevelServices.size()); Set<Integer> topLevelServiceIds = new HashSet<Integer>(); for (Resource topLevelService : topLevelServices) { result.add(ResourceSyncInfo.buildResourceSyncInfo(topLevelService)); topLevelServiceIds.add(topLevelService.getId()); } getToplevelServiceSyncInfoHierarchy(topLevelServiceIds, result); return result; }
public static PlatformSyncInfo buildPlatformSyncInfo(Resource platform) { Set<Integer> toplevelServerIds = new HashSet<Integer>(); for (Resource r : platform.getChildResources()) { if (r.getResourceType().getCategory().equals(ResourceCategory.SERVER)) { toplevelServerIds.add(r.getId()); } } ResourceSyncInfo resSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platform); PlatformSyncInfo syncInfo = new PlatformSyncInfo(resSyncInfo, new HashSet<ResourceSyncInfo>(1), toplevelServerIds); return syncInfo; } }
@Override public PlatformSyncInfo getPlatformSyncInfo(Agent knownAgent) { Resource platform = resourceManager.getPlatform(knownAgent); if (null == platform) { return null; } Set<Resource> toplevelServices = new HashSet<Resource>(); Set<Integer> topLevelServerIds = new HashSet<Integer>(); for (Resource platformChild : platform.getChildResources()) { switch (platformChild.getResourceType().getCategory()) { case SERVER: topLevelServerIds.add(platformChild.getId()); break; case SERVICE: toplevelServices.add(platformChild); break; default: break; } } ResourceSyncInfo platformSyncInfo = ResourceSyncInfo.buildResourceSyncInfo(platform); Set<ResourceSyncInfo> topLevelServiceSyncInfo = getToplevelServiceSyncInfo(toplevelServices); PlatformSyncInfo result = new PlatformSyncInfo(platformSyncInfo, topLevelServiceSyncInfo, topLevelServerIds); return result; }