private void garbageCollectHostDomains(Host host) throws IOException { // Delete deletable domains and partitions for (HostDomain hostDomain : host.getAssignedDomains()) { // Host domain does not contain anymore partitions. Delete it LOG.info("Host Domain " + hostDomain + " is assigned " + hostDomain.getPartitions().size() + " partitions."); if (hostDomain.getPartitions().size() == 0) { LOG.info("Garbage collecting Host Domain " + hostDomain + " as it is not used anymore."); host.removeDomain(hostDomain.getDomain()); } } }
private static boolean isAssignedDeletablePartition(Host host) throws IOException { for (HostDomain hostDomain : host.getAssignedDomains()) { for (HostDomainPartition partition : hostDomain.getPartitions()) { if (partition.isDeletable()) { return true; } } } return false; }
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 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; }
private ArrayList<PartitionUpdateTask> buildPartitionUpdateTasks( PartitionUpdateTaskStatisticsAggregator partitionUpdateTaskStatisticsAggregator, List<Throwable> encounteredThrowables) throws IOException { ArrayList<PartitionUpdateTask> partitionUpdateTasks = new ArrayList<PartitionUpdateTask>(); for (HostDomain hostDomain : host.getAssignedDomains()) { StorageEngine engine = hostDomain.getDomain().getStorageEngine(); DiskPartitionAssignment assignments = engine.getDataDirectoryPerPartition(configurator, getPartitionNumbers(hostDomain.getPartitions())); for (HostDomainPartition partition : hostDomain.getPartitions()) { partitionUpdateTasks.add( new PartitionUpdateTask( hostDomain, partition, partitionUpdateTaskStatisticsAggregator, encounteredThrowables, assignments)); } } // Sort update tasks per partition id, so that we update domains concurrently but in order of partition number Collections.sort(partitionUpdateTasks); return partitionUpdateTasks; }
StorageEngine storageEngine = hostDomain.getDomain().getStorageEngine(); DiskPartitionAssignment assignments = storageEngine.getDataDirectoryPerPartition(configurator, getPartitionNumbers(hostDomain.getPartitions())); for (HostDomainPartition hostDomainPartition : hostDomain.getPartitions()) { Integer versionNumber = hostDomainPartition.getCurrentDomainVersion(); if (versionNumber != null) {
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; }
for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable() && (partitionMappings == null || for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable()) { return false;
newDomainToPartitionToPartitionServerAddressList.put(domain.getId(), partitionToAdresses); for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable()) { List<HostAddress> partitionsList = partitionToAdresses.get(partition.getPartitionNumber());
return LiveReplicaStatus.UNDER_REPLICATED; for (HostDomainPartition partition : hostDomain.getPartitions()) { if (partitionToNumFullyServing.containsKey(partition.getPartitionNumber())) {
for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable() && (partitionMappings == null || for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable()) { partition.setDeletable(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; }
HostDomain hostDomain = host.getHostDomain(dgdv.getDomain()); if (hostDomain != null) { Set<HostDomainPartition> partitions = hostDomain.getPartitions(); if (partitions != null) { for (HostDomainPartition partition : partitions) { continue; Set<HostDomainPartition> partitions = hostDomain.getPartitions(); if (partitions == null) { LOG.error(String.format("Could not get partitions assignements of HostDomain %s. Skipping.", hostDomain));
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; }
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; }