This document describes the agent registration process.
Requirements
The requirement is to decouple the agent registration process of methods/sensor types etc. for a faster startup. Additionally, with such a system in place it is possible that the Agent is started without the CMR being running. The Agent tries to connect to the CMR in a specific interval and will execute all pending registrations.
Detailed concept
Instead of calling registration methods directly on the CMR if an instrumentation requests an ID, it is delayed and processed in a separate thread. The HookInstrumenter class receives an ID created locally in the Agent. The new IDManager class generates the IDs and tries to register these in the CMR.
As mentioned before, the registration is done in a separate thread which will be notified every time a new ID is stored (if the registration thread is currently not running).
In the case that an instrumented method is executed and requests the ID from the ID Manager andthe server is available, the method to retrieve the ID is blocked until the registration process is finished so that the ID can be returned. This is important to ensure that no measurements are lost only because the registration takes too long.
If the CMR is currently not available, an exception is thrown to indicate that there is a problem and the measurements are thrown away by the sensors (it doesn't makes sense to store them temporarily as the Agent cannot know when the CMR will be up again). In this case the registration process is executed every 10 seconds until the server is available and all IDs are registered.