Class AgentPersistenceFacade
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.AgentPersistenceFacade
-
- All Implemented Interfaces:
AgentPersister
,UnregisteredAgentsManager
public class AgentPersistenceFacade extends Object implements UnregisteredAgentsManager, AgentPersister
- Author:
- Pavel.Sher Date: 10.01.2007
-
-
Constructor Summary
Constructors Constructor Description AgentPersistenceFacade(EventDispatcher<BuildServerListener> dispatcher, NumericIdSequences idSequences, BuildServerState serverState, ExtensionsProvider extensions, SQLRunnerEx sql)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
authorizationTokenIsValid(String authorizationToken)
void
generateUniqueAuthorizationToken(BuildAgentEx agent)
Generates new unique token which should be used to authorize this agentLong
getAgentStatusRestoringTimestamp(int agentId)
Returns null if agent status will not be restored, otherwise returns status restoring timestampBoolean
getAgentStatusToRestore(int agentId)
Returns null if agent status will not be restored, otherwise returns status to restoreDate
getBindingTimestamp(int agentId)
Returns last binding timestampList<AgentData>
getUnregisteredAgents(boolean includeUnauthorized)
List<AgentData>
getUnregisteredAgents(Collection<Integer> agentTypeIds, boolean includeUnauthorized)
void
invalidateCaches(BuildAgentEx agent)
Clear all caches that may affect the agentAgentData
loadAgent(int agentId, boolean includeUnregistered)
Load agent data from databaseAgentData
loadAgent(String agentName, boolean includeUnregistered)
List<AgentData>
loadRegisteredAgents()
Load all registered agents from database.void
register(BuildAgentEx agent)
Marks agent as registered in database.void
removeAgent(BuildAgentEx agent)
Removes agent from the database.void
resetAgentCaches(int agentId)
Should be called to cleanup internal caches when server detected that agent was removedvoid
restoreAgentsEnabledStatusesIfNeeded(Function<Integer,BuildAgentEx> agentSupplier)
Restores agents statuses if neededboolean
restoreAgentStatus(BuildAgentEx agent)
Returns true if agent exists in database and its' status has been restored.void
setAgentTypeId(BuildAgentEx agent, int agentTypeId)
Persists agent type idvoid
setAuthorized(BuildAgentEx agent, boolean authorized)
Persists this agent authorized status in database.void
setBindingTimestamp(int agentId, Date timestamp)
Updates agent server last binding timestampvoid
setEnabled(BuildAgentEx agent, boolean enabled)
Persists this agent status enabled status in database.void
setEnabled(BuildAgentEx agent, boolean enabled, long statusRestoringTimestamp)
Persists this agent status enabled status in database.void
setTimeService(TimeService timeService)
void
unregister(BuildAgentEx agent, String unregisterReason)
Marks agent as unregistered in database.void
updateAgentAuthorizationToken(BuildAgentEx agent)
-
-
-
Constructor Detail
-
AgentPersistenceFacade
public AgentPersistenceFacade(@NotNull EventDispatcher<BuildServerListener> dispatcher, @NotNull NumericIdSequences idSequences, @NotNull BuildServerState serverState, @NotNull ExtensionsProvider extensions, @NotNull SQLRunnerEx sql)
-
-
Method Detail
-
setTimeService
public void setTimeService(@NotNull TimeService timeService)
-
loadRegisteredAgents
@NotNull public List<AgentData> loadRegisteredAgents()
Description copied from interface:AgentPersister
Load all registered agents from database.- Specified by:
loadRegisteredAgents
in interfaceAgentPersister
-
loadAgent
@Nullable public AgentData loadAgent(int agentId, boolean includeUnregistered)
Description copied from interface:AgentPersister
Load agent data from database- Specified by:
loadAgent
in interfaceAgentPersister
-
loadAgent
@Nullable public AgentData loadAgent(String agentName, boolean includeUnregistered)
- Specified by:
loadAgent
in interfaceAgentPersister
-
setEnabled
public void setEnabled(@NotNull BuildAgentEx agent, boolean enabled)
Description copied from interface:AgentPersister
Persists this agent status enabled status in database.- Specified by:
setEnabled
in interfaceAgentPersister
- Parameters:
agent
- which status to persistenabled
- enabled value
-
setEnabled
public void setEnabled(@NotNull BuildAgentEx agent, boolean enabled, long statusRestoringTimestamp)
Description copied from interface:AgentPersister
Persists this agent status enabled status in database.- Specified by:
setEnabled
in interfaceAgentPersister
- Parameters:
agent
- which status to persistenabled
- enabled valuestatusRestoringTimestamp
- timestamp at which agent status will be restored
-
restoreAgentsEnabledStatusesIfNeeded
public void restoreAgentsEnabledStatusesIfNeeded(@NotNull Function<Integer,BuildAgentEx> agentSupplier)
Description copied from interface:AgentPersister
Restores agents statuses if needed- Specified by:
restoreAgentsEnabledStatusesIfNeeded
in interfaceAgentPersister
-
getAgentStatusToRestore
@Nullable public Boolean getAgentStatusToRestore(int agentId)
Description copied from interface:AgentPersister
Returns null if agent status will not be restored, otherwise returns status to restore- Specified by:
getAgentStatusToRestore
in interfaceAgentPersister
- Parameters:
agentId
- agent id- Returns:
- null if agent status will not be restored, otherwise returns status to restore
-
getAgentStatusRestoringTimestamp
@Nullable public Long getAgentStatusRestoringTimestamp(int agentId)
Description copied from interface:AgentPersister
Returns null if agent status will not be restored, otherwise returns status restoring timestamp- Specified by:
getAgentStatusRestoringTimestamp
in interfaceAgentPersister
- Parameters:
agentId
- agent id- Returns:
- null if agent status will not be restored, otherwise returns status restoring timestamp
-
invalidateCaches
public void invalidateCaches(@NotNull BuildAgentEx agent)
Description copied from interface:AgentPersister
Clear all caches that may affect the agent- Specified by:
invalidateCaches
in interfaceAgentPersister
-
setAuthorized
public void setAuthorized(@NotNull BuildAgentEx agent, boolean authorized)
Description copied from interface:AgentPersister
Persists this agent authorized status in database.- Specified by:
setAuthorized
in interfaceAgentPersister
- Parameters:
agent
- which status to persistauthorized
- authorized value
-
setAgentTypeId
public void setAgentTypeId(@NotNull BuildAgentEx agent, int agentTypeId)
Description copied from interface:AgentPersister
Persists agent type id- Specified by:
setAgentTypeId
in interfaceAgentPersister
- Parameters:
agent
- agentagentTypeId
- agent type id
-
restoreAgentStatus
public boolean restoreAgentStatus(@NotNull BuildAgentEx agent)
Description copied from interface:AgentPersister
Returns true if agent exists in database and its' status has been restored.- Specified by:
restoreAgentStatus
in interfaceAgentPersister
- Parameters:
agent
- agent to restore- Returns:
- true if agent exists in database and its' status has been restored and false otherwise
-
updateAgentAuthorizationToken
public void updateAgentAuthorizationToken(@NotNull BuildAgentEx agent)
-
authorizationTokenIsValid
public static boolean authorizationTokenIsValid(String authorizationToken)
-
register
public void register(@NotNull BuildAgentEx agent)
Description copied from interface:AgentPersister
Marks agent as registered in database.- Specified by:
register
in interfaceAgentPersister
- Parameters:
agent
- agent to update
-
unregister
public void unregister(@NotNull BuildAgentEx agent, @NotNull String unregisterReason)
Description copied from interface:AgentPersister
Marks agent as unregistered in database.- Specified by:
unregister
in interfaceAgentPersister
- Parameters:
agent
- agent to updateunregisterReason
- reason of unregistering
-
generateUniqueAuthorizationToken
public void generateUniqueAuthorizationToken(BuildAgentEx agent)
Description copied from interface:AgentPersister
Generates new unique token which should be used to authorize this agent- Specified by:
generateUniqueAuthorizationToken
in interfaceAgentPersister
- Parameters:
agent
- agent
-
removeAgent
public void removeAgent(@NotNull BuildAgentEx agent)
Description copied from interface:AgentPersister
Removes agent from the database.- Specified by:
removeAgent
in interfaceAgentPersister
- Parameters:
agent
- agent to remove
-
resetAgentCaches
public void resetAgentCaches(int agentId)
Description copied from interface:AgentPersister
Should be called to cleanup internal caches when server detected that agent was removed- Specified by:
resetAgentCaches
in interfaceAgentPersister
-
setBindingTimestamp
public void setBindingTimestamp(int agentId, @NotNull Date timestamp)
Description copied from interface:AgentPersister
Updates agent server last binding timestamp- Specified by:
setBindingTimestamp
in interfaceAgentPersister
- Parameters:
agentId
- agent idtimestamp
- timestamp
-
getBindingTimestamp
public Date getBindingTimestamp(int agentId)
Description copied from interface:AgentPersister
Returns last binding timestamp- Specified by:
getBindingTimestamp
in interfaceAgentPersister
- Parameters:
agentId
- agent id- Returns:
- see above
-
getUnregisteredAgents
@NotNull public List<AgentData> getUnregisteredAgents(boolean includeUnauthorized)
- Specified by:
getUnregisteredAgents
in interfaceUnregisteredAgentsManager
-
getUnregisteredAgents
@NotNull public List<AgentData> getUnregisteredAgents(@NotNull Collection<Integer> agentTypeIds, boolean includeUnauthorized)
- Specified by:
getUnregisteredAgents
in interfaceUnregisteredAgentsManager
-
-