Class MachinePool
- java.lang.Object
-
- com.elastisys.scale.cloudpool.api.types.MachinePool
-
-
Constructor Summary
Constructors Constructor Description MachinePool(java.util.List<? extends Machine> machines, org.joda.time.DateTime timestamp)Constructs a newMachinePoolsnapshot.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static MachinePoolemptyPool(org.joda.time.DateTime timestamp)Factory method for creating an empty machine pool.booleanequals(java.lang.Object obj)static MachinePoolfromJson(java.lang.String machinePoolAsJson)Parses a JSON representation of aMachinePoolto its Java counterpart.java.util.List<Machine>getActiveMachines()Returns all activeMachines in the pool.java.util.List<Machine>getAllocatedMachines()Returns all allocatedMachines in the pool.java.util.List<Machine>getMachines()Returns allMachines in the pool.java.util.List<Machine>getStartedMachines()Returns all startedMachines in the pool.org.joda.time.DateTimegetTimestamp()Returns the time at which the pool observation was made.inthashCode()com.google.gson.JsonObjecttoJson()Returns the JSON representation for thisMachinePool.java.lang.StringtoString()
-
-
-
Constructor Detail
-
MachinePool
public MachinePool(java.util.List<? extends Machine> machines, org.joda.time.DateTime timestamp)
Constructs a newMachinePoolsnapshot.- Parameters:
machines- The machine instances that were part of the machine pool at the time of the snapshot.timestamp- The time when this snapshot of the resource pool was taken.
-
-
Method Detail
-
getMachines
public java.util.List<Machine> getMachines()
Returns allMachines in the pool. Note: the returnedMachines may be in anyMachineStateand may include both machines in non-terminal states (MachineState.REQUESTED,MachineState.PENDING,MachineState.RUNNING) as well as machines in terminal states (MachineState.REJECTED,MachineState.TERMINATING,MachineState.TERMINATED).- Returns:
-
getActiveMachines
public java.util.List<Machine> getActiveMachines()
Returns all activeMachines in the pool. SeeMachine.isActiveMember().- Returns:
-
getAllocatedMachines
public java.util.List<Machine> getAllocatedMachines()
Returns all allocatedMachines in the pool. SeeMachine.isAllocated().- Returns:
-
getStartedMachines
public java.util.List<Machine> getStartedMachines()
Returns all startedMachines in the pool. SeeMachine.isStarted().- Returns:
-
getTimestamp
public org.joda.time.DateTime getTimestamp()
Returns the time at which the pool observation was made. Note that in case the cloud pool serves locally cached data, this field may be used by the client to determine if the data is fresh enough to be acted upon.- Returns:
-
emptyPool
public static MachinePool emptyPool(org.joda.time.DateTime timestamp)
Factory method for creating an empty machine pool.- Parameters:
timestamp- The timestamp of the machine pool.- Returns:
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
fromJson
public static MachinePool fromJson(java.lang.String machinePoolAsJson) throws java.io.IOException
Parses a JSON representation of aMachinePoolto its Java counterpart. Any failure to parse the JSON representation into a validMachinePoolinstance results in an exception being thrown.- Parameters:
machinePoolAsJson-- Returns:
- Throws:
java.io.IOException
-
toJson
public com.google.gson.JsonObject toJson()
Returns the JSON representation for thisMachinePool.- Returns:
- A
JsonObjectrepresentation of thisMachinePool.
-
-