OpenTSDB / opentsdb

A scalable, distributed Time Series Database.
http://opentsdb.net
GNU Lesser General Public License v2.1
5k stars 1.25k forks source link

Refactor GraphHandler.java and QueryRpc.java to share query logic #775

Open HugoMFernandes opened 8 years ago

HugoMFernandes commented 8 years ago

Right now, GraphHandler.doGraph (https://github.com/OpenTSDB/opentsdb/blob/08acb7374983f6b93848afb864facfbf75514247/src/tsd/GraphHandler.java#L126) implements its own query-processing logic which, among other things, fetches all series synchronously (see the TODO in https://github.com/OpenTSDB/opentsdb/blob/08acb7374983f6b93848afb864facfbf75514247/src/tsd/GraphHandler.java#L193).

QueryRpc.handleQuery has similar logic, but actually does things asynchronously (https://github.com/OpenTSDB/opentsdb/blob/08acb7374983f6b93848afb864facfbf75514247/src/tsd/QueryRpc.java#L112).

Because of this (code path) difference, adding query-related features requires implementing the logic in both places (which has led to bugs).

I propose rewriting this block of code (i.e. the query-related logic contained in QueryRpc) to process queries/annotations/etc and return data, moving it away from handleQuery. The responsibility of QueryRpc.handleQuery would then simply be to attach a formatter to the data, while the responsibility of GraphHandler.doGraph would be to turn the data into a graph (via gnuplot).

johann8384 commented 8 years ago

Changed to bug at the request of the @HugoMFernandes

HugoMFernandes commented 8 years ago

This one was fine as enhancement. My bug comment was related to the other one (#773). Anyways, it doesn't really matter.