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 String
AGENT_FOR_KEY_PARAM
static String
AGENT_ID_PARAM
static String
APPROVAL_REQUIRED_HEADER
static int
BOOTSTRAP_UPDATE_REQUIRED_EXIT_CODE
static String
BOOTSTRAP_VERSION
static String
DISABLE_BOOTSTRAP_UPDATE
static String
INSTANCE_FINGERPRINT_PARAM
static String
SECURITY_TOKEN_PARAM
static String
SERVER_AUTH_POLL_INTERVAL
Server poll interval for authentication, in seconds.static String
SERVER_FINGERPRINT_PARAM
static String
UUID_PARAM
static String
VERSION_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 String
addParameter(String url, String name, String value)
protected String
createFingerprintUrl(String hostName)
String
getAbsoluteUrl(String relativeUrl)
String
getAbsoluteURL(String relativeUrl)
Deprecated.since 6.1, provided for compatibility with old code onlyAgentType
getAgentBootstrapType()
@NotNull UUID
getAgentUuid()
Unique ID for authenticating the agent.URL
getBaseUrl()
org.apache.http.client.HttpClient
getHttpClient()
long
getInstanceFingerprint()
A has identifying last restart of Bamboo server.String
getServerFingerprint()
A hash identifying Bamboo server.Map<String,String>
getUserProperties()
void
heartAttack()
Set agent in "heart attack" state.boolean
isHeartAttack()
Checks if this remote agent is in "heart attack" currently.boolean
isUnhealthy()
Checks if this remote agent was "heart attack" state at any point in time.void
normalSinusRhythm()
Clear the 'heart attack' state.protected void
run()
static void
systemExit(@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
- TheThrowable
that 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.
-
-