public class ElasticInstanceManagerImpl extends Object implements ElasticInstanceManager
DEFAULT_INSTANCE_TYPE_32, DEFAULT_INSTANCE_TYPE_64, DEFAULT_PRODUCT_FOR_LINUX_PLATFORM, DEFAULT_PRODUCT_FOR_WINDOWS_PLATFORM, ELASTIC_BAMBOO_KEY_PAIR, ELASTIC_BAMBOO_KEY_PAIR_FILE, ELASTIC_BAMBOO_SECURITY_GROUP
Constructor and Description |
---|
ElasticInstanceManagerImpl(AwsAccountBean awsAccountBean,
AdministrationConfigurationAccessor administrationConfigurationAccessor,
int startupTimeoutSeconds,
ScheduledExecutorService executor,
KeyStoreFactory keyStoreFactory,
SSLContextFactory sslContextFactory,
BootstrapManager bootstrapManager,
ErrorHandler errorHandler,
SpotInstanceConfigurationAccessor spotInstanceConfigurationAccessor,
com.atlassian.event.api.EventPublisher eventPublisher,
SecretEncryptionService secretEncryptionService) |
Modifier and Type | Method and Description |
---|---|
void |
addElasticLogEntry(org.apache.log4j.Logger log,
String logEntry) |
boolean |
cancelSpotRequests(com.atlassian.aws.AWSAccount awsAccount)
Cancel spot instance requests.
|
void |
ensureLoginKeyPairExists(com.atlassian.aws.AWSAccount awsAccount,
String keyPair)
Ensures that a key pair, named "elasticbamboo", has been defined in the configured AWS account.
|
int |
getAgentSideHttpPort()
The TCP port upon which the Elastic Agent listens for HTTP traffic intended for the Bamboo Server.
|
int |
getAgentSideJmsPort()
The TCP port upon which the Elastic Agent listens for JMS traffic intended for the Bamboo Server.
|
com.google.common.collect.SetMultimap<ElasticImageConfiguration,RemoteElasticInstance> |
getAllElasticAgentsAsMap()
Returns all elastic instances in a
SetMultimap , keyed by the ElasticImageConfiguration |
List<RemoteElasticInstance> |
getAllElasticRemoteAgents()
Returns all elastic instances.
|
Set<com.atlassian.aws.ec2.EC2InstanceType> |
getAllowedInstanceTypes() |
String |
getBambooControlTag()
Returns the name of the security group used to indicate that this instance belongs to Bamboo.
|
List<String> |
getElasticAgentLogs()
Retrieve activity logs
|
RemoteElasticInstance |
getElasticRemoteAgentByInstanceId(String instanceId)
Retrieve elastic instance of the given ID.
|
List<RemoteElasticInstance> |
getElasticRemoteAgents()
Retrieve a readonly list of any currently existing EC2 instances
|
List<RemoteElasticInstance> |
getElasticRemoteAgentsByConfiguration(ElasticImageConfiguration elasticImageConfiguration) |
List<RemoteElasticInstance> |
getElasticRemoteAgentsByConfiguration(long id) |
String |
getInstanceLogs(String instanceId)
Fetch console output of a running EC2 instance.
|
List<RemoteElasticInstance> |
getInstancesWithStartingAgents()
Returns those elastic instances that have already started but their agents have not yet connected to the bamboo server.
|
List<RemoteElasticInstance> |
getRequestedElasticRemoteAgents()
Returns the elastic instances which have been requested but not yet identified.
|
List<RemoteElasticInstance> |
getStartingElasticInstances()
Return the elastic instances which have been identified but not started up yet,
i.e.
|
int |
getTotalNumElasticRemoteAgents()
Return how many license spots are currently being occupied by elastic instances
(pending and running)
|
int |
getTunnelPort()
The TCP port upon which Elastic Agents listens for incoming tunnel connections from the Bamboo Server.
|
boolean |
isElasticSupportEnabled() |
boolean |
isInstanceKnown(String instanceId)
Checks if an AWS instance with the given ID exists and is managed by this Bamboo server.
|
RemoteElasticInstance |
newElasticAgent(RemoteElasticInstanceListener listener,
com.atlassian.aws.AWSAccount awsAccount,
AgentManager agentManager,
ElasticImageConfiguration elasticImageConfiguration,
com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) |
void |
onInstanceIdentified(RemoteElasticInstance instance)
Tell the manager that the instance is up and running
|
void |
onInstanceRunning(RemoteElasticInstance instance)
Invoked when the instance enters the 'running' state
|
void |
registerElasticAgentStopped(RemoteElasticInstance instance)
Remove and EC2 instance from the "currently Running map
|
RemoteElasticInstance |
restoreElasticAgent(ElasticAgentDefinition elasticAgentDefinition,
ElasticTunnelDefinition elasticTunnelDefinition,
com.amazonaws.services.ec2.model.Instance instance,
RemoteElasticInstanceListener listener,
com.atlassian.aws.AWSAccount awsAccount,
AgentManager agentManager,
com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder)
After Bamboo server restart, reconnect to elastic agent.
|
void |
setTunnelTimeoutMinutes(int tunnelTimeoutMinutes) |
boolean |
validateAwsCredentials(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region,
String awsAccessID,
String awsSecretKey,
ErrorCollection errorCollection)
Validate a set of supplied AWS credentials.
|
boolean |
validateAwsCredentials(String awsAccessID,
String awsSecretKey,
ErrorCollection errorCollection) |
public ElasticInstanceManagerImpl(AwsAccountBean awsAccountBean, AdministrationConfigurationAccessor administrationConfigurationAccessor, int startupTimeoutSeconds, ScheduledExecutorService executor, KeyStoreFactory keyStoreFactory, SSLContextFactory sslContextFactory, BootstrapManager bootstrapManager, ErrorHandler errorHandler, SpotInstanceConfigurationAccessor spotInstanceConfigurationAccessor, com.atlassian.event.api.EventPublisher eventPublisher, SecretEncryptionService secretEncryptionService)
public RemoteElasticInstance newElasticAgent(RemoteElasticInstanceListener listener, com.atlassian.aws.AWSAccount awsAccount, @NotNull AgentManager agentManager, @NotNull ElasticImageConfiguration elasticImageConfiguration, @NotNull com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException
newElasticAgent
in interface ElasticInstanceManager
NoSuchAlgorithmException
KeyManagementException
IOException
CertificateException
UnrecoverableKeyException
KeyStoreException
public RemoteElasticInstance restoreElasticAgent(@NotNull ElasticAgentDefinition elasticAgentDefinition, @Nullable ElasticTunnelDefinition elasticTunnelDefinition, @NotNull com.amazonaws.services.ec2.model.Instance instance, @NotNull RemoteElasticInstanceListener listener, @NotNull com.atlassian.aws.AWSAccount awsAccount, @NotNull AgentManager agentManager, @NotNull com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) throws Exception
ElasticInstanceManager
restoreElasticAgent
in interface ElasticInstanceManager
Exception
public void ensureLoginKeyPairExists(com.atlassian.aws.AWSAccount awsAccount, String keyPair) throws com.atlassian.aws.AWSException
ElasticInstanceManager
Ensures that a key pair, named "elasticbamboo", has been defined in the configured AWS account.
ensureLoginKeyPairExists
in interface ElasticInstanceManager
awsAccount
- that should contain the key paircom.atlassian.aws.AWSException
- if there is a problem communicating with EC2.public boolean validateAwsCredentials(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region, String awsAccessID, String awsSecretKey, ErrorCollection errorCollection)
ElasticInstanceManager
Validate a set of supplied AWS credentials.
validateAwsCredentials
in interface ElasticInstanceManager
awsAccessID
- The Access ID of the Amazon Web Services AccountawsSecretKey
- The Secret Key of the Amazon Web Services AccounterrorCollection
- An ErrorCollection
to which validation errors should be added, or
null
if validation errors are not required.true
if the supplied credentials are successfully validated; false
otherwise.public boolean validateAwsCredentials(String awsAccessID, String awsSecretKey, ErrorCollection errorCollection)
validateAwsCredentials
in interface ElasticInstanceManager
@NotNull public List<RemoteElasticInstance> getElasticRemoteAgents()
ElasticInstanceManager
getElasticRemoteAgents
in interface ElasticInstanceManager
RemoteElasticInstance
@NotNull public List<RemoteElasticInstance> getElasticRemoteAgentsByConfiguration(@NotNull ElasticImageConfiguration elasticImageConfiguration)
getElasticRemoteAgentsByConfiguration
in interface ElasticInstanceManager
@NotNull public List<RemoteElasticInstance> getElasticRemoteAgentsByConfiguration(long id)
getElasticRemoteAgentsByConfiguration
in interface ElasticInstanceManager
@Nullable public RemoteElasticInstance getElasticRemoteAgentByInstanceId(String instanceId)
ElasticInstanceManager
getElasticRemoteAgentByInstanceId
in interface ElasticInstanceManager
instanceId
- of the instance@NotNull public List<RemoteElasticInstance> getRequestedElasticRemoteAgents()
ElasticInstanceManager
getRequestedElasticRemoteAgents
in interface ElasticInstanceManager
@NotNull public List<RemoteElasticInstance> getStartingElasticInstances()
ElasticInstanceManager
getStartingElasticInstances
in interface ElasticInstanceManager
@NotNull public List<RemoteElasticInstance> getInstancesWithStartingAgents()
ElasticInstanceManager
ElasticInstanceManager.getRequestedElasticRemoteAgents()
)
but the agent on the instance has not yet connected to the bamboo server. Elastic instances in such state are returned by this method
and the list is a subset of the list returned by ElasticInstanceManager.getElasticRemoteAgents()
.getInstancesWithStartingAgents
in interface ElasticInstanceManager
RemoteElasticInstance
public List<RemoteElasticInstance> getAllElasticRemoteAgents()
ElasticInstanceManager
getAllElasticRemoteAgents
in interface ElasticInstanceManager
public com.google.common.collect.SetMultimap<ElasticImageConfiguration,RemoteElasticInstance> getAllElasticAgentsAsMap()
ElasticInstanceManager
SetMultimap
, keyed by the ElasticImageConfiguration
getAllElasticAgentsAsMap
in interface ElasticInstanceManager
public int getTotalNumElasticRemoteAgents()
ElasticInstanceManager
getTotalNumElasticRemoteAgents
in interface ElasticInstanceManager
public void onInstanceIdentified(@NotNull RemoteElasticInstance instance)
ElasticInstanceManager
onInstanceIdentified
in interface ElasticInstanceManager
instance
- the instance identifiedpublic void onInstanceRunning(@NotNull RemoteElasticInstance instance)
ElasticInstanceManager
onInstanceRunning
in interface ElasticInstanceManager
instance
- the instance that entered running statepublic boolean cancelSpotRequests(@NotNull com.atlassian.aws.AWSAccount awsAccount)
ElasticInstanceManager
cancelSpotRequests
in interface ElasticInstanceManager
awsAccount
- accountpublic void registerElasticAgentStopped(@NotNull RemoteElasticInstance instance)
ElasticInstanceManager
registerElasticAgentStopped
in interface ElasticInstanceManager
instance
- - the one to be deleted from the mappublic void addElasticLogEntry(org.apache.log4j.Logger log, String logEntry)
addElasticLogEntry
in interface ElasticInstanceManager
public List<String> getElasticAgentLogs()
ElasticInstanceManager
getElasticAgentLogs
in interface ElasticInstanceManager
public boolean isElasticSupportEnabled()
isElasticSupportEnabled
in interface ElasticInstanceManager
@NotNull public Set<com.atlassian.aws.ec2.EC2InstanceType> getAllowedInstanceTypes()
getAllowedInstanceTypes
in interface ElasticInstanceManager
public int getTunnelPort()
ElasticAgentTunnelPorts
The TCP port upon which Elastic Agents listens for incoming tunnel connections from the Bamboo Server.
getTunnelPort
in interface ElasticAgentTunnelPorts
public int getAgentSideHttpPort()
ElasticAgentTunnelPorts
The TCP port upon which the Elastic Agent listens for HTTP traffic intended for the Bamboo Server.
getAgentSideHttpPort
in interface ElasticAgentTunnelPorts
public int getAgentSideJmsPort()
ElasticAgentTunnelPorts
The TCP port upon which the Elastic Agent listens for JMS traffic intended for the Bamboo Server.
getAgentSideJmsPort
in interface ElasticAgentTunnelPorts
public void setTunnelTimeoutMinutes(int tunnelTimeoutMinutes)
@NotNull public String getInstanceLogs(@NotNull String instanceId) throws com.atlassian.aws.AWSException
ElasticInstanceManager
getInstanceLogs
in interface ElasticInstanceManager
instanceId
- id of the instancecom.atlassian.aws.AWSException
- if an error occurs while fetching the console outputpublic boolean isInstanceKnown(@NotNull String instanceId)
ElasticInstanceManager
isInstanceKnown
in interface ElasticInstanceManager
instanceId
- id of the instancepublic String getBambooControlTag()
ElasticInstanceManager
getBambooControlTag
in interface ElasticInstanceManager
Copyright © 2021 Atlassian Software Systems Pty Ltd. All rights reserved.