Class ElasticFunctionalityFacadeImpl
- java.lang.Object
-
- com.atlassian.bamboo.agent.elastic.server.ElasticFunctionalityFacadeImpl
-
- All Implemented Interfaces:
ElasticFunctionalityFacade
public class ElasticFunctionalityFacadeImpl extends Object implements ElasticFunctionalityFacade
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.atlassian.bamboo.agent.elastic.server.ElasticFunctionalityFacade
ElasticFunctionalityFacade.Ec2PrivateKeyValidationStatus
-
-
Field Summary
-
Fields inherited from interface com.atlassian.bamboo.agent.elastic.server.ElasticFunctionalityFacade
DEFAULT_ALLOWED_AGENTS
-
-
Constructor Summary
Constructors Constructor Description ElasticFunctionalityFacadeImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addElasticLogEntry(org.apache.log4j.Logger log, String logEntry)
void
addElasticLogEntry(org.apache.logging.log4j.Logger log, String logEntry)
void
adjustElasticInstanceNumbers(@NotNull ElasticInstanceSchedule instanceSchedule)
Given theElasticInstanceSchedule
startup or bring down the correct number of agentsprotected void
attemptShutdownInstances(Collection<RemoteElasticInstance> instances, int agentsToShutdown, ElasticImageConfiguration elasticImageConfiguration)
void
cleanupCredentials()
Cleanup EC2 credentials and disable EC2 support@NotNull String
getKeyPairName()
int
getMaxConcurrentInstances()
@NotNull io.atlassian.fugue.Either<ElasticFunctionalityFacade.Ec2PrivateKeyValidationStatus,Optional<String>>
getPassword(RemoteElasticInstance instance)
@NotNull String
getPkFileLocation()
@NotNull io.atlassian.fugue.Either<ElasticFunctionalityFacade.Ec2PrivateKeyValidationStatus,File>
getPrivateKeyLocation()
Returns the location of the AWS private keyboolean
isElasticSupportEnabled()
boolean
isElasticSupportPossible(@NotNull ErrorCollection errorCollection)
void
persistTunnelDataOfInstance(@NotNull ElasticAgentDefinition pipelineDefinition)
Persist data related to tunnel configuration of an elastic instance.void
postConstruct()
void
recheckElasticSupportEnabledFlag()
void
restoreAgent(@NotNull ElasticAgentDefinition elasticAgentDefinition, @NotNull com.amazonaws.services.ec2.model.Instance instance, @NotNull com.atlassian.aws.AWSAccount awsAccount)
void
setElasticSupportEnabled(boolean elasticSupportEnabled)
Enable/disable Elastic Bamboo functionalityvoid
shutdownAllInstances()
void
shutdownInstance(@NotNull RemoteElasticInstance elasticInstance)
void
shutdownInstance(String instanceId)
void
startupAgents(@NotNull Collection<ElasticImageConfiguration> elasticImageConfigurations)
Starts the given number of agentsvoid
updateAgentPendingStatus(@NotNull String instanceId)
Set the agent pending status to true for the given instance idboolean
validateAgentCreation(int numAgentsRequired, ErrorCollection errorCollection)
Validates whether the requested number of agents can be created and adds any errors to the error collection.
-
-
-
Method Detail
-
postConstruct
@PostConstruct public void postConstruct()
-
recheckElasticSupportEnabledFlag
public void recheckElasticSupportEnabledFlag()
- Specified by:
recheckElasticSupportEnabledFlag
in interfaceElasticFunctionalityFacade
-
shutdownInstance
public void shutdownInstance(@NotNull @NotNull RemoteElasticInstance elasticInstance)
- Specified by:
shutdownInstance
in interfaceElasticFunctionalityFacade
-
shutdownInstance
public void shutdownInstance(String instanceId) throws com.atlassian.aws.AWSException
- Specified by:
shutdownInstance
in interfaceElasticFunctionalityFacade
- Throws:
com.atlassian.aws.AWSException
-
shutdownAllInstances
public void shutdownAllInstances()
- Specified by:
shutdownAllInstances
in interfaceElasticFunctionalityFacade
-
startupAgents
@Transactional public void startupAgents(@NotNull @NotNull Collection<ElasticImageConfiguration> elasticImageConfigurations) throws com.atlassian.aws.AWSException
Starts the given number of agents- Specified by:
startupAgents
in interfaceElasticFunctionalityFacade
- Throws:
com.atlassian.aws.AWSException
-
restoreAgent
public void restoreAgent(@NotNull @NotNull ElasticAgentDefinition elasticAgentDefinition, @NotNull @NotNull com.amazonaws.services.ec2.model.Instance instance, @NotNull @NotNull com.atlassian.aws.AWSAccount awsAccount)
- Specified by:
restoreAgent
in interfaceElasticFunctionalityFacade
-
persistTunnelDataOfInstance
@Nullable public void persistTunnelDataOfInstance(@NotNull @NotNull ElasticAgentDefinition pipelineDefinition)
Description copied from interface:ElasticFunctionalityFacade
Persist data related to tunnel configuration of an elastic instance.- Specified by:
persistTunnelDataOfInstance
in interfaceElasticFunctionalityFacade
-
isElasticSupportEnabled
public boolean isElasticSupportEnabled()
- Specified by:
isElasticSupportEnabled
in interfaceElasticFunctionalityFacade
- Returns:
- true, if elastic support is turned on
-
isElasticSupportPossible
public boolean isElasticSupportPossible(@NotNull @NotNull ErrorCollection errorCollection)
- Specified by:
isElasticSupportPossible
in interfaceElasticFunctionalityFacade
- Returns:
- true, if all preconditions for turning elastic support on are met
-
setElasticSupportEnabled
public void setElasticSupportEnabled(boolean elasticSupportEnabled)
Description copied from interface:ElasticFunctionalityFacade
Enable/disable Elastic Bamboo functionality- Specified by:
setElasticSupportEnabled
in interfaceElasticFunctionalityFacade
- Parameters:
elasticSupportEnabled
- Specifies if Elastc Baboo shall be enabled or disabled.
-
validateAgentCreation
public boolean validateAgentCreation(int numAgentsRequired, ErrorCollection errorCollection)
Description copied from interface:ElasticFunctionalityFacade
Validates whether the requested number of agents can be created and adds any errors to the error collection.- Specified by:
validateAgentCreation
in interfaceElasticFunctionalityFacade
- Parameters:
numAgentsRequired
- - number of agents to be createderrorCollection
- - error collection to add any validation errors to.
-
updateAgentPendingStatus
public void updateAgentPendingStatus(@NotNull @NotNull String instanceId)
Description copied from interface:ElasticFunctionalityFacade
Set the agent pending status to true for the given instance id- Specified by:
updateAgentPendingStatus
in interfaceElasticFunctionalityFacade
-
addElasticLogEntry
public void addElasticLogEntry(org.apache.log4j.Logger log, String logEntry)
- Specified by:
addElasticLogEntry
in interfaceElasticFunctionalityFacade
-
addElasticLogEntry
public void addElasticLogEntry(org.apache.logging.log4j.Logger log, String logEntry)
- Specified by:
addElasticLogEntry
in interfaceElasticFunctionalityFacade
-
adjustElasticInstanceNumbers
@Transactional public void adjustElasticInstanceNumbers(@NotNull @NotNull ElasticInstanceSchedule instanceSchedule) throws com.atlassian.aws.AWSException
Description copied from interface:ElasticFunctionalityFacade
Given theElasticInstanceSchedule
startup or bring down the correct number of agents- Specified by:
adjustElasticInstanceNumbers
in interfaceElasticFunctionalityFacade
- Throws:
com.atlassian.aws.AWSException
-
attemptShutdownInstances
protected void attemptShutdownInstances(Collection<RemoteElasticInstance> instances, int agentsToShutdown, ElasticImageConfiguration elasticImageConfiguration)
-
getMaxConcurrentInstances
public int getMaxConcurrentInstances()
- Specified by:
getMaxConcurrentInstances
in interfaceElasticFunctionalityFacade
- Returns:
- max number of elastic instances allowed for this instance. It's based on license restrictions.
-
getPkFileLocation
@NotNull public @NotNull String getPkFileLocation()
- Specified by:
getPkFileLocation
in interfaceElasticFunctionalityFacade
-
getPrivateKeyLocation
@NotNull public @NotNull io.atlassian.fugue.Either<ElasticFunctionalityFacade.Ec2PrivateKeyValidationStatus,File> getPrivateKeyLocation()
Description copied from interface:ElasticFunctionalityFacade
Returns the location of the AWS private key- Specified by:
getPrivateKeyLocation
in interfaceElasticFunctionalityFacade
- Returns:
-
getPassword
@NotNull public @NotNull io.atlassian.fugue.Either<ElasticFunctionalityFacade.Ec2PrivateKeyValidationStatus,Optional<String>> getPassword(RemoteElasticInstance instance)
- Specified by:
getPassword
in interfaceElasticFunctionalityFacade
-
getKeyPairName
@NotNull public @NotNull String getKeyPairName()
- Specified by:
getKeyPairName
in interfaceElasticFunctionalityFacade
-
cleanupCredentials
public void cleanupCredentials()
Description copied from interface:ElasticFunctionalityFacade
Cleanup EC2 credentials and disable EC2 support- Specified by:
cleanupCredentials
in interfaceElasticFunctionalityFacade
-
-