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
public class AgentHibernateDao extends BambooHibernateObjectDao implements AgentDao
-
-
Constructor Summary
Constructors Constructor Description AgentHibernateDao()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable PipelineDefinition
findAgentByName(@NotNull String name)
Retrieve a pipelineDefinition by name.List<PipelineDefinition>
findAll()
Find all objects of the class provided by getPersistentClass()List<PipelineDefinition>
findAllAgents()
Retrieves all agents();Set<PipelineDefinition>
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 agentsList<EphemeralAgentDefinition>
findAllEphemeralAgents()
Retrieves all ephemeral agentsList<LocalAgentDefinition>
findAllLocalAgents()
Retrieves all local agentsList<RemoteAgentDefinition>
findAllRemoteAgents()
Retrieves all remote agentsList<ElasticAgentDefinition>
findNotShutDownElasticAgents()
Retrieves all agents without a shutdown time definedPipelineDefinition
getAgentById(long id)
Retrieve the agentDefinition object.long
getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
Retrieves the amount of agents of given type stored in the databaseLocalAgentDefinition
getLocalAgentById(long id)
Retrieve the localAgentDefinitionClass
getPersistentClass()
RemoteAgentDefinition
getRemoteAgentById(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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.atlassian.bamboo.persistence.BambooObjectDao
findById
-
-
-
-
Method Detail
-
getPersistentClass
public Class 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
public PipelineDefinition getAgentById(long id)
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
public LocalAgentDefinition getLocalAgentById(long id)
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
public RemoteAgentDefinition getRemoteAgentById(long id)
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
public List<PipelineDefinition> 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
public List<PipelineDefinition> findAllAgents()
Description copied from interface:AgentDao
Retrieves all agents();- Specified by:
findAllAgents
in interfaceAgentDao
- Returns:
- list of all agents
-
findAllRemoteAgents
public List<RemoteAgentDefinition> findAllRemoteAgents()
Description copied from interface:AgentDao
Retrieves all remote agents- Specified by:
findAllRemoteAgents
in interfaceAgentDao
- Returns:
- list of all remote agents
-
findAllEphemeralAgents
public List<EphemeralAgentDefinition> findAllEphemeralAgents()
Description copied from interface:AgentDao
Retrieves all ephemeral agents- Specified by:
findAllEphemeralAgents
in interfaceAgentDao
- Returns:
- list of all ephemeral agents
-
findAllLocalAgents
public List<LocalAgentDefinition> findAllLocalAgents()
Description copied from interface:AgentDao
Retrieves all local agents- Specified by:
findAllLocalAgents
in interfaceAgentDao
- Returns:
- list of all local agents
-
findNotShutDownElasticAgents
public List<ElasticAgentDefinition> 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
public long getAgentCount(Class<? extends PipelineDefinition> agentDefinitionClass)
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
@Nullable public @Nullable PipelineDefinition findAgentByName(@NotNull @NotNull String name)
Description copied from interface:AgentDao
Retrieve a pipelineDefinition by name. Names should be unique.- Specified by:
findAgentByName
in interfaceAgentDao
- Parameters:
name
- of the agent to find- Returns:
- the agent that has the given name.
-
updateAgentShutdownTime
public void updateAgentShutdownTime(@NotNull @NotNull PipelineDefinition agentDefinition)
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
-
-