@Override public int compareTo(PartitionUpdateTask other) { if (partition.getPartitionNumber() < other.partition.getPartitionNumber()) { return -1; } else if (partition.getPartitionNumber() > other.partition.getPartitionNumber()) { return 1; } else { return 0; } } }
private static Set<Integer> getPartitionNumbers(Collection<HostDomainPartition> partition) { Set<Integer> partitionNumbers = Sets.newHashSet(); for (HostDomainPartition hostDomainPartition : partition) { partitionNumbers.add(hostDomainPartition.getPartitionNumber()); } return partitionNumbers; } }
@Override public HostDomainPartition getPartitionByNumber(int partNum) throws IOException { for (HostDomainPartition p : getPartitions()) { if (p.getPartitionNumber() == partNum) { return p; } } return null; }
@Override public int compareTo(HostDomainPartition o) { return Integer.valueOf(getPartitionNumber()).compareTo(o.getPartitionNumber()); }
public String getDataDirectory() { return assignment.getDisk(partition.getPartitionNumber()); }
private void deletePartition(HostDomain hostDomain, HostDomainPartition partition) throws IOException { LOG.info("Deleting Domain " + hostDomain.getDomain().getName() + " partition " + partition.getPartitionNumber()); Deleter deleter = hostDomain.getDomain().getStorageEngine().getDeleter(assignment, partition.getPartitionNumber()); deleter.delete(); hostDomain.removePartition(partition.getPartitionNumber()); }
public static Set<Host> getHostsForDomainPartition(Ring ring, Domain domain, int partition) throws IOException { Set<Host> results = new HashSet<Host>(); for (Host host : ring.getHosts()) { HostDomain domainById = host.getHostDomain(domain); for (HostDomainPartition hdpc : domainById.getPartitions()) { if (hdpc.getPartitionNumber() == partition) { results.add(host); break; } } } return results; }
Integer versionNumber = hostDomainPartition.getCurrentDomainVersion(); if (versionNumber != null) { for (String filePath : storageEngine.getFiles(assignments, versionNumber, hostDomainPartition.getPartitionNumber())) { File file = new File(filePath);
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; }
if (partitionToNumFullyServing.containsKey(partition.getPartitionNumber())) { Set<Host> servingHosts = partitionToNumFullyServing.get(partition.getPartitionNumber()); allStatuses.add(statusFor( totalRings, Long count = domainPartitionBucketCounts.get(domain, partition.getPartitionNumber(), bucket);
List<HostAddress> partitionsList = partitionToAdresses.get(partition.getPartitionNumber()); if (partitionsList == null) { partitionsList = new ArrayList<HostAddress>(); partitionToAdresses.put(partition.getPartitionNumber(), partitionsList);
LOG.info(String.format( "Skipping partition update of domain %s partition %d to version %d (it is already up-to-date).", domain.getName(), partition.getPartitionNumber(), targetDomainVersion.getVersionNumber())); return; LOG.info(String.format( "Starting partition update of domain %s partition %d to version %d in %s.", domain.getName(), partition.getPartitionNumber(), targetDomainVersion.getVersionNumber(), getDataDirectory())); storageEngine.getUpdater(assignment, partition.getPartitionNumber()).updateTo(targetDomainVersion, statistics); LOG.info(String.format( "Completed partition update of domain %s partition %d to version %d.", domain.getName(), partition.getPartitionNumber(), targetDomainVersion.getVersionNumber())); domain.getName(), partition.getPartitionNumber()), t); encounteredThrowables.add(t); } finally {
if (!partition.isDeletable() && (partitionMappings == null || !partitionMappings.contains(partition.getPartitionNumber()))) { return false;
partitionNumbers.add(partition.getPartitionNumber()); LOG.error(String.format( "Could not load Reader for partition #%d of Domain %s because the partition's current version is null.", partition.getPartitionNumber(), domain.getName())); continue; reader = engine.getReader(configurator.getReaderConfigurator(numTotalPartitions), partition.getPartitionNumber(), assignment); } catch (IOException | IllegalArgumentException e) { partition.getPartitionNumber(), domain.getName()); LOG.error(msg, e); exceptions.add(new IOException(msg, e)); partition.getPartitionNumber(), domain.getName(), reader.getVersionNumber(), partition.getCurrentDomainVersion()); LOG.error(msg); exceptions.add(new IOException(msg)); domain.getName(), partition.getPartitionNumber())); partitionAccessors[partition.getPartitionNumber()] = new PartitionAccessor(partition, reader);
if (!partition.isDeletable() && (partitionMappings == null || !partitionMappings.contains(partition.getPartitionNumber()))) { partition.setDeletable(true);
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; }