예제 #1
0
파일: Hosts.java 프로젝트: sidoh/hank
 /**
  * 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;
 }
예제 #2
0
파일: Hosts.java 프로젝트: sidoh/hank
 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;
 }
예제 #3
0
파일: Hosts.java 프로젝트: sidoh/hank
 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);
 }
예제 #4
0
파일: Hosts.java 프로젝트: sidoh/hank
 /**
  * Returns true when the host is online. Note that this is distinct from "serving data" - a host
  * is online when it's NOT offline.
  *
  * @param host
  * @return
  * @throws IOException
  */
 public static boolean isOnline(Host host) throws IOException {
   return host.getState() != HostState.OFFLINE;
 }
예제 #5
0
파일: Hosts.java 프로젝트: sidoh/hank
 public static void enqueueCommandIfNotPresent(Host host, HostCommand command) throws IOException {
   if (host.getCurrentCommand() != command && !host.getCommandQueue().contains(command)) {
     host.enqueueCommand(command);
   }
 }