public class Splitter 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 between [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).
The following is an example of what a configuration document for the
Splitter could look like:
{
"poolSizeCalculator": "STRICT",
"adapters": [
{
"priority": 40,
"cloudAdapterHost": "cloudadapter-host-1",
"cloudAdapterPort": 8443
},
{
"priority": 40,
"cloudAdapterHost": "cloudadapter-host-2",
"cloudAdapterPort": 8443,
"basicCredentials": {
"username": "admin",
"password": "adminpassword"
}
},
{
"priority": 20,
"cloudAdapterHost": "cloudadapter-host-3",
"cloudAdapterPort": 8443,
"certificateCredentials": {
"keystorePath": "/path/to/keystore/goes/here",
"keystorePassword": "keystorepassword",
"keystoreType": "PKCS12"
}
}
],
"poolUpdatePeriod": 60
}
| Modifier and Type | Field and Description |
|---|---|
static com.google.gson.JsonObject |
CONFIG_SCHEMA
JSON Schema describing valid configurations for the cloud adapter.
|
| Constructor and Description |
|---|
Splitter()
Constructs a
Splitter in an unconfigured state. |
Splitter(RequestFactory requestFactory)
Constructs a
Splitter with a specific RequestFactory. |
| Modifier and Type | Method and Description |
|---|---|
void |
attachMachine(String machineId) |
protected Map<PrioritizedCloudAdapter,Integer> |
calculatePoolSizes() |
void |
configure(com.google.gson.JsonObject configuration) |
void |
detachMachine(String machineId,
boolean decrementDesiredSize) |
com.google.common.base.Optional<com.google.gson.JsonObject> |
getConfiguration() |
com.google.common.base.Optional<com.google.gson.JsonObject> |
getConfigurationSchema() |
MachinePool |
getMachinePool() |
PoolSizeSummary |
getPoolSize() |
void |
setDesiredSize(int desiredSize) |
void |
setServiceState(String machineId,
ServiceState serviceState) |
void |
terminateMachine(String machineId,
boolean decrementDesiredSize) |
void |
updateMachinePool()
Updates the child pools according to the desired size and the configured
priorities in a thread-safe manner.
|
public static final com.google.gson.JsonObject CONFIG_SCHEMA
public Splitter()
Splitter in an unconfigured state.public Splitter(RequestFactory requestFactory)
Splitter with a specific RequestFactory.
Useful during testing.requestFactory - 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()
getConfiguration in interface CloudAdapterpublic MachinePool getMachinePool() throws CloudAdapterException
getMachinePool in interface CloudAdapterCloudAdapterExceptionpublic PoolSizeSummary getPoolSize() throws CloudAdapterException
getPoolSize in interface CloudAdapterCloudAdapterExceptionpublic void setDesiredSize(int desiredSize)
throws IllegalArgumentException,
CloudAdapterException
setDesiredSize in interface CloudAdapterIllegalArgumentExceptionCloudAdapterExceptionpublic void terminateMachine(String machineId, boolean decrementDesiredSize) throws NotFoundException, CloudAdapterException
terminateMachine in interface CloudAdapterNotFoundExceptionCloudAdapterExceptionpublic void setServiceState(String machineId, ServiceState serviceState) throws NotFoundException, CloudAdapterException
setServiceState in interface CloudAdapterNotFoundExceptionCloudAdapterExceptionpublic void attachMachine(String machineId) throws NotFoundException, CloudAdapterException
attachMachine in interface CloudAdapterNotFoundExceptionCloudAdapterExceptionpublic void detachMachine(String machineId, boolean decrementDesiredSize) throws NotFoundException, CloudAdapterException
detachMachine in interface CloudAdapterNotFoundExceptionCloudAdapterExceptionpublic void updateMachinePool()
protected Map<PrioritizedCloudAdapter,Integer> calculatePoolSizes()
Copyright © 2011–2015 elastisys. All rights reserved.