Class CloudManagerFacade
- java.lang.Object
-
- jetbrains.buildServer.clouds.server.impl.CloudManagerFacade
-
- All Implemented Interfaces:
CloudInstanceManager
,CloudManager
public class CloudManagerFacade extends Object implements CloudManager
- Author:
- Eugene Petrenko Created: 17.09.2009 0:15:48
-
-
Constructor Summary
Constructors Constructor Description CloudManagerFacade(CloudManagerBase base, CloudAgentRelation relation, StartInstanceAction startAction, StopInstanceQueue stopInstanceQueue, CloudAgentTypeProvider types, RunningAgentsTracker tracker, CloudStateManager stateManager, CloudInstancesProvider instancesProvider, CloudQuotaChecker cloudQuotaChecker, DeleteProfileAndStopInstancesAction deleteProfileAndStopInstancesAction, DeleteImageAndStopInstancesAction deleteImageAndStopInstancesAction, DisposeClientAndStopInstancesAction disposeClientAndStopInstancesAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CanStartNewInstanceResult
canStartNewInstance(CloudProfile profile, CloudImage image)
Indicates whether it's possible to start a new instance of a certain image in particular cloud profileCloudImageParameters
createImage(String projectId, CloudImageData imageData)
CloudProfile
createProfile(String projectId, CloudProfileData profileData)
void
deleteImage(String projectId, String profileId, String imageId)
Deletes a cloud image with the specified imageId from a cloud profilevoid
deleteImageAndInstances(String projectId, String profileId, String imageId, TerminateInstanceReason reason)
Deletes a cloud image with the specified imageId from a cloud profile.void
disposeClient(String projectId, String profileId)
Disposes of the client associated to the cloud profile with the given project and profile IDs.void
disposeClientAndRemoveInstances(String projectId, String profileId, TerminateInstanceReason reason)
Disposes of the client associated to the cloud profile with the given project and profile IDs.Collection<SBuildAgent>
findAgentByInstance(String profileId, String instanceId)
CloudType
findCloudType(String cloudName)
Returns cloud type for name or nullCloudImageParameters
findImageByInternalId(String projectId, String imageInternalId)
Pair<CloudProfile,CloudInstance>
findInstanceByAgent(AgentDescription desc)
Checks if the agent is an instnce of one of the running instances.CloudInstance
findInstanceById(String projectId, String profileId, String instanceId)
Returns instance by the specified identifier.Map<AgentDescription,Pair<CloudProfile,CloudInstance>>
findInstancesByAgents(Collection<? extends AgentDescription> agents)
Finds cloud instances (if any) for the collection of agentsCloudProfile
findProfileById(String projectId, String profileId)
Returns profile by the specified identifier in a certain project.CloudProfile
findProfileByImageId(String imageId)
CloudProfile
findProfileGloballyById(String profileId)
Returns profile by the specified identifier.String
generateAgentName(AgentDescription agent)
Generated name for build agent that is thought to be running as instance of this cloud client.CloudClientEx
getClient(String projectId, String profileId)
Provides a client for the specified profile.CloudClientEx
getClientIfExists(String projectId, String profileId)
Provides a client for the specified profile.Collection<? extends CloudType>
getCloudTypes()
Returns all available "Real" cloud types, excluding ReadOnlyClient (which is not a "real" cloud type, but rather used to show instances on the secondary nodes).SAgentType
getDescriptionFor(CloudProfile prof, String imageId)
Fetches recorded agent descriptionProjectCloudIntegrationStatus
getProjectIntegrationStatus(String projectId)
String
getServerUrlForAgent(CloudProfile profile, CloudImage image)
Server url that will be sent to new created build agentboolean
isConfigurable(String projectId)
Can enable/disable configuration in the current project's treeboolean
isImageWithAgent(CloudProfile profile, CloudImage image)
Checks if the image is configured to start agent.boolean
isInstanceExpired(String profileId, String instanceId)
Returns true, if instance will be terminated after current build finishesboolean
isIntegrationEnabled(String projectId)
void
iterateInstances(CloudInstancesProviderCallback callback)
Iterates through all running instances of all profiles.void
iterateInstances(CloudInstancesProviderExtendedCallback callback)
Iterates through all running instances of all profiles.void
iterateProfileInstances(CloudProfile profile, CloudInstancesProviderExtendedCallback callback)
Iterates through all running instances of all profiles.Collection<CloudProfile>
listAllProfiles()
Returns all cloud profiles.Collection<CloudImageParameters>
listImagesByProject(String projectId)
Collection<CloudProfile>
listProfilesByProject(String projectId, boolean includeFromSubprojects)
Returns cloud profiles defined in the current project.void
markInstanceExpired(String profileId, String instanceId)
Marks the instance as expired, so it should be terminated after current build finishesboolean
removeProfile(String projectId, String profileId)
void
removeProfileAndInstances(String projectId, String profileId, TerminateInstanceReason reason)
Terminate all running instance for the profile and then removes the profile itselfvoid
setProfileEnabled(String projectId, String profileId, boolean enabled)
CloudInstance
startInstance(String projectId, String profileId, String imageId, StartInstanceReason reason)
Starts new agent instance for given profile and imageCloudInstance
startInstance(String profileId, String imageId, StartInstanceReason reason)
void
terminateInstance(String projectId, String profileId, String imageId, String instanceId, TerminateInstanceReason reason)
Schedules termination a running instancevoid
terminateInstance(String profileId, String imageId, String instanceId, TerminateInstanceReason reason)
Deprecated.void
terminateProfileInstances(String projectId, String profileId, TerminateInstanceReason reason)
Terminate all running instance for the profilevoid
terminateProfileInstances(String profileId, TerminateInstanceReason reason)
Deprecated.void
terminateProjectInstances(String projectId, TerminateInstanceReason reason, boolean subProjectsOnly)
Terminate all running instanceCloudProfile
updateProfile(String projectId, String profileId, CloudProfileData profileData)
void
updateStatus(String projectId, ProjectCloudIntegrationStatus newStatus)
Updates enabled/disabled status of integration-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.clouds.server.CloudManager
findAgentByInstance, isInstanceExpired, markInstanceExpired
-
-
-
-
Constructor Detail
-
CloudManagerFacade
public CloudManagerFacade(@NotNull CloudManagerBase base, @NotNull CloudAgentRelation relation, @NotNull StartInstanceAction startAction, @NotNull StopInstanceQueue stopInstanceQueue, @NotNull CloudAgentTypeProvider types, @NotNull RunningAgentsTracker tracker, @NotNull CloudStateManager stateManager, @NotNull CloudInstancesProvider instancesProvider, @NotNull CloudQuotaChecker cloudQuotaChecker, @NotNull DeleteProfileAndStopInstancesAction deleteProfileAndStopInstancesAction, @NotNull DeleteImageAndStopInstancesAction deleteImageAndStopInstancesAction, @NotNull DisposeClientAndStopInstancesAction disposeClientAndStopInstancesAction)
-
-
Method Detail
-
isIntegrationEnabled
public boolean isIntegrationEnabled(String projectId)
- Specified by:
isIntegrationEnabled
in interfaceCloudManager
- Returns:
- false if user decided to disabled cloud integration at all
-
isConfigurable
public boolean isConfigurable(@NotNull String projectId)
Can enable/disable configuration in the current project's tree- Specified by:
isConfigurable
in interfaceCloudManager
- Parameters:
projectId
- project internal id- Returns:
- see above
-
updateStatus
public void updateStatus(String projectId, @NotNull ProjectCloudIntegrationStatus newStatus)
Description copied from interface:CloudManager
Updates enabled/disabled status of integration- Specified by:
updateStatus
in interfaceCloudManager
-
getProjectIntegrationStatus
@Nullable public ProjectCloudIntegrationStatus getProjectIntegrationStatus(String projectId)
- Specified by:
getProjectIntegrationStatus
in interfaceCloudManager
- Parameters:
projectId
- - project internal id- Returns:
- returns cloud integration status information in this project; null, if project doesn't have any information (inherits from parent project)
-
listProfilesByProject
@NotNull public Collection<CloudProfile> listProfilesByProject(String projectId, boolean includeFromSubprojects)
Description copied from interface:CloudManager
Returns cloud profiles defined in the current project.- Specified by:
listProfilesByProject
in interfaceCloudManager
- Returns:
- list of profiles; order of items is not specified (or depend on this interface implementation); empty list when no ones.
-
listAllProfiles
@NotNull public Collection<CloudProfile> listAllProfiles()
Description copied from interface:CloudManager
Returns all cloud profiles.- Specified by:
listAllProfiles
in interfaceCloudManager
- Returns:
- list of profiles; order of items is not specified (or depend on this interface implementation); empty list when no ones.
-
getCloudTypes
@NotNull public Collection<? extends CloudType> getCloudTypes()
Description copied from interface:CloudManager
Returns all available "Real" cloud types, excluding ReadOnlyClient (which is not a "real" cloud type, but rather used to show instances on the secondary nodes).- Specified by:
getCloudTypes
in interfaceCloudManager
- Returns:
- list of types. No order specified
-
findCloudType
public CloudType findCloudType(@Nullable String cloudName)
Description copied from interface:CloudManager
Returns cloud type for name or null- Specified by:
findCloudType
in interfaceCloudManager
- Parameters:
cloudName
- cloud type ID- Returns:
- registered cloud type or null
-
findProfileById
@Nullable public CloudProfile findProfileById(@NotNull String projectId, @NotNull String profileId)
Description copied from interface:CloudManager
Returns profile by the specified identifier in a certain project.- Specified by:
findProfileById
in interfaceCloudManager
- Parameters:
projectId
- internal project idprofileId
- , seeCloudProfile.getProfileId()
.- Returns:
- found profile or null if no such ones.
-
findProfileGloballyById
@Nullable public CloudProfile findProfileGloballyById(@NotNull String profileId)
Returns profile by the specified identifier.- Specified by:
findProfileGloballyById
in interfaceCloudManager
- Parameters:
profileId
-- Returns:
- found profile or null if no such ones.
-
findInstanceById
@Nullable public CloudInstance findInstanceById(@NotNull String projectId, @NotNull String profileId, @NotNull String instanceId)
Description copied from interface:CloudManager
Returns instance by the specified identifier.- Specified by:
findInstanceById
in interfaceCloudManager
- Returns:
- found instance or null if no such ones.
-
getClient
@NotNull public CloudClientEx getClient(String projectId, @NotNull String profileId) throws CloudException, IllegalArgumentException
Description copied from interface:CloudManager
Provides a client for the specified profile. Creates a new client or gets a cached one if exists.- Specified by:
getClient
in interfaceCloudManager
profileId
- id of profile, seeCloudProfile.getProfileId()
.- Returns:
- correct ready for use cloud client.
- Throws:
CloudException
- eIllegalArgumentException
- e
-
getClientIfExists
@Nullable public CloudClientEx getClientIfExists(String projectId, @NotNull String profileId) throws CloudException, IllegalArgumentException
Description copied from interface:CloudManager
Provides a client for the specified profile. Creates gets a cached one if exists, returns null otherwise- Specified by:
getClientIfExists
in interfaceCloudManager
profileId
- id of profile, seeCloudProfile.getProfileId()
.- Returns:
- correct ready for use cloud client.
- Throws:
CloudException
- eIllegalArgumentException
- e
-
findInstanceByAgent
public Pair<CloudProfile,CloudInstance> findInstanceByAgent(@NotNull AgentDescription desc)
Description copied from interface:CloudManager
Checks if the agent is an instnce of one of the running instances.- Specified by:
findInstanceByAgent
in interfaceCloudManager
- Parameters:
desc
- agent description of an agent that is going to connect- Returns:
- corresponding
CloudInstance
if found or null
-
findInstancesByAgents
@NotNull public Map<AgentDescription,Pair<CloudProfile,CloudInstance>> findInstancesByAgents(@NotNull Collection<? extends AgentDescription> agents)
Description copied from interface:CloudManager
Finds cloud instances (if any) for the collection of agents- Specified by:
findInstancesByAgents
in interfaceCloudManager
- Parameters:
agents
- agent descriptions of agents- Returns:
- found pairs of agents and cloud instances. For agents that we don't find cloud instance for there's no entry in this collection
-
findAgentByInstance
@NotNull public Collection<SBuildAgent> findAgentByInstance(@NotNull String profileId, @NotNull String instanceId)
- Specified by:
findAgentByInstance
in interfaceCloudManager
- Returns:
- agent, if any, that associated with the instance, profile pair
-
isImageWithAgent
public boolean isImageWithAgent(@NotNull CloudProfile profile, @NotNull CloudImage image)
Description copied from interface:CloudManager
Checks if the image is configured to start agent. If unknown - true is returned- Specified by:
isImageWithAgent
in interfaceCloudManager
- Parameters:
profile
- profileimage
- image- Returns:
- true is this image may contain agent, false if it is definitly broken
-
getServerUrlForAgent
@NotNull public String getServerUrlForAgent(@NotNull CloudProfile profile, @NotNull CloudImage image)
Description copied from interface:CloudManager
Server url that will be sent to new created build agent- Specified by:
getServerUrlForAgent
in interfaceCloudManager
- Parameters:
profile
- profileimage
- image- Returns:
- server url
-
generateAgentName
@Nullable public String generateAgentName(@NotNull AgentDescription agent)
Description copied from interface:CloudManager
Generated name for build agent that is thought to be running as instance of this cloud client.- Specified by:
generateAgentName
in interfaceCloudManager
- Parameters:
agent
- agent instance- Returns:
- proposed build agent name or null
-
isInstanceExpired
public boolean isInstanceExpired(@NotNull String profileId, @NotNull String instanceId)
Description copied from interface:CloudManager
Returns true, if instance will be terminated after current build finishes- Specified by:
isInstanceExpired
in interfaceCloudManager
- Returns:
- true, if no other buids will be run on this instance. False otherwise
-
markInstanceExpired
public void markInstanceExpired(@NotNull String profileId, @NotNull String instanceId)
Description copied from interface:CloudManager
Marks the instance as expired, so it should be terminated after current build finishes- Specified by:
markInstanceExpired
in interfaceCloudManager
-
createProfile
@NotNull public CloudProfile createProfile(@NotNull String projectId, @NotNull CloudProfileData profileData)
- Specified by:
createProfile
in interfaceCloudManager
-
updateProfile
@NotNull public CloudProfile updateProfile(@NotNull String projectId, @NotNull String profileId, @NotNull CloudProfileData profileData)
- Specified by:
updateProfile
in interfaceCloudManager
-
removeProfile
public boolean removeProfile(@NotNull String projectId, @NotNull String profileId)
- Specified by:
removeProfile
in interfaceCloudManager
-
setProfileEnabled
public void setProfileEnabled(@NotNull String projectId, @NotNull String profileId, boolean enabled)
- Specified by:
setProfileEnabled
in interfaceCloudManager
-
listImagesByProject
@NotNull public Collection<CloudImageParameters> listImagesByProject(@NotNull String projectId)
- Specified by:
listImagesByProject
in interfaceCloudManager
-
createImage
@NotNull public CloudImageParameters createImage(@NotNull String projectId, @NotNull CloudImageData imageData)
- Specified by:
createImage
in interfaceCloudManager
-
deleteImageAndInstances
public void deleteImageAndInstances(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull TerminateInstanceReason reason)
Description copied from interface:CloudManager
Deletes a cloud image with the specified imageId from a cloud profile. Will also remove any instances running of this image- Specified by:
deleteImageAndInstances
in interfaceCloudManager
- Parameters:
projectId
- The ID of the project that the image belongs to. Cannot be null.profileId
- The ID of the profile that the image belongs to. Cannot be null.imageId
- The ID of the image to be deleted. Cannot be null.reason
- reason of termination
-
deleteImage
public void deleteImage(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId)
Description copied from interface:CloudManager
Deletes a cloud image with the specified imageId from a cloud profile- Specified by:
deleteImage
in interfaceCloudManager
- Parameters:
projectId
- The ID of the project that the image belongs to. Cannot be null.profileId
- The ID of the profile that the image belongs to. Cannot be null.imageId
- The ID of the image to be deleted. Cannot be null.
-
findImageByInternalId
@Nullable public CloudImageParameters findImageByInternalId(@NotNull String projectId, @NotNull String imageInternalId)
- Specified by:
findImageByInternalId
in interfaceCloudManager
-
findProfileByImageId
@Nullable public CloudProfile findProfileByImageId(@NotNull String imageId)
- Specified by:
findProfileByImageId
in interfaceCloudManager
-
startInstance
@NotNull public CloudInstance startInstance(@NotNull String profileId, @NotNull String imageId, @NotNull StartInstanceReason reason) throws StartAgentQuotaExceededException, FailedToStartInstanceException
- Specified by:
startInstance
in interfaceCloudInstanceManager
- Throws:
StartAgentQuotaExceededException
FailedToStartInstanceException
-
startInstance
public CloudInstance startInstance(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull StartInstanceReason reason) throws StartAgentQuotaExceededException, FailedToStartInstanceException
Description copied from interface:CloudInstanceManager
Starts new agent instance for given profile and image- Specified by:
startInstance
in interfaceCloudInstanceManager
- Parameters:
projectId
- projectIdprofileId
- profileIdimageId
- imageIdreason
- reason why instance is stared. Used for logging- Throws:
StartAgentQuotaExceededException
- if there is not enough quotaFailedToStartInstanceException
- if image or profile was not found
-
canStartNewInstance
@NotNull public CanStartNewInstanceResult canStartNewInstance(@NotNull CloudProfile profile, @NotNull CloudImage image)
Description copied from interface:CloudInstanceManager
Indicates whether it's possible to start a new instance of a certain image in particular cloud profile- Specified by:
canStartNewInstance
in interfaceCloudInstanceManager
- Returns:
- see above
-
terminateInstance
@Deprecated public void terminateInstance(@NotNull String profileId, @NotNull String imageId, @NotNull String instanceId, @NotNull TerminateInstanceReason reason)
Deprecated.- Specified by:
terminateInstance
in interfaceCloudInstanceManager
-
terminateInstance
public void terminateInstance(@NotNull String projectId, @NotNull String profileId, @NotNull String imageId, @NotNull String instanceId, @NotNull TerminateInstanceReason reason)
Description copied from interface:CloudInstanceManager
Schedules termination a running instance- Specified by:
terminateInstance
in interfaceCloudInstanceManager
- Parameters:
projectId
- projectIdprofileId
- profileIdimageId
- imageIdinstanceId
- instanceIdreason
- reason why instance is terminated. Used for logging
-
terminateProfileInstances
@Deprecated public void terminateProfileInstances(@NotNull String profileId, @NotNull TerminateInstanceReason reason)
Deprecated.- Specified by:
terminateProfileInstances
in interfaceCloudInstanceManager
-
terminateProfileInstances
public void terminateProfileInstances(@NotNull String projectId, @NotNull String profileId, @NotNull TerminateInstanceReason reason)
Description copied from interface:CloudInstanceManager
Terminate all running instance for the profile- Specified by:
terminateProfileInstances
in interfaceCloudInstanceManager
- Parameters:
projectId
- projectIdprofileId
- profileIdreason
- reason of temination
-
terminateProjectInstances
public void terminateProjectInstances(@NotNull String projectId, @NotNull TerminateInstanceReason reason, boolean subProjectsOnly)
Description copied from interface:CloudInstanceManager
Terminate all running instance- Specified by:
terminateProjectInstances
in interfaceCloudInstanceManager
reason
- reason of termination
-
getDescriptionFor
public SAgentType getDescriptionFor(@NotNull CloudProfile prof, @NotNull String imageId)
Description copied from interface:CloudManager
Fetches recorded agent description- Specified by:
getDescriptionFor
in interfaceCloudManager
- Parameters:
prof
- profileimageId
- image id- Returns:
- description if found
-
iterateInstances
public void iterateInstances(@NotNull CloudInstancesProviderCallback callback)
Description copied from interface:CloudInstanceManager
Iterates through all running instances of all profiles.- Specified by:
iterateInstances
in interfaceCloudInstanceManager
- Parameters:
callback
- uses this interface to notify next instance
-
iterateInstances
public void iterateInstances(@NotNull CloudInstancesProviderExtendedCallback callback)
Description copied from interface:CloudInstanceManager
Iterates through all running instances of all profiles.- Specified by:
iterateInstances
in interfaceCloudInstanceManager
- Parameters:
callback
- uses this interface to notify next instance
-
iterateProfileInstances
public void iterateProfileInstances(@NotNull CloudProfile profile, @NotNull CloudInstancesProviderExtendedCallback callback)
Description copied from interface:CloudInstanceManager
Iterates through all running instances of all profiles.- Specified by:
iterateProfileInstances
in interfaceCloudInstanceManager
callback
- uses this interface to notify next instance
-
removeProfileAndInstances
public void removeProfileAndInstances(@NotNull String projectId, @NotNull String profileId, TerminateInstanceReason reason)
Description copied from interface:CloudManager
Terminate all running instance for the profile and then removes the profile itself- Specified by:
removeProfileAndInstances
in interfaceCloudManager
- Parameters:
projectId
- projectIdprofileId
- profileIdreason
- reason of temination
-
disposeClientAndRemoveInstances
public void disposeClientAndRemoveInstances(@NotNull String projectId, @NotNull String profileId, @NotNull TerminateInstanceReason reason)
Description copied from interface:CloudManager
Disposes of the client associated to the cloud profile with the given project and profile IDs. Will terminate all running instances- Specified by:
disposeClientAndRemoveInstances
in interfaceCloudManager
- Parameters:
projectId
- the unique identifier of the projectprofileId
- the unique identifier of the profilereason
- reason of termination
-
disposeClient
public void disposeClient(@NotNull String projectId, @NotNull String profileId)
Description copied from interface:CloudManager
Disposes of the client associated to the cloud profile with the given project and profile IDs.- Specified by:
disposeClient
in interfaceCloudManager
- Parameters:
projectId
- the unique identifier of the projectprofileId
- the unique identifier of the profile
-
-