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()); } } }
public static void addPartition(HostDomain hostDomain, int partitionNumber) throws IOException { HostDomainPartition partition = hostDomain.getPartitionByNumber(partitionNumber); if (partition == null) { hostDomain.addPartition(partitionNumber); } } }
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()); }
@Override public HostDomain getHostDomain(Domain domain) { // TODO: this should be done with a map and caching try { for (HostDomain hostDomain : getAssignedDomains()) { if (hostDomain.getDomain().equals(domain)) { return hostDomain; } } } catch (IOException e) { throw new RuntimeException(e); } return null; }
for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable() && (partitionMappings == null || HostDomainPartition partition = hostDomain.getPartitionByNumber(partitionMapping); if (partition == null) { return false; if (!domains.contains(hostDomain.getDomain())) { for (HostDomainPartition partition : hostDomain.getPartitions()) { if (!partition.isDeletable()) { return false;
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; }
private void doDeleteOrUndeletePartition(HttpServletRequest req, HttpServletResponse resp, boolean deletable) throws IOException { RingGroup rg = coordinator.getRingGroup(req.getParameter("g")); Ring r = rg.getRing(Integer.parseInt(req.getParameter("n"))); Host h = r.getHostByAddress(PartitionServerAddress.parse(URLEnc.decode(req.getParameter("h")))); HostDomain hd = h.getHostDomain(coordinator.getDomain(req.getParameter("d"))); HostDomainPartition hdp = hd.getPartitionByNumber(Integer.parseInt(req.getParameter("p"))); hdp.setDeletable(deletable); redirectBack(resp, rg, r, h); }
dataLocationChangeListener.clear(); HostDomainPartition hostDomainPartition = hostDomain.addPartition(0); WaitUntil.orDie(() -> !dataLocationChangeListener.isCalled()); assertFalse(dataLocationChangeListener.isCalled());
public PartitionUpdateTask(HostDomain hostDomain, HostDomainPartition partition, PartitionUpdateTaskStatisticsAggregator partitionUpdateTaskStatisticsAggregator, List<Throwable> encounteredThrowables, DiskPartitionAssignment assignment) { this.hostDomain = hostDomain; this.encounteredThrowables = encounteredThrowables; this.domain = hostDomain.getDomain(); this.partition = partition; this.assignment = assignment; this.partitionUpdateTaskStatisticsAggregator = partitionUpdateTaskStatisticsAggregator; // Register itself in the aggregator partitionUpdateTaskStatisticsAggregator.register(this); }
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; }
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; }
public String getName() { return hostDomain.getDomain().getName(); }
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; }
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) {
DomainAccessor(HostDomain hostDomain, PartitionAccessor[] partitionAccessors, Partitioner partitioner, int getTimerAggregatorWindow) throws IOException { this.hostDomain = hostDomain; this.partitionAccessors = partitionAccessors; this.partitioner = partitioner; this.getRequestsTimerAggregator = new HankTimerEventAggregator("GET " + hostDomain.getDomain().getName(), getTimerAggregatorWindow); }
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 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; }
@Override public int compareTo(HostDomain hostDomain) { return getDomain().compareTo(hostDomain.getDomain()); }
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; }