Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 package org.jclouds.cloudstack.domain;
 
 import static com.google.common.base.CaseFormat.UPPER_CAMEL;
 import static com.google.common.base.CaseFormat.UPPER_UNDERSCORE;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Date;
 import java.util.Set;
 
 
Represents a host issued by Cloudstack

Author(s):
Andrei Savu
 
 public class Host implements Comparable<Host> {
 
    public static enum ClusterType {
       CLOUD_MANAGED,
       EXTERNAL_MANAGED,
       UNKNOWN;
 
       public static ClusterType fromValue(String value) {
          try {
             return valueOf(.to(value));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
 
       @Override
       public String toString() {
          return .to(name());
       }
    }
 
    public static enum State {
       CONNECTING,
       UP,
       DOWN,
       DISCONNECTED,
       UPDATING,
       PREPARE_FOR_MAINTENANCE,
       ERROR_IN_MAINTENANCE,
       MAINTENANCE,
       ALERT,
       REMOVED,
       REBALANCING,
       UNKNOWN;
 
       public static State fromValue(String value) {
          try {
             return valueOf(.to(value));
          } catch (IllegalArgumentException e) {
             return ;
          }
       }
 
       @Override
       public String toString() {
          return .to(name());
       }
    }
 
    public static enum Type {
       STORAGE,
       ROUTING,
       SECONDARY_STORAGE,
       SECONDARY_STORAGE_CMD_EXECUTOR,
       CONSOLE_PROXY,
       EXTERNAL_FIREWALL,
       EXTERNAL_LOAD_BALANCER,
       PXE_SERVER,
       TRAFFIC_MONITOR,
       EXTERNAL_DHCP,
       SECONDARY_STORAGE_VM,
       LOCAL_SECONDARY_STORAGE,
      UNKNOWN;
      public static Type fromValue(String value) {
         try {
            if (value.equals("SecondaryStorageVM")) {
               return ;
            }
            return valueOf(.to(value));
         } catch (IllegalArgumentException e) {
            return ;
         }
      }
      @Override
      public String toString() {
         if (this == ) {
            return "SecondaryStorageVM"// note the inconsistency in VM naming
         }
         return .to(name());
      }
   }
   public static Builder<?> builder() {
      return new ConcreteBuilder();
   }
   public Builder<?> toBuilder() {
      return new ConcreteBuilder().fromHost(this);
   }
   public abstract static class Builder<T extends Builder<T>> {
      protected abstract T self();
      protected String id;
      protected AllocationState allocationState;
      protected int averageLoad;
      protected String capabilities;
      protected String clusterId;
      protected String clusterName;
      protected Host.ClusterType clusterType;
      protected String cpuAllocated;
      protected int cpuNumber;
      protected int cpuSpeed;
      protected String cpuUsed;
      protected float cpuWithOverProvisioning;
      protected Date created;
      protected Date disconnected;
      protected long diskSizeAllocated;
      protected long diskSizeTotal;
      protected String events;
      protected boolean hasEnoughCapacity;
      protected ImmutableSet.Builder<Stringtags = ImmutableSet.<String>builder();
      protected String hypervisor;
      protected String ipAddress;
      protected boolean localStorageActive;
      protected String jobId;
      protected AsyncJob.Status jobStatus;
      protected Date lastPinged;
      protected String managementServerId;
      protected long memoryAllocated;
      protected long memoryTotal;
      protected long memoryUsed;
      protected String name;
      protected long networkKbsRead;
      protected long networkKbsWrite;
      protected String osCategoryId;
      protected String osCategoryName;
      protected String podId;
      protected String podName;
      protected Date removed;
      protected Host.State state;
      protected Host.Type type;
      protected String version;
      protected String zoneId;
      protected String zoneName;

      

See also:
Host.getId()
      public T id(String id) {
         this. = id;
         return self();
      }

      
      public T allocationState(AllocationState allocationState) {
         this. = allocationState;
         return self();
      }

      
      public T averageLoad(int averageLoad) {
         this. = averageLoad;
         return self();
      }

      
      public T capabilities(String capabilities) {
         this. = capabilities;
         return self();
      }

      
      public T clusterId(String clusterId) {
         this. = clusterId;
         return self();
      }

      
      public T clusterName(String clusterName) {
         this. = clusterName;
         return self();
      }

      
      public T clusterType(Host.ClusterType clusterType) {
         this. = clusterType;
         return self();
      }

      
      public T cpuAllocated(String cpuAllocated) {
         this. = cpuAllocated;
         return self();
      }

      
      public T cpuNumber(int cpuNumber) {
         this. = cpuNumber;
         return self();
      }

      
      public T cpuSpeed(int cpuSpeed) {
         this. = cpuSpeed;
         return self();
      }

      
      public T cpuUsed(String cpuUsed) {
         this. = cpuUsed;
         return self();
      }

      
      public T cpuWithOverProvisioning(float cpuWithOverProvisioning) {
         this. = cpuWithOverProvisioning;
         return self();
      }

      
      public T created(Date created) {
         this. = created;
         return self();
      }

      
      public T disconnected(Date disconnected) {
         this. = disconnected;
         return self();
      }

      
      public T diskSizeAllocated(long diskSizeAllocated) {
         this. = diskSizeAllocated;
         return self();
      }

      
      public T diskSizeTotal(long diskSizeTotal) {
         this. = diskSizeTotal;
         return self();
      }

      
      public T events(String events) {
         this. = events;
         return self();
      }

      
      public T hasEnoughCapacity(boolean hasEnoughCapacity) {
         this. = hasEnoughCapacity;
         return self();
      }

      

See also:
Host.getTags()
      public T tags(Iterable<Stringtags) {
         this. = ImmutableSet.<String>builder().addAll(tags);
         return self();
      }
      
      

See also:
Host.getTags()
      public T tag(String tag) {
         this..add(tag);
         return self();
      }
      
      
      public T hypervisor(String hypervisor) {
         this. = hypervisor;
         return self();
      }

      
      public T ipAddress(String ipAddress) {
         this. = ipAddress;
         return self();
      }

      
      public T localStorageActive(boolean localStorageActive) {
         this. = localStorageActive;
         return self();
      }

      

See also:
Host.getJobId()
      public T jobId(String jobId) {
         this. = jobId;
         return self();
      }

      
      public T jobStatus(AsyncJob.Status jobStatus) {
         this. = jobStatus;
         return self();
      }

      
      public T lastPinged(Date lastPinged) {
         this. = lastPinged;
         return self();
      }

      
      public T managementServerId(String managementServerId) {
         this. = managementServerId;
         return self();
      }

      
      public T memoryAllocated(long memoryAllocated) {
         this. = memoryAllocated;
         return self();
      }

      
      public T memoryTotal(long memoryTotal) {
         this. = memoryTotal;
         return self();
      }

      
      public T memoryUsed(long memoryUsed) {
         this. = memoryUsed;
         return self();
      }

      

See also:
Host.getName()
      public T name(String name) {
         this. = name;
         return self();
      }

      
      public T networkKbsRead(long networkKbsRead) {
         this. = networkKbsRead;
         return self();
      }

      
      public T networkKbsWrite(long networkKbsWrite) {
         this. = networkKbsWrite;
         return self();
      }

      
      public T osCategoryId(String osCategoryId) {
         this. = osCategoryId;
         return self();
      }

      
      public T osCategoryName(String osCategoryName) {
         this. = osCategoryName;
         return self();
      }

      

See also:
Host.getPodId()
      public T podId(String podId) {
         this. = podId;
         return self();
      }

      
      public T podName(String podName) {
         this. = podName;
         return self();
      }

      
      public T removed(Date removed) {
         this. = removed;
         return self();
      }

      

See also:
Host.getState()
      public T state(Host.State state) {
         this. = state;
         return self();
      }

      

See also:
Host.getType()
      public T type(Host.Type type) {
         this. = type;
         return self();
      }

      
      public T version(String version) {
         this. = version;
         return self();
      }

      
      public T zoneId(String zoneId) {
         this. = zoneId;
         return self();
      }

      
      public T zoneName(String zoneName) {
         this. = zoneName;
         return self();
      }
      public Host build() {
      }
      public T fromHost(Host in) {
         return this
               .id(in.getId())
               .allocationState(in.getAllocationState())
               .averageLoad(in.getAverageLoad())
               .capabilities(in.getCapabilities())
               .clusterId(in.getClusterId())
               .clusterName(in.getClusterName())
               .clusterType(in.getClusterType())
               .cpuAllocated(in.getCpuAllocated())
               .cpuNumber(in.getCpuNumber())
               .cpuSpeed(in.getCpuSpeed())
               .cpuUsed(in.getCpuUsed())
               .cpuWithOverProvisioning(in.getCpuWithOverProvisioning())
               .created(in.getCreated())
               .disconnected(in.getDisconnected())
               .diskSizeAllocated(in.getDiskSizeAllocated())
               .diskSizeTotal(in.getDiskSizeTotal())
               .events(in.getEvents())
               .hasEnoughCapacity(in.isHasEnoughCapacity())
               .tags(in.getTags())
               .hypervisor(in.getHypervisor())
               .ipAddress(in.getIpAddress())
               .localStorageActive(in.isLocalStorageActive())
               .jobId(in.getJobId())
               .jobStatus(in.getJobStatus())
               .lastPinged(in.getLastPinged())
               .managementServerId(in.getManagementServerId())
               .memoryAllocated(in.getMemoryAllocated())
               .memoryTotal(in.getMemoryTotal())
               .memoryUsed(in.getMemoryUsed())
               .name(in.getName())
               .networkKbsRead(in.getNetworkKbsRead())
               .networkKbsWrite(in.getNetworkKbsWrite())
               .osCategoryId(in.getOsCategoryId())
               .osCategoryName(in.getOsCategoryName())
               .podId(in.getPodId())
               .podName(in.getPodName())
               .removed(in.getRemoved())
               .state(in.getState())
               .type(in.getType())
               .version(in.getVersion())
               .zoneId(in.getZoneId())
               .zoneName(in.getZoneName());
      }
   }
   private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
      @Override
      protected ConcreteBuilder self() {
         return this;
      }
   }
   private final String id;
   private final AllocationState allocationState;
   private final int averageLoad;
   private final String capabilities;
   private final String clusterId;
   private final String clusterName;
   private final Host.ClusterType clusterType;
   private final String cpuAllocated;
   private final int cpuNumber;
   private final int cpuSpeed;
   private final String cpuUsed;
   private final float cpuWithOverProvisioning;
   private final Date created;
   private final Date disconnected;
   private final long diskSizeAllocated;
   private final long diskSizeTotal;
   private final String events;
   private final boolean hasEnoughCapacity;
   private final Set<Stringtags;
   private final String hypervisor;
   private final String ipAddress;
   private final boolean localStorageActive;
   private final String jobId;
   private final AsyncJob.Status jobStatus;
   private final Date lastPinged;
   private final String managementServerId;
   private final long memoryAllocated;
   private final long memoryTotal;
   private final long memoryUsed;
   private final String name;
   private final long networkKbsRead;
   private final long networkKbsWrite;
   private final String osCategoryId;
   private final String osCategoryName;
   private final String podId;
   private final String podName;
   private final Date removed;
   private final Host.State state;
   private final Host.Type type;
   private final String version;
   private final String zoneId;
   private final String zoneName;
         "id""allocationstate""averageload""capabilities""clusterid""clustername""clustertype""cpuallocated""cpunumber""cpuspeed""cpuused""cpuwithoverprovisioning""created""disconnected""disksizeallocated""disksizetotal""events""hasenoughcapacity""hosttags""hypervisor""ipaddress""islocalstorageactive""jobid""jobstatus""lastpinged""managementserverid""memoryallocated""memorytotal""memoryused""name""networkkbsread""networkkbswrite""oscategoryid""oscategoryname""podid""podname""removed""state""type""version""zoneid""zonename"
   })
   protected Host(String id, @Nullable AllocationState allocationStateint averageLoad, @Nullable String capabilities,
                  @Nullable String clusterId, @Nullable String clusterName, @Nullable Host.ClusterType clusterType,
                  @Nullable String cpuAllocatedint cpuNumberint cpuSpeed, @Nullable String cpuUsed,
                  float cpuWithOverProvisioning, @Nullable Date created, @Nullable Date disconnectedlong diskSizeAllocated,
                  long diskSizeTotal, @Nullable String eventsboolean hasEnoughCapacity, @Nullable Iterable<Stringtags,
                  @Nullable String hypervisor, @Nullable String ipAddressboolean localStorageActive, @Nullable String jobId,
                  @Nullable AsyncJob.Status jobStatus, @Nullable Date lastPinged, @Nullable String managementServerId,
                  long memoryAllocatedlong memoryTotallong memoryUsed, @Nullable String namelong networkKbsReadlong networkKbsWrite,
                  @Nullable String osCategoryId, @Nullable String osCategoryName, @Nullable String podId, @Nullable String podName,
                  @Nullable Date removed, @Nullable Host.State state, @Nullable Host.Type type, @Nullable String version, @Nullable String zoneId,
                  @Nullable String zoneName) {
      this. = checkNotNull(id"id");
      this. = allocationState;
      this. = averageLoad;
      this. = capabilities;
      this. = clusterId;
      this. = clusterName;
      this. = clusterType;
      this. = cpuAllocated;
      this. = cpuNumber;
      this. = cpuSpeed;
      this. = cpuUsed;
      this. = cpuWithOverProvisioning;
      this. = created;
      this. = disconnected;
      this. = diskSizeAllocated;
      this. = diskSizeTotal;
      this. = events;
      this. = hasEnoughCapacity;
      this. = tags != null ? ImmutableSet.copyOf(tags) : ImmutableSet.<Stringof();
      this. = hypervisor;
      this. = ipAddress;
      this. = localStorageActive;
      this. = jobId;
      this. = jobStatus;
      this. = lastPinged;
      this. = managementServerId;
      this. = memoryAllocated;
      this. = memoryTotal;
      this. = memoryUsed;
      this. = name;
      this. = networkKbsRead;
      this. = networkKbsWrite;
      this. = osCategoryId;
      this. = osCategoryName;
      this. = podId;
      this. = podName;
      this. = removed;
      this. = state;
      this. = type;
      this. = version;
      this. = zoneId;
      this. = zoneName;
   }
   public String getId() {
      return this.;
   }
      return this.;
   }
   public int getAverageLoad() {
      return this.;
   }
   public String getCapabilities() {
      return this.;
   }
   public String getClusterId() {
      return this.;
   }
   public String getClusterName() {
      return this.;
   }
   public Host.ClusterType getClusterType() {
      return this.;
   }
   public String getCpuAllocated() {
      return this.;
   }
   public int getCpuNumber() {
      return this.;
   }
   public int getCpuSpeed() {
      return this.;
   }
   public String getCpuUsed() {
      return this.;
   }
   public float getCpuWithOverProvisioning() {
      return this.;
   }
   public Date getCreated() {
      return this.;
   }
   public Date getDisconnected() {
      return this.;
   }
   public long getDiskSizeAllocated() {
      return this.;
   }
   public long getDiskSizeTotal() {
      return this.;
   }
   public String getEvents() {
      return this.;
   }
   public boolean isHasEnoughCapacity() {
      return this.;
   }

   

