Class BeaconSendingContext
- java.lang.Object
-
- com.dynatrace.openkit.core.communication.BeaconSendingContext
-
- All Implemented Interfaces:
AdditionalQueryParameters
public class BeaconSendingContext extends java.lang.Object implements AdditionalQueryParameters
State context for beacon sending states.All package-private methods in this class shall only be accessed from the beacon sending thread, since they are not thread safe. All public methods are thread safe, unless explicitly stated.
-
-
Constructor Summary
Constructors Constructor Description BeaconSendingContext(Logger logger, HTTPClientConfiguration httpClientConfiguration, HTTPClientProvider httpClientProvider, TimingProvider timingProvider)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSession(SessionImpl session)Adds the given session to the internal container of sessions.voidexecuteCurrentState()Executes the current state.longgetConfigurationTimestamp()Returns the current timestamp of the configuration received by the serverintgetCurrentServerId()Returns the current server ID to be used for creating new sessionsServerConfigurationgetLastServerConfiguration()Returns the last knownServerConfiguration.booleanisInitialized()Get a boolean indicating whether OpenKit is initialized or not.booleanisInTerminalState()Gets a boolean indicating whether the current state is a terminal state or not.booleanisShutdownRequested()Gets a boolean flag indicating whether shutdown was requested before or not.voidrequestShutdown()Requests a shutdown.booleanwaitForInit()Wait until OpenKit has been fully initialized.booleanwaitForInit(long timeoutMillis)Wait until OpenKit has been fully initialized or timeout expired.
-
-
-
Constructor Detail
-
BeaconSendingContext
public BeaconSendingContext(Logger logger, HTTPClientConfiguration httpClientConfiguration, HTTPClientProvider httpClientProvider, TimingProvider timingProvider)
Constructor.The state is initialized to
BeaconSendingInitState,
-
-
Method Detail
-
executeCurrentState
public void executeCurrentState()
Executes the current state.This method must only be called from the beacon sending thread, since it's not thread safe.
-
requestShutdown
public void requestShutdown()
Requests a shutdown.
-
isShutdownRequested
public boolean isShutdownRequested()
Gets a boolean flag indicating whether shutdown was requested before or not.
-
waitForInit
public boolean waitForInit()
Wait until OpenKit has been fully initialized.If initialization is interrupted (e.g.
requestShutdown()was called), then this method also returns.- Returns:
trueOpenKit is fully initialized,falseOpenKit init got interrupted.
-
waitForInit
public boolean waitForInit(long timeoutMillis)
Wait until OpenKit has been fully initialized or timeout expired.If initialization is interrupted (e.g.
requestShutdown()was called), then this method also returns.- Parameters:
timeoutMillis- The maximum number of milliseconds to wait for initialization being completed.- Returns:
trueif OpenKit is fully initialized,falseif OpenKit init got interrupted or time to wait expired.
-
isInitialized
public boolean isInitialized()
Get a boolean indicating whether OpenKit is initialized or not.- Returns:
trueif OpenKit is initialized,falseotherwise.
-
isInTerminalState
public boolean isInTerminalState()
Gets a boolean indicating whether the current state is a terminal state or not.This method must only be called from the beacon sending thread, since it's not thread safe.
- Returns:
trueif the current state is a terminal state,falseotherwise.
-
getLastServerConfiguration
public ServerConfiguration getLastServerConfiguration()
Returns the last knownServerConfiguration.
-
getCurrentServerId
public int getCurrentServerId()
Returns the current server ID to be used for creating new sessions
-
addSession
public void addSession(SessionImpl session)
Adds the given session to the internal container of sessions.- Parameters:
session- The new session to add.
-
getConfigurationTimestamp
public long getConfigurationTimestamp()
Description copied from interface:AdditionalQueryParametersReturns the current timestamp of the configuration received by the server- Specified by:
getConfigurationTimestampin interfaceAdditionalQueryParameters
-
-