Package com.dynatrace.openkit.core
Class BeaconSender
- java.lang.Object
-
- com.dynatrace.openkit.core.BeaconSender
-
public class BeaconSender extends java.lang.ObjectThe BeaconSender is responsible for asynchronously sending the Beacons to the provided endpoint.The
BeaconSendermanages the thread running OpenKit communication in the background.
-
-
Constructor Summary
Constructors Constructor Description BeaconSender(Logger logger, HTTPClientConfiguration httpClientConfiguration, HTTPClientProvider clientProvider, TimingProvider timingProvider)Create a new BeaconSender.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSession(SessionImpl session)Adds the given session to the known sessions of thisBeaconSender.intgetCurrentServerId()Returns the current server ID to be used for creating new sessionsServerConfigurationgetLastServerConfiguration()Returns the last known server configuration.voidinitialize()Start beacon sender thread.booleanisInitialized()Get a boolean indicating whether OpenKit has been initialized or not.voidshutdown()Shutdown the BeaconSender and wait until it's shutdown (at mostSHUTDOWN_TIMEOUTmilliseconds.booleanwaitForInit()Wait until OpenKit is fully initialized or a shutdown request has been made.booleanwaitForInit(long timeoutMillis)Wait until OpenKit is fully initialized or a shutdown request has been made or given timeout expired.
-
-
-
Constructor Detail
-
BeaconSender
public BeaconSender(Logger logger, HTTPClientConfiguration httpClientConfiguration, HTTPClientProvider clientProvider, TimingProvider timingProvider)
Create a new BeaconSender.To start the beacon sending the
initialize()method must be called.- Parameters:
logger- Logger for logging messageshttpClientConfiguration- Initial HTTP client configuration.clientProvider- Used for retrieving anHTTPClientinstance.timingProvider- Used for some timing related things.
-
-
Method Detail
-
initialize
public void initialize()
Start beacon sender thread.Note: The beacon sender has to perform some initialization code, which is done in the background, before it actually starts sending beacons. If it's necessary to have OpenKit fully initialized use the
waitForInit()method to wait until initialized.
-
waitForInit
public boolean waitForInit()
Wait until OpenKit is fully initialized or a shutdown request has been made.This method might hang forever.
- Returns:
trueif OpenKit is fully initialized, orfalseif shutdown has been requested during init phase.
-
waitForInit
public boolean waitForInit(long timeoutMillis)
Wait until OpenKit is fully initialized or a shutdown request has been made or given timeout expired.- Parameters:
timeoutMillis- The maximum number of milliseconds to wait for initialization being completed.- Returns:
trueif OpenKit is fully initialized, orfalseif shutdown has been requested during init phase.
-
isInitialized
public boolean isInitialized()
Get a boolean indicating whether OpenKit has been initialized or not.- Returns:
trueif OpenKit has been initialized,falseotherwise.
-
shutdown
public void shutdown()
Shutdown the BeaconSender and wait until it's shutdown (at mostSHUTDOWN_TIMEOUTmilliseconds.
-
getLastServerConfiguration
public ServerConfiguration getLastServerConfiguration()
Returns the last known server configuration.
-
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 known sessions of thisBeaconSender.This method should be called when creating a new session.
- Parameters:
session- the session to start.
-
-