Esempio n. 1
0
 /**
  * Return true if all partitions assigned to that host for domains of the given domain group
  * version are at the correct version. And there are no deletable partitions.
  *
  * @param host
  * @param domainGroupVersion
  * @return
  * @throws IOException
  */
 public static boolean isUpToDate(Host host, DomainGroupVersion domainGroupVersion)
     throws IOException {
   if (domainGroupVersion == null || domainGroupVersion.getDomainVersions() == null) {
     return false;
   }
   // Check that each domain of the given domain group version is up to date on this host
   for (DomainGroupVersionDomainVersion dgvdv : domainGroupVersion.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 the partition is not currently at the given domain group version, the host is not
           // up-to-date
           if (partition.getCurrentDomainGroupVersion() == null
               || partition.getCurrentDomainGroupVersion()
                   != domainGroupVersion.getVersionNumber()) {
             return false;
           }
         }
       }
     }
   }
   // Check if there is any deletable partition
   for (HostDomain hostDomain : host.getAssignedDomains()) {
     for (HostDomainPartition partition : hostDomain.getPartitions()) {
       if (partition.isDeletable()) {
         return false;
       }
     }
   }
   return true;
 }
Esempio n. 2
0
 public static ServingStatusAggregator computeServingStatusAggregator(
     Host host, DomainGroupVersion domainGroupVersion) throws IOException {
   ServingStatusAggregator result = new ServingStatusAggregator();
   for (HostDomain hostDomain : host.getAssignedDomains()) {
     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.getCurrentDomainGroupVersion() != null
                 && partition
                     .getCurrentDomainGroupVersion()
                     .equals(domainGroupVersion.getVersionNumber());
         // Aggregate counts
         result.add(hostDomain.getDomain(), partition.getPartitionNumber(), servedAndUpToDate);
       }
     }
   }
   return result;
 }
Esempio n. 3
0
 public static UpdateProgress computeUpdateProgress(
     Host host, DomainGroupVersion domainGroupVersion) throws IOException {
   int numPartitions = 0;
   int numPartitionsUpToDate = 0;
   for (DomainGroupVersionDomainVersion dgvdv : domainGroupVersion.getDomainVersions()) {
     Domain domain = dgvdv.getDomain();
     HostDomain hostDomain = host.getHostDomain(domain);
     if (hostDomain != null) {
       for (HostDomainPartition partition : hostDomain.getPartitions()) {
         // Ignore deletable partitions
         if (!partition.isDeletable()) {
           ++numPartitions;
           if (partition.getCurrentDomainGroupVersion() != null
               && partition
                   .getCurrentDomainGroupVersion()
                   .equals(domainGroupVersion.getVersionNumber())) {
             ++numPartitionsUpToDate;
           }
         }
       }
     }
   }
   return new UpdateProgress(numPartitions, numPartitionsUpToDate);
 }