Agent registration
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 and the 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.
Before any Agent can send measurements, they have to register different parts of their system. The order of the registration is important, too, otherwise there will be errors:
- Registration of the Platform: Every Agent receives a unique id from the CMR so all measurements can be associated to this Agent. Different information is needed to create that id:
- Network Interfaces: A list of the network interfaces on the target computer has to be collected. As this is not sufficient because of several Agents on the same computer with different JVM's the following information is needed, too.
- Agent Name: A self-defined Agent name, provided in a configuration file for example, has to be specified, too
- Registration of Sensor Types: As new sensor types can be plugged in easily into the Agent system, they have to be registered so that the CMR knows which sensor types are active on that specific Agent. There are two different sensor types available: Method and Platform sensor types. Method sensor types are collecting data from instrumented methods, thus their measurement/data container needs additional information of which method this container belongs to. Platform sensor types on the other hand collect data (automatically or requested by the user) of the target system or the target virtual machine. Both sensor types are registered by the CMR by passing the Platform id and the fully qualified class name. A successful register process will return a unique ID for this sensor type.
- Registration of Methods: Every instrumented method needs to be registered in the CMR. A successful register process will return a unique ID for this sensor type.
Every sensor on the Agent can then use these IDs for their measurements.