|
Brooklyn | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbrooklyn.location.basic.jclouds.pool.MachinePool
public class MachinePool
Contains details of machines detected at a given cloud (ComputeService), and records claims made against those machines via this pool.
Machine instances themselves are persisted and rescanned as new instances of this class are created. Claims however are specific to this instance of the class, i.e. not persisted.
This class is believed to be thread-safe. Refreshes to the remote detected machines are synchronized on the pool instance. Details of detected and claimed machines are also synchronized on the pool instance. (If it is necessary to claim machines whilst the pool is being rescanned, we can investigate a more sophisticated threading model. Access to some fields is clearly independent and uses a tighter synchonization strategy, e.g. templates. Synchronization of fields within a synch block on the class instance is permitted, but not the other way round, and synching on multiple fields is also not permitted.)
Callers wishing to guarantee results of e.g. ensureUnclaimed remaining available can synchronize on this class for the duration that they wish to have that guarantee (at the cost, of course, of any other threads being able to access this pool).
If underlying provisioning/destroying operations fail, the pool currently may be in an unknown state, currently. If more robustness is needed this can be added.
Field Summary | |
---|---|
protected ComputeService |
computeService
|
Constructor Summary | |
MachinePool(ComputeService computeService)
|
Method Summary | |
---|---|
void
|
addToBlacklist(MachineSet newToBlacklist)
|
MachineSet
|
all()
all machines matching any templates |
MachineSet
|
all(Predicate criterion)
returns all machines matching the given criteria (may be claimed) |
MachineSet
|
all(Predicate... ops)
returns all machines matching the given criteria (may be claimed) |
MachineSet
|
claim(int count, ReusableMachineTemplate t)
claims the indicated number of machines with the indicated spec, creating if necessary |
MachineSet
|
claim(MachineSet set)
claims the indicated set of machines; throws exception if cannot all be claimed; returns the set passed in if successful |
MachineSet
|
create(int count, ReusableMachineTemplate template)
creates the given number of machines of the indicated template |
int
|
destroy(MachineSet set)
|
MachineSet
|
ensureExists(ReusableMachineTemplate template)
creates machines if necessary so that this spec exists (may already be claimed however) returns a set of all matching machines, guaranteed non-empty (but possibly some are already claimed) |
MachineSet
|
ensureExists(int count, ReusableMachineTemplate template)
creates machines if necessary so that this spec exists (may already be claimed however); returns a set of all matching machines, of size at least count (but possibly some are already claimed). |
MachineSet
|
ensureUnclaimed(ReusableMachineTemplate template)
creates machines if necessary so that this spec can subsequently be claimed; returns all such unclaimed machines, guaranteed to be non-empty. |
MachineSet
|
ensureUnclaimed(int count, ReusableMachineTemplate template)
creates machines if necessary so that this spec can subsequently be claimed; returns a set of at least count unclaimed machines |
protected MachineSet
|
filterForAllowedMachines(MachineSet input)
|
java.lang.String
|
getPoolName()
pool name is used as a group/label by jclouds, for convenience only; it has no special properties for detecting matching instances (use explicit tags on the templates, for that). |
java.util.List
|
getTemplates()
|
java.util.Set
|
getTemplatesMatchingInstance(NodeMetadata nm)
|
protected void
|
init()
|
protected ReusableMachineTemplate
|
newTemplate(java.lang.String name)
|
void
|
refresh()
refreshes the pool of machines from the server (finding all instances matching the registered templates) |
protected void
|
registerNewNodes(MachineSet result, ReusableMachineTemplate template)
|
protected ReusableMachineTemplate
|
registerTemplate(ReusableMachineTemplate template)
|
protected void
|
registerTemplates(ReusableMachineTemplate... templatesToReg)
|
void
|
setBlacklist(MachineSet newBlacklist)
replaces the blacklist set; callers should generally perform a refresh() afterwards, to trigger re-detection of blacklisted machines |
void
|
setPoolName(java.lang.String poolName)
|
int
|
unclaim(MachineSet set)
|
MachineSet
|
unclaimed()
machines matching any templates which have not been claimed |
MachineSet
|
unclaimed(Predicate criterion)
returns unclaimed machines matching the given criteria |
MachineSet
|
unclaimed(Predicate... criteria)
returns unclaimed machines matching the given criteria |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected final ComputeService computeService
Constructor Detail |
---|
public MachinePool(ComputeService computeService)
Method Detail |
---|
public void addToBlacklist(MachineSet newToBlacklist)
public MachineSet all()
@SuppressWarnings("unchecked") public MachineSet all(Predicate criterion)
public MachineSet all(Predicate... ops)
public MachineSet claim(int count, ReusableMachineTemplate t)
public MachineSet claim(MachineSet set)
public MachineSet create(int count, ReusableMachineTemplate template)
public int destroy(MachineSet set)
public MachineSet ensureExists(ReusableMachineTemplate template)
public MachineSet ensureExists(int count, ReusableMachineTemplate template)
public MachineSet ensureUnclaimed(ReusableMachineTemplate template)
public MachineSet ensureUnclaimed(int count, ReusableMachineTemplate template)
protected MachineSet filterForAllowedMachines(MachineSet input)
public java.lang.String getPoolName()
public java.util.List getTemplates()
public java.util.Set getTemplatesMatchingInstance(NodeMetadata nm)
protected void init()
protected ReusableMachineTemplate newTemplate(java.lang.String name)
public void refresh()
protected void registerNewNodes(MachineSet result, ReusableMachineTemplate template)
protected ReusableMachineTemplate registerTemplate(ReusableMachineTemplate template)
protected void registerTemplates(ReusableMachineTemplate... templatesToReg)
public void setBlacklist(MachineSet newBlacklist)
public void setPoolName(java.lang.String poolName)
public int unclaim(MachineSet set)
public MachineSet unclaimed()
@SuppressWarnings("unchecked") public MachineSet unclaimed(Predicate criterion)
public MachineSet unclaimed(Predicate... criteria)
Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.