rhq-project/rhq — pull request #51 by metlos (2014-06-11 13:15:55+00:00)
Title: [BZ 1035890] Make REST-originating measurements alertable

This required quite a bit of changes across the codebase to correctly
support. While the metric-push in the REST didn't need any changes,
there had to be quite a number of changes in the way resources are
created over REST.

The previous implementation was a bit naive in that it merely tried to
push stuff into database without invoking the usual agent-server
work-flows that made sure that everything was set up, including
alerting.

This commit does several things:

* It invokes the same workflow during resource creation over REST as
would have been using the normal agent-server communication.

* It formalizes the fact that the agents and resources created over
REST can be synthetic by introducing a DB column in the appropriate
tables. There are simple rules governing the synthetic resources:
a) a synthetic parent can only have synthetic children
b) the above rule applies even in cases where the resource is
otherwise creatable.
This has the following consequences: one can create ANY type of
resource (even content-backed - for which the content is merely ignored)
on an synthetic agent, but the resource is always synthetic. A "real"
resource can have synthetic children but not otherwise. Normally
creatable resources can still be created over REST under
"real" parents.

* HA servers periodically scan the synthetic agents and claim
ownership of them if the last owning server didn't check in in due
time. This is to support alerting that assumes that each agent is
owned by exactly one server at any given time.

* All places in the server.jar that reach out to agents to do some
work have been augmented to take the synthetic resources into
consideration somehow (usually just leaving them out of the
"picture", because agents can't do anything about these resources).

* Agents aren't even aware of these synthetic resources because they are
not synced. It would not make sense for an agent to do anything about
a synthetic resource because such resource doesn't "physically" exist on
any agent. It is only backed by the data pushed through REST.