@Override public String toString() { return getDomain().getName() + "@v" + getVersionNumber(); }
@Override public String toString() { StringBuilder domainVersionsString = new StringBuilder(); domainVersionsString.append('['); try { if (getDomainVersions() != null) { for (DomainAndVersion dgvdv : getDomainVersionsSorted()) { domainVersionsString.append(dgvdv.getDomain() != null ? dgvdv.getDomain().getName() : "null"); domainVersionsString.append('@'); domainVersionsString.append(dgvdv.getVersionNumber()); domainVersionsString.append(", "); } } } catch (IOException e) { throw new RuntimeException(e); } domainVersionsString.append(']'); return "AbstractDomainGroup [name=" + getName() + ", domainVersions=" + domainVersionsString.toString() + "]"; } }
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; }
protected DomainGroupData getDomainGroupData(DomainGroup domainGroup) throws IOException { DomainGroupData data = new DomainGroupData(); data.name = domainGroup.getName(); Map<String, Integer> versionsMap = new HashMap<String, Integer>(); for (DomainAndVersion v : domainGroup.getDomainVersions()) { versionsMap.put(v.getDomain().getName(), v.getVersionNumber()); } data.domainVersions = versionsMap; return data; }
public static String formatDomainGroupDomainVersionsTable(DomainGroup domainGroup, String cssClass, boolean linkToDomains) throws IOException { StringBuilder content = new StringBuilder(); content.append("<table class='" + cssClass + "'><tr><th>Domain</th><th>Version</th><th>Closed On</th></tr>"); for (DomainAndVersion version : domainGroup.getDomainVersionsSorted()) { content.append("<tr><td class='centered'>"); if (linkToDomains) { content.append("<a href='/domain.jsp?n=" + URLEnc.encode(version.getDomain().getName()) + "'>"); content.append(version.getDomain().getName()); content.append("</a>"); } else { content.append(version.getDomain().getName()); } content.append("</td><td class='centered'>"); content.append(version.getVersionNumber()); content.append("</td><td class='centered'>"); content.append(formatDomainVersionClosedAt(version.getDomain().getVersion(version.getVersionNumber()))); content.append("</td></tr>"); } content.append("</table>"); return content.toString(); }
private static boolean allPartitionsUpToDate(Host host, Collection<DomainAndVersion> domainVersions, boolean allowMoreRecentDomainVersions) throws IOException { // Check that each domain of the given domain group version is up to date on this host for (DomainAndVersion domainAndVersion : domainVersions) { Domain domain = domainAndVersion.getDomain(); HostDomain hostDomain = host.getHostDomain(domain); if (hostDomain != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { // If the partition is not currently at the given domain group version, the host is not up-to-date if (partition.getCurrentDomainVersion() == null || (!allowMoreRecentDomainVersions && partition.getCurrentDomainVersion() != domainAndVersion.getVersionNumber()) || (allowMoreRecentDomainVersions && (partition.getCurrentDomainVersion() < domainAndVersion.getVersionNumber()))) { LOG.info("Host " + host.getAddress().getHostName() + " is not up to date for domain " + domain.getName() + " and version " + domainAndVersion.getVersionNumber()); LOG.info("Host " + host.getAddress().getHostName() + " has a partition on domain " + domain.getName() + " at version " + partition.getCurrentDomainVersion()); return false; } } } } } return true; }
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; }
public static UpdateProgressAggregator computeUpdateProgress(Host host, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (DomainAndVersion dgvdv : domainGroup.getDomainVersions()) { Domain domain = dgvdv.getDomain(); HostDomain hostDomain = host.getHostDomain(domain); if (hostDomain != null) { for (HostDomainPartition partition : hostDomain.getPartitions()) { // Ignore deletable partitions if (!partition.isDeletable()) { if (partition.getCurrentDomainVersion() != null && partition.getCurrentDomainVersion().equals(dgvdv.getVersionNumber())) { result.add(domain, true); } else { result.add(domain, false); } } } } } return result; }
domain.getVersion(targetDomainAndVersion.getVersionNumber());
assertEquals(0, dg.getDomainVersion(d0).getVersionNumber()); assertEquals(0, dg.getDomainVersion(d1).getVersionNumber()); return dg.getDomainVersion(d0).getVersionNumber() != 0; } catch (IOException e) { throw new RuntimeException(e); assertEquals(1, dg.getDomainVersion(d0).getVersionNumber()); assertEquals(1, dg.getDomainVersion(d1).getVersionNumber());
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; }