public static boolean isServable(Host host) throws IOException { int numPartitions = 0; for (HostDomain hostDomain : host.getAssignedDomains()) { for (HostDomainPartition hostDomainPartition : hostDomain.getPartitions()) { ++numPartitions; if (hostDomainPartition.getCurrentDomainVersion() == null) { return false; } } } return numPartitions != 0; }
public static Map<Domain, Map<Integer, Set<Host>>> domainToPartitionToHostsServing(RingGroup ringGroup, HostReplicaStatus config) throws IOException { Map<Domain, Map<Integer, Set<Host>>> result = new HashMap<>(); // Compute num replicas fully serving for all partitions for (Ring ring : ringGroup.getRings()) { for (Host h : ring.getHosts()) { if (isFullyServing(h, false, config)) { for (HostDomain hostDomain : h.getAssignedDomains()) { Domain domain = hostDomain.getDomain(); for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable() && partition.getCurrentDomainVersion() != null) { int partitionNumber = partition.getPartitionNumber(); Map<Integer, Set<Host>> partitionToNumFullyServing = result.get(domain); if (partitionToNumFullyServing == null) { partitionToNumFullyServing = new HashMap<Integer, Set<Host>>(); result.put(domain, partitionToNumFullyServing); } if (!partitionToNumFullyServing.containsKey(partitionNumber)) { partitionToNumFullyServing.put(partitionNumber, new HashSet<Host>()); } partitionToNumFullyServing.get(partitionNumber).add(h); } } } } } } return result; }
Integer versionNumber = hostDomainPartition.getCurrentDomainVersion(); if (versionNumber != null) { for (String filePath : storageEngine.getFiles(assignments, versionNumber, hostDomainPartition.getPartitionNumber())) {
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; }
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; }
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; }
if (partition.getCurrentDomainVersion() != null && partition.getCurrentDomainVersion().equals(targetDomainVersion.getVersionNumber())) { LOG.info(String.format( "Skipping partition update of domain %s partition %d to version %d (it is already up-to-date).",
if (partitions != null) { for (HostDomainPartition partition : partitions) { if (partition.getCurrentDomainVersion() != null) { numTotalPartitions += 1; if (partition.getCurrentDomainVersion() == null) { LOG.error(String.format( "Could not load Reader for partition #%d of Domain %s because the partition's current version is null.", if (reader.getVersionNumber() != null && !reader.getVersionNumber().equals(partition.getCurrentDomainVersion())) { partition.getPartitionNumber(), domain.getName(), reader.getVersionNumber(), partition.getCurrentDomainVersion()); LOG.error(msg); exceptions.add(new IOException(msg));