Returns:
the tags for the host
   public Set<StringgetTags() {
      return this.;
   }
   public String getHypervisor() {
      return this.;
   }
   public String getIpAddress() {
      return this.;
   }
   public boolean isLocalStorageActive() {
      return this.;
   }
   public String getJobId() {
      return this.;
   }
   public AsyncJob.Status getJobStatus() {
      return this.;
   }
   public Date getLastPinged() {
      return this.;
   }
   public String getManagementServerId() {
      return this.;
   }
   public long getMemoryAllocated() {
      return this.;
   }
   public long getMemoryTotal() {
      return this.;
   }
   public long getMemoryUsed() {
      return this.;
   }
   public String getName() {
      return this.;
   }
   public long getNetworkKbsRead() {
      return this.;
   }
   public long getNetworkKbsWrite() {
      return this.;
   }
   public String getOsCategoryId() {
      return this.;
   }
   public String getOsCategoryName() {
      return this.;
   }
   public String getPodId() {
      return this.;
   }
   public String getPodName() {
      return this.;
   }
   public Date getRemoved() {
      return this.;
   }
   public Host.State getState() {
      return this.;
   }
   public Host.Type getType() {
      return this.;
   }
   public String getVersion() {
      return this.;
   }
   public String getZoneId() {
      return this.;
   }
   public String getZoneName() {
      return this.;
   }
   public int hashCode() {
   }
   public boolean equals(Object obj) {
      if (this == objreturn true;
      if (obj == null || getClass() != obj.getClass()) return false;
      Host that = Host.class.cast(obj);
      return Objects.equal(this.that.id)
            && Objects.equal(this.that.allocationState)
            && Objects.equal(this.that.averageLoad)
            && Objects.equal(this.that.capabilities)
            && Objects.equal(this.that.clusterId)
            && Objects.equal(this.that.clusterName)
            && Objects.equal(this.that.clusterType)
            && Objects.equal(this.that.cpuAllocated)
            && Objects.equal(this.that.cpuNumber)
            && Objects.equal(this.that.cpuSpeed)
            && Objects.equal(this.that.cpuUsed)
            && Objects.equal(this.that.cpuWithOverProvisioning)
            && Objects.equal(this.that.created)
            && Objects.equal(this.that.disconnected)
            && Objects.equal(this.that.diskSizeAllocated)
            && Objects.equal(this.that.diskSizeTotal)
            && Objects.equal(this.that.events)
            && Objects.equal(this.that.hasEnoughCapacity)
            && Objects.equal(this.that.tags)
            && Objects.equal(this.that.hypervisor)
            && Objects.equal(this.that.ipAddress)
            && Objects.equal(this.that.localStorageActive)
            && Objects.equal(this.that.jobId)
            && Objects.equal(this.that.jobStatus)
            && Objects.equal(this.that.lastPinged)
            && Objects.equal(this.that.managementServerId)
            && Objects.equal(this.that.memoryAllocated)
            && Objects.equal(this.that.memoryTotal)
            && Objects.equal(this.that.memoryUsed)
            && Objects.equal(this.that.name)
            && Objects.equal(this.that.networkKbsRead)
            && Objects.equal(this.that.networkKbsWrite)
            && Objects.equal(this.that.osCategoryId)
            && Objects.equal(this.that.osCategoryName)
            && Objects.equal(this.that.podId)
            && Objects.equal(this.that.podName)
            && Objects.equal(this.that.removed)
            && Objects.equal(this.that.state)
            && Objects.equal(this.that.type)
            && Objects.equal(this.that.version)
            && Objects.equal(this.that.zoneId)
            && Objects.equal(this.that.zoneName);
   }
   protected ToStringHelper string() {
      return Objects.toStringHelper(this)
            .add("id").add("allocationState").add("averageLoad")
            .add("capabilities").add("clusterId").add("clusterName")
            .add("clusterType").add("cpuAllocated").add("cpuNumber")
            .add("cpuSpeed").add("cpuUsed").add("cpuWithOverProvisioning")
            .add("created").add("disconnected").add("diskSizeAllocated")
            .add("diskSizeTotal").add("events").add("hasEnoughCapacity")
            .add("tags").add("hypervisor").add("ipAddress")
            .add("localStorageActive").add("jobId").add("jobStatus")
            .add("lastPinged").add("managementServerId").add("memoryAllocated")
            .add("memoryTotal").add("memoryUsed").add("name").add("networkKbsRead")
            .add("networkKbsWrite").add("osCategoryId").add("osCategoryName")
            .add("podId").add("podName").add("removed").add("state").add("type")
            .add("version").add("zoneId").add("zoneName");
   }
   public String toString() {
      return string().toString();
   }
   public int compareTo(Host other) {
      return this.getId().compareTo(other.getId());
   }