Class AgentHibernateDao
java.lang.Object
org.springframework.dao.support.DaoSupport
org.springframework.orm.hibernate5.support.HibernateDaoSupport
com.atlassian.bamboo.persistence.BambooHibernateObjectDao
com.atlassian.bamboo.buildqueue.dao.AgentHibernateDao
- All Implemented Interfaces:
bucket.core.persistence.ObjectDao
,AgentDao
,BambooObjectDao
,org.springframework.beans.factory.InitializingBean
-
Field Summary
Fields inherited from class org.springframework.dao.support.DaoSupport
logger
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription@Nullable PipelineDefinition
findAgentByName
(@NotNull String name) Retrieve aPipelineDefinition
by name.@NotNull List<PipelineDefinition>
findAgentsByName
(@NotNull String name) RetrievePipelineDefinition
s by name.findAll()
Find all objects of the class provided by getPersistentClass()Retrieves all agents();findAllAgentsForAgentIds
(@NotNull Collection<Long> agentIds) Return a list of agents by their ids@NotNull List<PipelineDefinition>
findAllAgentsWithNameLike
(@NotNull String nameLike) Retrun a list of agents whose name is like the provided string.@NotNull List<ElasticAgentDefinition>
findAllElasticAgents
(int firstResult, int maxResults) Retrieves n most recently terminated elastic agents, ordered by termination time, descending.@NotNull List<ElasticAgentDefinition>
findAllElasticAgents
(@NotNull Collection<String> instanceIds) Retrieves all elastic agentsRetrieves all ephemeral agentsRetrieves all local agentsRetrieves all remote agentsRetrieves all agents without a shutdown time definedgetAgentById
(long id) Retrieve the agentDefinition object.long
getAgentCount
(Class<? extends PipelineDefinition> agentDefinitionClass) Retrieves the amount of agents of given type stored in the databasegetLocalAgentById
(long id) Retrieve the localAgentDefinitiongetRemoteAgentById
(long id) Retrieve the remoteAgentDefinition@NotNull PipelineDefinition
saveAndReturn
(@NotNull PipelineDefinition pipelineDefinition) Saves the passed definition and returns a new copy of the updated pipeline definitionvoid
updateAgentShutdownTime
(@NotNull PipelineDefinition agentDefinition) Updates agent shutdown time taking into account that passed object might not be in session.Methods inherited from class com.atlassian.bamboo.persistence.BambooHibernateObjectDao
findAllSorted, findById, findById, refresh, remove, replicate, save, saveRaw, updateModificationData
Methods inherited from class org.springframework.orm.hibernate5.support.HibernateDaoSupport
checkDaoConfig, createHibernateTemplate, currentSession, getHibernateTemplate, getSessionFactory, setHibernateTemplate, setSessionFactory
Methods inherited from class org.springframework.dao.support.DaoSupport
afterPropertiesSet, initDao
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.atlassian.bamboo.persistence.BambooObjectDao
findById
Methods inherited from interface bucket.core.persistence.ObjectDao
findAllSorted, refresh, remove, replicate, save, saveRaw
-
Constructor Details
-
AgentHibernateDao
public AgentHibernateDao()
-
-
Method Details
-
getPersistentClass
- Specified by:
getPersistentClass
in interfacebucket.core.persistence.ObjectDao
-
saveAndReturn
@NotNull public @NotNull PipelineDefinition saveAndReturn(@NotNull @NotNull PipelineDefinition pipelineDefinition) Description copied from interface:AgentDao
Saves the passed definition and returns a new copy of the updated pipeline definition- Specified by:
saveAndReturn
in interfaceAgentDao
- Parameters:
pipelineDefinition
- to save- Returns:
- the saved and updated (e.g with agentId) pipelineDefinition
-
getAgentById
Description copied from interface:AgentDao
Retrieve the agentDefinition object.- Specified by:
getAgentById
in interfaceAgentDao
- Parameters:
id
- - the id for the agent to be retrieved- Returns:
- agentDefinition associated with the agentId or null if it couldn't be found
-
getLocalAgentById
Description copied from interface:AgentDao
Retrieve the localAgentDefinition- Specified by:
getLocalAgentById
in interfaceAgentDao
- Parameters:
id
- of the agent- Returns:
- LocalAgentDefintion associated with the id if no agent found, returns null
-
getRemoteAgentById
Description copied from interface:AgentDao
Retrieve the remoteAgentDefinition- Specified by:
getRemoteAgentById
in interfaceAgentDao
- Parameters:
id
- of the agent- Returns:
- RemoteAgentDefintion associated with the id if no agent found, returns null
-
findAll
Description copied from class:BambooHibernateObjectDao
Find all objects of the class provided by getPersistentClass()- Specified by:
findAll
in interfacebucket.core.persistence.ObjectDao
- Overrides:
findAll
in classBambooHibernateObjectDao
- Returns:
- a list of all objects of the appropriate class, or the empty list if no objects are found
-
findAllAgents
Description copied from interface:AgentDao
Retrieves all agents();- Specified by:
findAllAgents
in interfaceAgentDao
- Returns:
- list of all agents
-
findAllRemoteAgents
Description copied from interface:AgentDao
Retrieves all remote agents- Specified by:
findAllRemoteAgents
in interfaceAgentDao
- Returns:
- list of all remote agents
-
findAllEphemeralAgents
Description copied from interface:AgentDao
Retrieves all ephemeral agents- Specified by:
findAllEphemeralAgents
in interfaceAgentDao
- Returns:
- list of all ephemeral agents
-
findAllLocalAgents
Description copied from interface:AgentDao
Retrieves all local agents- Specified by:
findAllLocalAgents
in interfaceAgentDao
- Returns:
- list of all local agents
-
findNotShutDownElasticAgents
Description copied from interface:AgentDao
Retrieves all agents without a shutdown time defined- Specified by:
findNotShutDownElasticAgents
in interfaceAgentDao
- Returns:
- all agents without a shutdown time defined
-
getAgentCount
Description copied from interface:AgentDao
Retrieves the amount of agents of given type stored in the database- Specified by:
getAgentCount
in interfaceAgentDao
- Parameters:
agentDefinitionClass
- agent type- Returns:
- amount of agents
-
findAllElasticAgents
@NotNull public @NotNull List<ElasticAgentDefinition> findAllElasticAgents(int firstResult, int maxResults) Description copied from interface:AgentDao
Retrieves n most recently terminated elastic agents, ordered by termination time, descending.- Specified by:
findAllElasticAgents
in interfaceAgentDao
-
findAllElasticAgents
@NotNull public @NotNull List<ElasticAgentDefinition> findAllElasticAgents(@NotNull @NotNull Collection<String> instanceIds) Description copied from interface:AgentDao
Retrieves all elastic agents- Specified by:
findAllElasticAgents
in interfaceAgentDao
- Parameters:
instanceIds
- the instances ids on which the agents were running
-
findAllAgentsWithNameLike
@NotNull public @NotNull List<PipelineDefinition> findAllAgentsWithNameLike(@NotNull @NotNull String nameLike) Description copied from interface:AgentDao
Retrun a list of agents whose name is like the provided string. Uses hibernate's "like" so % to mark wild card.- Specified by:
findAllAgentsWithNameLike
in interfaceAgentDao
- Parameters:
nameLike
- the string to match- Returns:
- List of Pipeline Definitions
-
findAllAgentsForAgentIds
public Set<PipelineDefinition> findAllAgentsForAgentIds(@NotNull @NotNull Collection<Long> agentIds) Description copied from interface:AgentDao
Return a list of agents by their ids- Specified by:
findAllAgentsForAgentIds
in interfaceAgentDao
- Returns:
- List of
PipelineDefinition
-
findAgentByName
Description copied from interface:AgentDao
Retrieve aPipelineDefinition
by name. Names should be unique. If duplicated names exist, this method will throwNonUniqueResultException
exception.- Specified by:
findAgentByName
in interfaceAgentDao
- Parameters:
name
- of the agent to find- Returns:
- the agent that has the given name.
-
findAgentsByName
Description copied from interface:AgentDao
RetrievePipelineDefinition
s by name. Names should be unique. However, duplicates are possible due to not properly handled unsuccessful registration attempts.- Specified by:
findAgentsByName
in interfaceAgentDao
- Parameters:
name
- of the agent to find- Returns:
- the list of agents that have the given name.
-
updateAgentShutdownTime
Description copied from interface:AgentDao
Updates agent shutdown time taking into account that passed object might not be in session.- Specified by:
updateAgentShutdownTime
in interfaceAgentDao
-