public static boolean isUpToDate(Host host, DomainGroup domainGroup, Domain domain) throws IOException { if (domain == null || domain.getVersions() == null) { return false; } Set<DomainAndVersion> domainAndVersion = new HashSet<>(); domainAndVersion.add(domainGroup.getDomainVersion(domain)); return isUpToDateOrMoreRecent(host, domainAndVersion); }
public static boolean isCurrentlyServed(Domain domain, DomainVersion domainVersion, Coordinator coord) throws IOException { for (DomainGroup domainGroup : coord.getDomainGroups()) { DomainAndVersion version = domainGroup.getDomainVersion(domain); if (version != null) { if (version.getVersionNumber() == domainVersion.getVersionNumber()) { return true; } } } return false; }
private DomainDeployStatusForRingGroup getDomainDeployStatusForRingGroup(DomainGroup domainGroup, Domain domain, RingGroup ringGroup) throws IOException { DomainDeployStatusForRingGroup status = new DomainDeployStatusForRingGroup(); status.ringGroupName = ringGroup.getName(); if (domainGroup != null) { status.targetDomainVersion = domainGroup.getDomainVersion(domain) == null ? null : domainGroup.getDomainVersion(domain).getVersionNumber(); } ServingStatus servingStatus = RingGroups.computeServingStatusAggregator(ringGroup, domainGroup).computeServingStatus(); status.numPartitions = servingStatus.getNumPartitions(); status.numPartitionsServedAndUpToDate = servingStatus.getNumPartitionsServedAndUpToDate(); return status; }
protected DomainDeployStatus getDomainDeployStatus(Domain domain) throws IOException { DomainDeployStatus status = new DomainDeployStatus(); status.domainName = domain.getName(); Map<String, DomainDeployStatusForRingGroup> ringGroupsMap = new HashMap<String, DomainDeployStatusForRingGroup>(); for (RingGroup ringGroup : coordinator.getRingGroups()) { DomainGroup domainGroup = ringGroup.getDomainGroup(); if (domainGroup != null && domainGroup.getDomainVersion(domain) != null) { ringGroupsMap.put(ringGroup.getName(), getDomainDeployStatusForRingGroup(domainGroup, domain, ringGroup)); } } status.ringGroupsMap = ringGroupsMap; return status; }
protected void addDomainsToRingGroup(Coordinator coordinator, RingGroup ringGroup) throws IOException { // for each configured domain for (RingGroupConfiguredDomain configuredDomain : configuredDomains) { Domain domain = coordinator.getDomain(configuredDomain.getName()); DomainAndVersion version = ringGroup.getDomainGroup().getDomainVersion(domain); if (version == null) { // either there are no versions, which is fine DomainVersion latestClosedVersion = Domains.getLatestVersionNotOpenNotDefunct(domain); if (latestClosedVersion != null) { int versionToAdd = latestClosedVersion.getVersionNumber(); LOG.info("Adding domain " + domain.getName() + " version " + versionToAdd + " to domain group: " + ringGroup.getName()); ringGroup.getDomainGroup().setDomainVersion(domain, versionToAdd); } } } }
ringGroup.getDomainGroup().getDomainVersion(domain);
public static ServingStatusAggregator computeServingStatusAggregator(Host host, DomainGroup domainGroup) throws IOException { ServingStatusAggregator result = new ServingStatusAggregator(); for (HostDomain hostDomain : host.getAssignedDomains()) { DomainAndVersion domainVersion = domainGroup.getDomainVersion(hostDomain.getDomain()); // Ignore domains that are not relevant if (domainVersion != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { // Check if partition is served and up to date boolean servedAndUpToDate = host.getState() == HostState.SERVING && partition.getCurrentDomainVersion() != null && partition.getCurrentDomainVersion().equals(domainVersion.getVersionNumber()); // Aggregate counts result.add(hostDomain.getDomain(), partition.getPartitionNumber(), servedAndUpToDate); } } } } return result; }