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 Details

    • AgentHibernateDao

      public AgentHibernateDao()
  • Method Details

    • getPersistentClass

      public Class getPersistentClass()
      Specified by:
      getPersistentClass in interface bucket.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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
      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 interface bucket.core.persistence.ObjectDao
      Overrides:
      findAll in class BambooHibernateObjectDao
      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 interface AgentDao
      Returns:
      list of all agents
    • findAllRemoteAgents

      public List<RemoteAgentDefinition> findAllRemoteAgents()
      Description copied from interface: AgentDao
      Retrieves all remote agents
      Specified by:
      findAllRemoteAgents in interface AgentDao
      Returns:
      list of all remote agents
    • findAllEphemeralAgents

      public List<EphemeralAgentDefinition> findAllEphemeralAgents()
      Description copied from interface: AgentDao
      Retrieves all ephemeral agents
      Specified by:
      findAllEphemeralAgents in interface AgentDao
      Returns:
      list of all ephemeral agents
    • findAllLocalAgents

      public List<LocalAgentDefinition> findAllLocalAgents()
      Description copied from interface: AgentDao
      Retrieves all local agents
      Specified by:
      findAllLocalAgents in interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
    • 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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao
      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 interface AgentDao