public class SplitterCloudAdapter extends Object implements CloudAdapter
MachinePool to a number of
configured CloudAdapters. It communicates with the underlying
CloudAdapters via their REST protocol endpoints.
Cloud adapters are prioritized by a number in [0, 100]. The sums of these priorities must equal 100, to ensure that we have an unambiguous configuration. The splitter adapter will instruct its underlying adapters to obtain the correct number of instances based on the priorities (in case of a tie, e.g., two adapters each configured to handle 50% of the machine demand, the first in the configuration file will win).
This class is thread-safe. It guards its modification methods,
configure(JsonObject) and resizeMachinePool(int) with its
own intrinsic lock. It delegates thread-safety to thread-safe members for
getConfiguration(), getConfigurationSchema(), and
getMachinePool().
| Constructor and Description |
|---|
SplitterCloudAdapter()
Creates a new instance in an unconfigured state.
|
SplitterCloudAdapter(Class<? extends PrioritizedRemoteCloudAdapter> adapterClass)
Creates a new instance in an unconfigured state, with the ability to
specify the implementation class of the remote cloud adapter (useful for
testing).
|
| Modifier and Type | Method and Description |
|---|---|
void |
configure(com.google.gson.JsonObject configuration)
This method is thread-safe, guarded by the class' intrinsic lock for the
actual update part of the code, making changes to the configuration
appear to be atomic.
|
com.google.common.base.Optional<com.google.gson.JsonObject> |
getConfiguration()
This method is thread-safe by delegation to an
AtomicReference. |
com.google.common.base.Optional<com.google.gson.JsonObject> |
getConfigurationSchema()
This method is thread-safe by delegation (uses only a private final
static constant).
|
MachinePool |
getMachinePool()
Queries all configured adapters and summarizes the results.
|
void |
resizeMachinePool(int desiredSize)
This method is made thread-safe by guarding it with the class' intrinsic
lock.
|
public SplitterCloudAdapter()
public SplitterCloudAdapter(Class<? extends PrioritizedRemoteCloudAdapter> adapterClass)
adapterClass - The class from which remote cloud adapters will be
instantiated.public com.google.common.base.Optional<com.google.gson.JsonObject> getConfigurationSchema()
getConfigurationSchema in interface CloudAdapterpublic void configure(com.google.gson.JsonObject configuration)
throws IllegalArgumentException,
CloudAdapterException
configure in interface CloudAdapterIllegalArgumentExceptionCloudAdapterExceptionpublic com.google.common.base.Optional<com.google.gson.JsonObject> getConfiguration()
AtomicReference.getConfiguration in interface CloudAdapterpublic MachinePool getMachinePool() throws CloudAdapterException
AtomicReference.getMachinePool in interface CloudAdapterCloudAdapterExceptionpublic void resizeMachinePool(int desiredSize)
throws IllegalArgumentException,
CloudAdapterException
resizeMachinePool in interface CloudAdapterIllegalArgumentExceptionCloudAdapterExceptionCopyright © 2011–2014 elastisys. All rights reserved.