Class AgentContext
- java.lang.Object
-
- com.atlassian.bamboo.agent.bootstrap.AgentContext
-
- All Implemented Interfaces:
Serializable
public class AgentContext extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringAGENT_FOR_KEY_PARAMstatic StringAGENT_ID_PARAMstatic StringAPPROVAL_REQUIRED_HEADERstatic intBOOTSTRAP_UPDATE_REQUIRED_EXIT_CODEstatic StringBOOTSTRAP_VERSIONstatic StringDISABLE_BOOTSTRAP_UPDATEstatic StringINSTANCE_FINGERPRINT_PARAMstatic StringSECURITY_TOKEN_PARAMstatic StringSERVER_AUTH_POLL_INTERVALServer poll interval for authentication, in seconds.static StringSERVER_FINGERPRINT_PARAMstatic StringUUID_PARAMstatic StringVERSION_PARAM
-
Constructor Summary
Constructors Constructor Description AgentContext(RemoteAgentHttpClientFactory httpClientFactory, @NotNull URL baseUrl, String fingerPrintRequestSuffix, AgentType agentBootstrapType, @Nullable String securityToken)AgentContext(RemoteAgentHttpClientFactory httpClientFactory, @NotNull URL baseUrl, String fingerPrintRequestSuffix, AgentType agentBootstrapType, @Nullable String securityToken, @Nullable String forKey)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static StringaddParameter(String url, String name, String value)protected StringcreateFingerprintUrl(String hostName)StringgetAbsoluteUrl(String relativeUrl)StringgetAbsoluteURL(String relativeUrl)Deprecated.since 6.1, provided for compatibility with old code onlyAgentTypegetAgentBootstrapType()@NotNull UUIDgetAgentUuid()Unique ID for authenticating the agent.URLgetBaseUrl()org.apache.http.client.HttpClientgetHttpClient()longgetInstanceFingerprint()A has identifying last restart of Bamboo server.StringgetServerFingerprint()A hash identifying Bamboo server.Map<String,String>getUserProperties()voidheartAttack()Set agent in "heart attack" state.booleanisHeartAttack()Checks if this remote agent is in "heart attack" currently.booleanisUnhealthy()Checks if this remote agent was "heart attack" state at any point in time.voidnormalSinusRhythm()Clear the 'heart attack' state.protected voidrun()static voidsystemExit(@Nullable String reason, @Nullable Throwable throwable)Shutdown theAgentContext, as a unrecoverable error has occurred.
-
-
-
Field Detail
-
SERVER_AUTH_POLL_INTERVAL
public static final String SERVER_AUTH_POLL_INTERVAL
Server poll interval for authentication, in seconds.- See Also:
- Constant Field Values
-
SERVER_FINGERPRINT_PARAM
public static final String SERVER_FINGERPRINT_PARAM
- See Also:
- Constant Field Values
-
INSTANCE_FINGERPRINT_PARAM
public static final String INSTANCE_FINGERPRINT_PARAM
- See Also:
- Constant Field Values
-
VERSION_PARAM
public static final String VERSION_PARAM
- See Also:
- Constant Field Values
-
UUID_PARAM
public static final String UUID_PARAM
- See Also:
- Constant Field Values
-
AGENT_ID_PARAM
public static final String AGENT_ID_PARAM
- See Also:
- Constant Field Values
-
AGENT_FOR_KEY_PARAM
public static final String AGENT_FOR_KEY_PARAM
- See Also:
- Constant Field Values
-
SECURITY_TOKEN_PARAM
public static final String SECURITY_TOKEN_PARAM
- See Also:
- Constant Field Values
-
DISABLE_BOOTSTRAP_UPDATE
public static final String DISABLE_BOOTSTRAP_UPDATE
- See Also:
- Constant Field Values
-
APPROVAL_REQUIRED_HEADER
public static final String APPROVAL_REQUIRED_HEADER
- See Also:
- Constant Field Values
-
BOOTSTRAP_VERSION
public static final String BOOTSTRAP_VERSION
- See Also:
- Constant Field Values
-
BOOTSTRAP_UPDATE_REQUIRED_EXIT_CODE
public static final int BOOTSTRAP_UPDATE_REQUIRED_EXIT_CODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AgentContext
public AgentContext(RemoteAgentHttpClientFactory httpClientFactory, @NotNull @NotNull URL baseUrl, String fingerPrintRequestSuffix, AgentType agentBootstrapType, @Nullable @Nullable String securityToken) throws MalformedURLException
- Throws:
MalformedURLException
-
AgentContext
public AgentContext(RemoteAgentHttpClientFactory httpClientFactory, @NotNull @NotNull URL baseUrl, String fingerPrintRequestSuffix, AgentType agentBootstrapType, @Nullable @Nullable String securityToken, @Nullable @Nullable String forKey) throws MalformedURLException
- Throws:
MalformedURLException
-
-
Method Detail
-
run
protected void run() throws IOException- Throws:
IOException
-
getServerFingerprint
public String getServerFingerprint()
A hash identifying Bamboo server. If it matches, agent can send messages to server.
-
getInstanceFingerprint
public long getInstanceFingerprint()
A has identifying last restart of Bamboo server. Used to determine if bamboo agent should restart itself.
-
getBaseUrl
public URL getBaseUrl()
- Returns:
- base url for bootstrap
- Since:
- 3.3
-
getAbsoluteURL
@Deprecated public String getAbsoluteURL(String relativeUrl)
Deprecated.since 6.1, provided for compatibility with old code only
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
-
getAgentBootstrapType
public AgentType getAgentBootstrapType()
- Returns:
- type of agent bootstrap
- Since:
- 3.3
-
getAgentUuid
@NotNull public @NotNull UUID getAgentUuid()
Unique ID for authenticating the agent.- Returns:
- unique agent ID
-
systemExit
public static void systemExit(@Nullable @Nullable String reason, @Nullable @Nullable Throwable throwable)Shutdown the
AgentContext, as a unrecoverable error has occurred.- Parameters:
reason- for systemExitthrowable- TheThrowablethat caused the systemExit.
-
isUnhealthy
public boolean isUnhealthy()
Checks if this remote agent was "heart attack" state at any point in time. "Heart attack" state means that heartbeat timeout has been exceeded, but the agent is still running with limited functionality in order to give itself a chance of finishing current build/deployment and returning its result should the communication be re-established. Agent that went through "heart attack" state will attempt to restart itself at the nearest opportunity.
-
isHeartAttack
public boolean isHeartAttack()
Checks if this remote agent is in "heart attack" currently. "Heart attack" state means that heartbeat timeout has been exceeded, but the agent is still running with limited functionality in order to give itself a chance of finishing current build/deployment and returning its result should the communication be re-established.
-
heartAttack
public void heartAttack()
Set agent in "heart attack" state.
-
normalSinusRhythm
public void normalSinusRhythm()
Clear the 'heart attack' state. This does not mean agent is considered healthy, it just means it's not dying right now. If unhealthy, it will be restarted at the nearest opportunity.
-
-