Class RegisteredAgent
- java.lang.Object
-
- jetbrains.buildServer.serverSide.impl.Proxyfied<BuildAgentEx>
-
- jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgentContext
-
- jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgent
-
- jetbrains.buildServer.serverSide.impl.agent.RegisteredAgent
-
- All Implemented Interfaces:
Comparable<BuildAgent>
,BuildAgent
,Loggable
,AgentBuildHistory
,AgentDescription
,BuildAgentEx
,BuildAgentInit
,SBuildAgent
public class RegisteredAgent extends AbstractBuildAgent
-
-
Field Summary
-
Fields inherited from class jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgent
FAILED_TO_FIND_AGENT_TYPE_FOR_AGENT_MSG_PREFIX
-
Fields inherited from class jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgentContext
myContext
-
Fields inherited from interface jetbrains.buildServer.BuildAgent
DEFAULT_POOL_ID, DEFAULT_POOL_NAME
-
-
Constructor Summary
Constructors Constructor Description RegisteredAgent(AgentContext context, AgentDescription agentDescription, RemoteAgentConnection connection, String host, int port, String agentName, String agentAuthorizationToken, String agentPingCode, String agentVersion, String pluginsSignature, CurrentAgentVersionProvider currentAgentVersionProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearSpecialState(BuildAgentSpecialState specialState)
Clears special state if set to the given valueString
getCommunicationProtocolDescription()
Returns short description of the protocol that is used to communicate with this agent.String
getCommunicationProtocolType()
Returns type (identifier) of the protocol that is used to communicate with this agent.RemoteAgentConnection
getConnection()
int
getPort()
Port where agent is listening for server commands.Date
getRegistrationTimestamp()
Returns timestamp of this agent registration.<T> T
getRemoteInterface(Class<T> clazz)
Extension point allowing to call custom methods on agent remotely.BuildAgentSpecialState
getSpecialState()
Returns current special stateString
getUnregistrationComment()
If agent is not registered returns reason of its' unregistration.boolean
isAccessible()
Returns true if the agent is connected to the current node, otherwise returns false.void
isLocal(Action<Boolean> callback)
Calls callback with true if this agent is local for sure (i.e.Boolean
isLocalFast()
Returns the result ofBuildAgentEx.isLocal(Action)
if the operation is fast, null otherwiseboolean
isRegistered()
Returns true or false depending on whether this agent is currently registered on server or not.boolean
ping()
Try to ping agent over networksvoid
register()
Makes this agent registered.AgentBuildResult
runBuild(AgentBuild agentBuild)
Send runBuild command to the Agent.void
setId(int id)
protected void
setNameInternal(String name)
void
setTimeService(TimeService timeService)
boolean
stopBuild(SRunningBuild build)
Sends stop build command to agent.String
toString()
boolean
trySetSpecialState(BuildAgentSpecialState specialState)
Tries atomically to set a certain special state on agent.void
unregister(String unregistrationReason)
Makes this agent unregistered.boolean
upgrade(Action<Boolean> callback)
Sends upgrade command on agent-
Methods inherited from class jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgent
buildStartedOnAgent, canStartBuildIfAgentOutdated, compareTo, describe, generateUniqueAgentAuthorizationToken, getAgentPool, getAgentPoolId, getAgentStatusRestoringTimestamp, getAgentStatusToRestore, getAgentType, getAgentTypeId, getAuthorizationToken, getAuthorizeComment, getAvailableParameters, getAvailableParameterValue, getAvailableRunTypeIds, getAvailableRunTypes, getAvailableVcsPlugins, getBuildConfigurationsBuilt, getBuildHistory, getBuildParameters, getConfigurationParameters, getCpuBenchmarkIndex, getCpuCount, getCurrentAgentPluginsSignature, getCurrentAgentVersion, getDefinedParameters, getHostAddress, getHostName, getId, getIdleTime, getLastCommunicationTimestamp, getLastFinishedBuildDateOnAgent, getName, getOperatingSystemName, getParameterValue, getPingCode, getPluginsSignature, getRunningBuild, getStatusComment, getVersion, initAgentTypeId, initAuthorized, initEnabled, isAuthorized, isCaseInsensitiveEnvironment, isCloudAgent, isEnabled, isFakeAgent, isOutdated, isPluginsOutdated, isRemoved, isUpgrading, markAsRemoved, releaseSources, releaseSources, restoreAgent, setAgentTypeId, setAuthorizationToken, setAuthorized, setCommunicationTimestamp, setEnabled, setEnabled, setHostAddress, setHostAddress, setName, setPingCode, setPluginsSignature, setUpgrading, setVersion, setVersion, updateAgent, updateCommunicationTimestampInMemory
-
Methods inherited from class jetbrains.buildServer.serverSide.impl.agent.AbstractBuildAgentContext
getAgentDescription, setAgentDescription
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jetbrains.buildServer.serverSide.BuildAgentEx
setAgentDescription
-
-
-
-
Constructor Detail
-
RegisteredAgent
public RegisteredAgent(@NotNull AgentContext context, @NotNull AgentDescription agentDescription, @NotNull RemoteAgentConnection connection, @NotNull String host, int port, @NotNull String agentName, @NotNull String agentAuthorizationToken, @NotNull String agentPingCode, @NotNull String agentVersion, @NotNull String pluginsSignature, @NotNull CurrentAgentVersionProvider currentAgentVersionProvider)
-
-
Method Detail
-
setId
public void setId(int id)
- Specified by:
setId
in interfaceBuildAgentInit
- Overrides:
setId
in classAbstractBuildAgent
-
setNameInternal
protected void setNameInternal(@NotNull String name)
- Overrides:
setNameInternal
in classAbstractBuildAgent
-
isLocal
public void isLocal(Action<Boolean> callback)
Description copied from interface:BuildAgentEx
Calls callback with true if this agent is local for sure (i.e. installed on the same machine as server).- Specified by:
isLocal
in interfaceBuildAgentEx
- Overrides:
isLocal
in classAbstractBuildAgent
-
isLocalFast
@Nullable public Boolean isLocalFast()
Description copied from interface:BuildAgentEx
Returns the result ofBuildAgentEx.isLocal(Action)
if the operation is fast, null otherwise- Specified by:
isLocalFast
in interfaceBuildAgentEx
- Overrides:
isLocalFast
in classAbstractBuildAgent
-
runBuild
public AgentBuildResult runBuild(@NotNull AgentBuild agentBuild)
Description copied from interface:BuildAgentEx
Send runBuild command to the Agent.
-
stopBuild
public boolean stopBuild(@NotNull SRunningBuild build)
Description copied from interface:BuildAgentEx
Sends stop build command to agent.- Specified by:
stopBuild
in interfaceBuildAgentEx
- Overrides:
stopBuild
in classAbstractBuildAgent
- Returns:
- true if build was stopped on agent and false otherwise
-
upgrade
public boolean upgrade(Action<Boolean> callback)
Description copied from interface:BuildAgentEx
Sends upgrade command on agent- Parameters:
callback
- will be called with true if upgrade was accepted by agent.- Returns:
- true if upgrade is scheduled, false otherwise (for example if previous Upgrade call is still in progress).
-
ping
public boolean ping()
Description copied from interface:SBuildAgent
Try to ping agent over networks- Returns:
- true if agent is reachable
-
getRemoteInterface
public <T> T getRemoteInterface(@NotNull Class<T> clazz)
Description copied from interface:BuildAgentEx
Extension point allowing to call custom methods on agent remotely.- Specified by:
getRemoteInterface
in interfaceBuildAgentEx
- Overrides:
getRemoteInterface
in classAbstractBuildAgent
- Parameters:
clazz
- should contain only simple methods - with simple parameters and return types (number and strings)
-
getCommunicationProtocolDescription
@NotNull public String getCommunicationProtocolDescription()
Description copied from interface:SBuildAgent
Returns short description of the protocol that is used to communicate with this agent.
Examples: "unidirectional", "local".- Specified by:
getCommunicationProtocolDescription
in interfaceSBuildAgent
- Overrides:
getCommunicationProtocolDescription
in classAbstractBuildAgent
-
getCommunicationProtocolType
@NotNull public String getCommunicationProtocolType()
Description copied from interface:SBuildAgent
Returns type (identifier) of the protocol that is used to communicate with this agent. Opposite toSBuildAgent.getCommunicationProtocolDescription()
this type is constant and will not change for the particular protocol in future.- Specified by:
getCommunicationProtocolType
in interfaceSBuildAgent
- Overrides:
getCommunicationProtocolType
in classAbstractBuildAgent
-
getRegistrationTimestamp
@NotNull public Date getRegistrationTimestamp()
Description copied from interface:SBuildAgent
Returns timestamp of this agent registration. If agent is not registered the returned timestamp is timestamp of last agent registration.- Returns:
- see above
-
register
public void register()
Description copied from interface:BuildAgentEx
Makes this agent registered.- Specified by:
register
in interfaceBuildAgentEx
- Overrides:
register
in classAbstractBuildAgent
-
unregister
public void unregister(@NotNull String unregistrationReason)
Description copied from interface:BuildAgentEx
Makes this agent unregistered.- Specified by:
unregister
in interfaceBuildAgentEx
- Overrides:
unregister
in classAbstractBuildAgent
- Parameters:
unregistrationReason
- reason of the agent unregistration
-
isRegistered
public boolean isRegistered()
Description copied from interface:SBuildAgent
Returns true or false depending on whether this agent is currently registered on server or not.- Returns:
- see above
-
getUnregistrationComment
public String getUnregistrationComment()
Description copied from interface:SBuildAgent
If agent is not registered returns reason of its' unregistration.- Returns:
- agent is not registered returns reason of its' unregistration.
-
getPort
public int getPort()
Description copied from interface:SBuildAgent
Port where agent is listening for server commands.- Returns:
- see above
-
toString
public String toString()
- Overrides:
toString
in classAbstractBuildAgent
-
getConnection
@NotNull public RemoteAgentConnection getConnection()
-
trySetSpecialState
public boolean trySetSpecialState(BuildAgentSpecialState specialState)
Description copied from interface:BuildAgentEx
Tries atomically to set a certain special state on agent. This operation is thread-safe- Returns:
- boolean if successful, false otherwise
-
clearSpecialState
public void clearSpecialState(BuildAgentSpecialState specialState)
Description copied from interface:BuildAgentEx
Clears special state if set to the given value- Specified by:
clearSpecialState
in interfaceBuildAgentEx
- Overrides:
clearSpecialState
in classAbstractBuildAgent
-
getSpecialState
public BuildAgentSpecialState getSpecialState()
Description copied from interface:BuildAgentEx
Returns current special state- Specified by:
getSpecialState
in interfaceBuildAgentEx
- Overrides:
getSpecialState
in classAbstractBuildAgent
- Returns:
- see above
-
isAccessible
public boolean isAccessible()
Description copied from interface:BuildAgentEx
Returns true if the agent is connected to the current node, otherwise returns false. For example on the read-only node always return false. The remote operations can be executed on the agent only if the method returns true.
-
setTimeService
public void setTimeService(TimeService timeService)
-
-