Interface AgentPersister

    • Method Detail

      • loadRegisteredAgents

        @NotNull
        List<AgentData> loadRegisteredAgents()
        Load all registered agents from database.
      • loadAgent

        @Nullable
        AgentData loadAgent​(int agentId,
                            boolean includeUnregistered)
        Load agent data from database
      • loadAgent

        @Nullable
        AgentData loadAgent​(String agentName,
                            boolean includeUnregistered)
      • setEnabled

        void setEnabled​(@NotNull
                        BuildAgentEx agent,
                        boolean enabled)
        Persists this agent status enabled status in database.
        Parameters:
        agent - which status to persist
        enabled - enabled value
      • setEnabled

        void setEnabled​(@NotNull
                        BuildAgentEx agent,
                        boolean enabled,
                        long statusRestoringTimestamp)
        Persists this agent status enabled status in database.
        Parameters:
        agent - which status to persist
        enabled - enabled value
        statusRestoringTimestamp - timestamp at which agent status will be restored
      • restoreAgentsEnabledStatusesIfNeeded

        void restoreAgentsEnabledStatusesIfNeeded​(@NotNull
                                                  Function<Integer,​BuildAgentEx> agentSupplier)
        Restores agents statuses if needed
      • setAuthorized

        void setAuthorized​(@NotNull
                           BuildAgentEx agent,
                           boolean authorized)
        Persists this agent authorized status in database.
        Parameters:
        agent - which status to persist
        authorized - authorized value
      • setAgentTypeId

        void setAgentTypeId​(@NotNull
                            BuildAgentEx agent,
                            int agentTypeId)
        Persists agent type id
        Parameters:
        agent - agent
        agentTypeId - agent type id
      • restoreAgentStatus

        boolean restoreAgentStatus​(@NotNull
                                   BuildAgentEx agent)
        Returns true if agent exists in database and its' status has been restored.
        Parameters:
        agent - agent to restore
        Returns:
        true if agent exists in database and its' status has been restored and false otherwise
      • register

        void register​(@NotNull
                      BuildAgentEx agent)
        Marks agent as registered in database.
        Parameters:
        agent - agent to update
      • unregister

        void unregister​(@NotNull
                        BuildAgentEx agent,
                        @NotNull
                        String unregisterReason)
        Marks agent as unregistered in database.
        Parameters:
        agent - agent to update
        unregisterReason - reason of unregistering
      • generateUniqueAuthorizationToken

        void generateUniqueAuthorizationToken​(BuildAgentEx agent)
        Generates new unique token which should be used to authorize this agent
        Parameters:
        agent - agent
      • removeAgent

        void removeAgent​(@NotNull
                         BuildAgentEx agent)
        Removes agent from the database.
        Parameters:
        agent - agent to remove
      • resetAgentCaches

        void resetAgentCaches​(int agentId)
        Should be called to cleanup internal caches when server detected that agent was removed
        Parameters:
        agent -
        Since:
        2020.2.1
      • setBindingTimestamp

        void setBindingTimestamp​(int agentId,
                                 @NotNull
                                 Date timestamp)
        Updates agent server last binding timestamp
        Parameters:
        agentId - agent id
        timestamp - timestamp
      • getBindingTimestamp

        @Nullable
        Date getBindingTimestamp​(int agentId)
        Returns last binding timestamp
        Parameters:
        agentId - agent id
        Returns:
        see above
      • getAgentStatusToRestore

        @Nullable
        Boolean getAgentStatusToRestore​(int agentId)
        Returns null if agent status will not be restored, otherwise returns status to restore
        Parameters:
        agentId - agent id
        Returns:
        null if agent status will not be restored, otherwise returns status to restore
      • getAgentStatusRestoringTimestamp

        @Nullable
        Long getAgentStatusRestoringTimestamp​(int agentId)
        Returns null if agent status will not be restored, otherwise returns status restoring timestamp
        Parameters:
        agentId - agent id
        Returns:
        null if agent status will not be restored, otherwise returns status restoring timestamp
      • invalidateCaches

        void invalidateCaches​(@NotNull
                              BuildAgentEx agent)
        Clear all caches that may affect the agent