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 booleanauthorizationTokenIsValid(String authorizationToken)voidgenerateUniqueAuthorizationToken(BuildAgentEx agent)Generates new unique token which should be used to authorize this agentLonggetAgentStatusRestoringTimestamp(int agentId)Returns null if agent status will not be restored, otherwise returns status restoring timestampBooleangetAgentStatusToRestore(int agentId)Returns null if agent status will not be restored, otherwise returns status to restoreDategetBindingTimestamp(int agentId)Returns last binding timestampList<AgentData>getUnregisteredAgents(boolean includeUnauthorized)List<AgentData>getUnregisteredAgents(Collection<Integer> agentTypeIds, boolean includeUnauthorized)voidinvalidateCaches(BuildAgentEx agent)Clear all caches that may affect the agentAgentDataloadAgent(int agentId, boolean includeUnregistered)Load agent data from databaseAgentDataloadAgent(String agentName, boolean includeUnregistered)List<AgentData>loadRegisteredAgents()Load all registered agents from database.voidregister(BuildAgentEx agent)Marks agent as registered in database.voidremoveAgent(BuildAgentEx agent)Removes agent from the database.voidresetAgentCaches(int agentId)Should be called to cleanup internal caches when server detected that agent was removedvoidrestoreAgentsEnabledStatusesIfNeeded(Function<Integer,BuildAgentEx> agentSupplier)Restores agents statuses if neededbooleanrestoreAgentStatus(BuildAgentEx agent)Returns true if agent exists in database and its' status has been restored.voidsetAgentTypeId(BuildAgentEx agent, int agentTypeId)Persists agent type idvoidsetAuthorized(BuildAgentEx agent, boolean authorized)Persists this agent authorized status in database.voidsetBindingTimestamp(int agentId, Date timestamp)Updates agent server last binding timestampvoidsetEnabled(BuildAgentEx agent, boolean enabled)Persists this agent status enabled status in database.voidsetEnabled(BuildAgentEx agent, boolean enabled, long statusRestoringTimestamp)Persists this agent status enabled status in database.voidsetTimeService(TimeService timeService)voidunregister(BuildAgentEx agent, String unregisterReason)Marks agent as unregistered in database.voidupdateAgentAuthorizationToken(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:AgentPersisterLoad all registered agents from database.- Specified by:
loadRegisteredAgentsin interfaceAgentPersister
-
loadAgent
@Nullable public AgentData loadAgent(int agentId, boolean includeUnregistered)
Description copied from interface:AgentPersisterLoad agent data from database- Specified by:
loadAgentin interfaceAgentPersister
-
loadAgent
@Nullable public AgentData loadAgent(String agentName, boolean includeUnregistered)
- Specified by:
loadAgentin interfaceAgentPersister
-
setEnabled
public void setEnabled(@NotNull BuildAgentEx agent, boolean enabled)Description copied from interface:AgentPersisterPersists this agent status enabled status in database.- Specified by:
setEnabledin interfaceAgentPersister- Parameters:
agent- which status to persistenabled- enabled value
-
setEnabled
public void setEnabled(@NotNull BuildAgentEx agent, boolean enabled, long statusRestoringTimestamp)Description copied from interface:AgentPersisterPersists this agent status enabled status in database.- Specified by:
setEnabledin 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:AgentPersisterRestores agents statuses if needed- Specified by:
restoreAgentsEnabledStatusesIfNeededin interfaceAgentPersister
-
getAgentStatusToRestore
@Nullable public Boolean getAgentStatusToRestore(int agentId)
Description copied from interface:AgentPersisterReturns null if agent status will not be restored, otherwise returns status to restore- Specified by:
getAgentStatusToRestorein 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:AgentPersisterReturns null if agent status will not be restored, otherwise returns status restoring timestamp- Specified by:
getAgentStatusRestoringTimestampin 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:AgentPersisterClear all caches that may affect the agent- Specified by:
invalidateCachesin interfaceAgentPersister
-
setAuthorized
public void setAuthorized(@NotNull BuildAgentEx agent, boolean authorized)Description copied from interface:AgentPersisterPersists this agent authorized status in database.- Specified by:
setAuthorizedin interfaceAgentPersister- Parameters:
agent- which status to persistauthorized- authorized value
-
setAgentTypeId
public void setAgentTypeId(@NotNull BuildAgentEx agent, int agentTypeId)Description copied from interface:AgentPersisterPersists agent type id- Specified by:
setAgentTypeIdin interfaceAgentPersister- Parameters:
agent- agentagentTypeId- agent type id
-
restoreAgentStatus
public boolean restoreAgentStatus(@NotNull BuildAgentEx agent)Description copied from interface:AgentPersisterReturns true if agent exists in database and its' status has been restored.- Specified by:
restoreAgentStatusin 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:AgentPersisterMarks agent as registered in database.- Specified by:
registerin interfaceAgentPersister- Parameters:
agent- agent to update
-
unregister
public void unregister(@NotNull BuildAgentEx agent, @NotNull String unregisterReason)Description copied from interface:AgentPersisterMarks agent as unregistered in database.- Specified by:
unregisterin interfaceAgentPersister- Parameters:
agent- agent to updateunregisterReason- reason of unregistering
-
generateUniqueAuthorizationToken
public void generateUniqueAuthorizationToken(BuildAgentEx agent)
Description copied from interface:AgentPersisterGenerates new unique token which should be used to authorize this agent- Specified by:
generateUniqueAuthorizationTokenin interfaceAgentPersister- Parameters:
agent- agent
-
removeAgent
public void removeAgent(@NotNull BuildAgentEx agent)Description copied from interface:AgentPersisterRemoves agent from the database.- Specified by:
removeAgentin interfaceAgentPersister- Parameters:
agent- agent to remove
-
resetAgentCaches
public void resetAgentCaches(int agentId)
Description copied from interface:AgentPersisterShould be called to cleanup internal caches when server detected that agent was removed- Specified by:
resetAgentCachesin interfaceAgentPersister
-
setBindingTimestamp
public void setBindingTimestamp(int agentId, @NotNull Date timestamp)Description copied from interface:AgentPersisterUpdates agent server last binding timestamp- Specified by:
setBindingTimestampin interfaceAgentPersister- Parameters:
agentId- agent idtimestamp- timestamp
-
getBindingTimestamp
public Date getBindingTimestamp(int agentId)
Description copied from interface:AgentPersisterReturns last binding timestamp- Specified by:
getBindingTimestampin interfaceAgentPersister- Parameters:
agentId- agent id- Returns:
- see above
-
getUnregisteredAgents
@NotNull public List<AgentData> getUnregisteredAgents(boolean includeUnauthorized)
- Specified by:
getUnregisteredAgentsin interfaceUnregisteredAgentsManager
-
getUnregisteredAgents
@NotNull public List<AgentData> getUnregisteredAgents(@NotNull Collection<Integer> agentTypeIds, boolean includeUnauthorized)
- Specified by:
getUnregisteredAgentsin interfaceUnregisteredAgentsManager
-
-