public static boolean isServingOnlyUpToDateOrMoreRecent(RingGroup ringGroup, List<DomainAndVersion> domainVersions) throws IOException { for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDateOrMoreRecent(host, domainVersions)) { return false; } } } return true; }
public static boolean isServingOnlyUpToDate(RingGroup ringGroup) throws IOException { DomainGroup domainGroup = ringGroup.getDomainGroup(); for (Ring ring : ringGroup.getRings()) { for (Host host : ring.getHosts()) { if (host.getState() == HostState.SERVING && !Hosts.isUpToDate(host, domainGroup)) { return false; } } } return true; }
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; }
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; }
@Override public DomainAndVersion getDomainVersion(Domain domain) throws IOException { if (domain == null || domain.getName() == null) { return null; } for (DomainAndVersion domainVersion : getDomainVersions()) { if (domainVersion.getDomain() != null && domain.getId() == domainVersion.getDomain().getId()) { return domainVersion; } } return null; }
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 ServingStatusAggregator computeServingStatusAggregator(RingGroup ringGroup, DomainGroup domainGroup) throws IOException { ServingStatusAggregator servingStatusAggregator = new ServingStatusAggregator(); for (Ring ring : ringGroup.getRings()) { servingStatusAggregator.aggregate(Rings.computeServingStatusAggregator(ring, domainGroup)); } return servingStatusAggregator; }
public static long getTotalNumBytes(Domain domain) throws IOException { long total = 0; for (DomainVersion version : domain.getVersions()) { if (version.isDefunct()) { continue; } total += DomainVersions.getTotalNumBytes(version); } return total; }
@Override public Host getHostByAddress(PartitionServerAddress address) { for (Host host : hosts) { if (host.getAddress().equals(address)) { return host; } } return null; }
public static UpdateProgressAggregator computeUpdateProgress(RingGroup ringGroup, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (Ring ring : ringGroup.getRings()) { result.aggregate(Rings.computeUpdateProgress(ring, domainGroup)); } return result; }
public static UpdateProgressAggregator computeUpdateProgress(Ring ring, DomainGroup domainGroup) throws IOException { UpdateProgressAggregator result = new UpdateProgressAggregator(); for (Host host : ring.getHosts()) { result.aggregate(Hosts.computeUpdateProgress(host, domainGroup)); } return result; }
public static ServingStatusAggregator computeServingStatusAggregator(Ring ring, DomainGroup domainGroup) throws IOException { ServingStatusAggregator servingStatusAggregator = new ServingStatusAggregator(); for (Host host : ring.getHosts()) { servingStatusAggregator.aggregate(Hosts.computeServingStatusAggregator(host, domainGroup)); } return servingStatusAggregator; }
public static boolean isUpToDate(RingGroup ringGroup, DomainGroup domainGroup) throws IOException { for (Ring ring : ringGroup.getRings()) { if (!Rings.isUpToDate(ring, domainGroup)) { return false; } } return true; }
public static void run(CoordinatorConfigurator configurator, RunnableWithCoordinator runnableWithCoordinator) throws IOException { Coordinator coordinator = createCoordinator(configurator); try { runnableWithCoordinator.run(coordinator); } finally { coordinator.close(); } } }
public static boolean isUpToDate(Host host, DomainGroup domainGroup) throws IOException { if (domainGroup == null || domainGroup.getDomainVersions() == null) { return false; } if (!allPartitionsUpToDate(host, domainGroup.getDomainVersions(), false)) { return false; } if (isAssignedDeletablePartition(host)) { return false; } return true; }
public static long computeUpdateETA(Ring ring) { long maxUpdateETA = -1; for (Host host : ring.getHosts()) { long hostUpdateETA = Hosts.computeUpdateETA(host); if (hostUpdateETA > maxUpdateETA) { maxUpdateETA = hostUpdateETA; } } return maxUpdateETA; } }
public static boolean isUpToDate(RingGroup ringGroup, DomainGroup domainGroup, Domain domain) throws IOException { for (Ring ring : ringGroup.getRings()) { if (!Rings.isUpToDate(ring, domainGroup, domain)) { return false; } } return true; }