Class CloudPoolRestApiImpl
- java.lang.Object
-
- com.elastisys.scale.cloudpool.api.restapi.impl.CloudPoolRestApiImpl
-
- All Implemented Interfaces:
CloudPoolRestApi
@Path("/") public class CloudPoolRestApiImpl extends java.lang.Object implements CloudPoolRestApi/** Implements the cloud pool REST API, which is fully covered in the elastisys:scale cloud pool REST API documentation.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_CONFIG_FILE_NAMEDefault file name (within the storage directory) in whichCloudPoolconfiguration is stored.
-
Constructor Summary
Constructors Constructor Description CloudPoolRestApiImpl(CloudPool cloudPool, java.lang.String storageDir)Creates aCloudPoolRestApiImplthat will store setCloudPoolconfigurations under a given storage directory with theDEFAULT_CONFIG_FILE_NAME.CloudPoolRestApiImpl(CloudPool cloudPool, java.lang.String storageDir, java.lang.String configFileName)Creates aCloudPoolRestApiImplthat will store setCloudPoolconfigurations under a given storage directory with a given file name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.ws.rs.core.ResponseattachMachine(AttachMachineRequest request)Attaches an already running machine instance to the pool, growing the pool with a new member.javax.ws.rs.core.ResponsedetachMachine(DetachMachineRequest request)Removes a member from the pool without terminating it.java.nio.file.PathgetCloudPoolConfigPath()Returns the file system path where theCloudPoolRestApiImplstores receivedCloudPoolconfigurations.javax.ws.rs.core.ResponsegetConfig()Retrieves the configuration currently set for theCloudPool.javax.ws.rs.core.ResponsegetPool()Retrieves the current machine pool members.javax.ws.rs.core.ResponsegetPoolSize()Returns the current size of the machine pool -- both in terms of the desired size and the actual size (as these may differ at any time).javax.ws.rs.core.ResponsegetStatus()Retrieves the execution status for the cloud pool.javax.ws.rs.core.ResponsesetConfig(com.google.gson.JsonObject configuration)Sets the configuration for theCloudPool.javax.ws.rs.core.ResponsesetDesiredSize(SetDesiredSizeRequest request)Sets the desired number of machines in the machine pool.javax.ws.rs.core.ResponsesetMembershipStatus(SetMembershipStatusRequest request)Sets the membership status for a given pool member.javax.ws.rs.core.ResponsesetServiceState(SetServiceStateRequest request)Sets the service state for a given machine pool member.javax.ws.rs.core.Responsestart()Starts the cloud pool.javax.ws.rs.core.Responsestop()Stops the cloud pool.voidstoreConfig(com.google.gson.JsonObject configuration)Stores a configuration in thestorageDir, to allow it to be restored when theCloudPoolis restarted.javax.ws.rs.core.ResponseterminateMachine(TerminateMachineRequest request)Terminates a particular machine pool member.
-
-
-
Field Detail
-
DEFAULT_CONFIG_FILE_NAME
public static final java.lang.String DEFAULT_CONFIG_FILE_NAME
Default file name (within the storage directory) in whichCloudPoolconfiguration is stored.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CloudPoolRestApiImpl
public CloudPoolRestApiImpl(CloudPool cloudPool, java.lang.String storageDir)
Creates aCloudPoolRestApiImplthat will store setCloudPoolconfigurations under a given storage directory with theDEFAULT_CONFIG_FILE_NAME.- Parameters:
cloudPool- The back-endCloudPoolthat is being managed.storageDir- The directory path where runtime state for theCloudPoolis stored. TheCloudPoolRestApiImplwill use this directory to store every set configuration so that it can be restored on restart. The directory will be created if it does not exist.
-
CloudPoolRestApiImpl
public CloudPoolRestApiImpl(CloudPool cloudPool, java.lang.String storageDir, java.lang.String configFileName)
Creates aCloudPoolRestApiImplthat will store setCloudPoolconfigurations under a given storage directory with a given file name.- Parameters:
cloudPool- The back-endCloudPoolthat is being managed.storageDir- The directory path where runtime state for theCloudPoolis stored. TheCloudPoolRestApiImplwill use this directory to store every set configuration so that it can be restored on restart. The directory will be created if it does not exist.configFileName- The file name, within thestorageDir, in whichCloudPoolconfiguration is stored.
-
-
Method Detail
-
getConfig
public javax.ws.rs.core.Response getConfig()
Description copied from interface:CloudPoolRestApiRetrieves the configuration currently set for theCloudPool. More details can be found in the official API documentation.- Specified by:
getConfigin interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
setConfig
public javax.ws.rs.core.Response setConfig(com.google.gson.JsonObject configuration)
Description copied from interface:CloudPoolRestApiSets the configuration for theCloudPool. More details can be found in the official API documentation.- Specified by:
setConfigin interfaceCloudPoolRestApi- Parameters:
configuration- The (JSON) configuration document to set.- Returns:
- A response message as per the cloud pool REST API.
-
start
public javax.ws.rs.core.Response start()
Description copied from interface:CloudPoolRestApiStarts the cloud pool. This will set the cloud pool in an activated state where it will start to accept requests to query or modify the machine pool. If the cloud pool has not been configured the method should fail. If the cloud pool is already started this is a no-op. More details can be found in the official API documentation.- Specified by:
startin interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
stop
public javax.ws.rs.core.Response stop()
Description copied from interface:CloudPoolRestApiStops the cloud pool. A stopped cloud pool is in a passivated state and will not accept any requests to query or modify the machine pool. If the cloud pool is already in a stopped state this is a no-op. More details can be found in the official API documentation.- Specified by:
stopin interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
getStatus
public javax.ws.rs.core.Response getStatus()
Description copied from interface:CloudPoolRestApiRetrieves the execution status for the cloud pool. More details can be found in the official API documentation.- Specified by:
getStatusin interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
storeConfig
public void storeConfig(com.google.gson.JsonObject configuration) throws java.io.IOExceptionStores a configuration in thestorageDir, to allow it to be restored when theCloudPoolis restarted.- Parameters:
configuration-- Throws:
java.io.IOException- If the configuration could not be stored.
-
getCloudPoolConfigPath
public java.nio.file.Path getCloudPoolConfigPath()
Returns the file system path where theCloudPoolRestApiImplstores receivedCloudPoolconfigurations.- Parameters:
storageDir-- Returns:
-
getPool
public javax.ws.rs.core.Response getPool()
Description copied from interface:CloudPoolRestApiRetrieves the current machine pool members. More details can be found in the official API documentation.- Specified by:
getPoolin interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
setDesiredSize
public javax.ws.rs.core.Response setDesiredSize(SetDesiredSizeRequest request)
Description copied from interface:CloudPoolRestApiSets the desired number of machines in the machine pool. This method is asynchronous in that the method returns immediately without having carried out any required changes to the machine pool. More details can be found in the official API documentation.- Specified by:
setDesiredSizein interfaceCloudPoolRestApi- Parameters:
request- ASetDesiredSizeRequest.- Returns:
- A response message as per the cloud pool REST API.
-
getPoolSize
public javax.ws.rs.core.Response getPoolSize()
Description copied from interface:CloudPoolRestApiReturns the current size of the machine pool -- both in terms of the desired size and the actual size (as these may differ at any time). More details can be found in the official API documentation.- Specified by:
getPoolSizein interfaceCloudPoolRestApi- Returns:
- A response message as per the cloud pool REST API.
-
terminateMachine
public javax.ws.rs.core.Response terminateMachine(TerminateMachineRequest request)
Description copied from interface:CloudPoolRestApiTerminates a particular machine pool member. The caller can control if a replacement machine is to be provisioned. Note: a machine that is protected from removal by a membership status withevictable: falsecan not be terminated. More details can be found in the official API documentation.- Specified by:
terminateMachinein interfaceCloudPoolRestApi- Parameters:
request- ATerminateMachineRequest.- Returns:
- A response message as per the cloud pool REST API.
-
detachMachine
public javax.ws.rs.core.Response detachMachine(DetachMachineRequest request)
Description copied from interface:CloudPoolRestApiRemoves a member from the pool without terminating it. The machine keeps running but is no longer considered a pool member and, therefore, needs to be managed independently. The caller can control if a replacement machine is to be provisioned. Note: a machine that is protected from removal by a membership status withevictable: falsecan not be detached. More details can be found in the official API documentation.- Specified by:
detachMachinein interfaceCloudPoolRestApi- Parameters:
request- ADetachMachineRequest.- Returns:
- A response message as per the cloud pool REST API.
-
attachMachine
public javax.ws.rs.core.Response attachMachine(AttachMachineRequest request)
Description copied from interface:CloudPoolRestApiAttaches an already running machine instance to the pool, growing the pool with a new member. This operation implies that the desired size of the pool is incremented by one. More details can be found in the official API documentation.- Specified by:
attachMachinein interfaceCloudPoolRestApi- Parameters:
request- AnAttachMachineRequest.- Returns:
- A response message as per the cloud pool REST API.
-
setServiceState
public javax.ws.rs.core.Response setServiceState(SetServiceStateRequest request)
Description copied from interface:CloudPoolRestApiSets the service state for a given machine pool member. Setting the service state does not have any functional implications on the pool member, but should be seen as way to supply operational information about the service running on the machine to third-party services (such as load balancers). More details can be found in the official API documentation.- Specified by:
setServiceStatein interfaceCloudPoolRestApi- Parameters:
request- ASetServiceStateRequest.- Returns:
- A response message as per the cloud pool REST API.
-
setMembershipStatus
public javax.ws.rs.core.Response setMembershipStatus(SetMembershipStatusRequest request)
Description copied from interface:CloudPoolRestApiSets the membership status for a given pool member. The membership status for a machine can be set to protect the machine from being terminated (by setting its evictability status) and/or to mark a machine as being in need of replacement by flagging it as an inactive pool member. More details can be found in the official API documentation.- Specified by:
setMembershipStatusin interfaceCloudPoolRestApi- Parameters:
request- ASetMembershipStatusRequest.- Returns:
- A response message as per the cloud pool REST API.
-
-