MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / QueryStats

Method QueryStats

src/stats/QueryStats.java:238–277  ·  view source on GitHub ↗

Default CTor @param remote_address Remote address of the client @param query Query being executed @param headers The HTTP headers passed with the query @throws QueryException if the exact query is already running, e.g if the client submitted the same query twice

(final String remote_address, final TSQuery query, 
      final Map<String, String> headers)

Source from the content-addressed store, hash-verified

236 * client submitted the same query twice
237 */
238 public QueryStats(final String remote_address, final TSQuery query,
239 final Map<String, String> headers) {
240 if (remote_address == null || remote_address.isEmpty()) {
241 throw new IllegalArgumentException("Remote address was null or empty");
242 }
243 if (query == null) {
244 throw new IllegalArgumentException("Query object was null");
245 }
246 this.remote_address = remote_address;
247 this.query = query;
248 this.headers = headers; // can be null
249 executed = 1;
250 query_start_ns = DateTime.nanoTime();
251 query_start_ms = DateTime.currentTimeMillis();
252 overall_stats = new ConcurrentHashMap<QueryStat, Long>();
253 query_stats = new ConcurrentHashMap<Integer, Map<QueryStat, Long>>(1);
254 scanner_stats = new ConcurrentHashMap<Integer,
255 Map<Integer, Map<QueryStat, Long>>>(1);
256 scanner_servers = new ConcurrentHashMap<Integer, Map<Integer, Set<String>>>(1);
257 scanner_ids = new ConcurrentHashMap<Integer, Map<Integer, String>>(1);
258 if (LOG.isDebugEnabled()) {
259 LOG.debug("New query for remote " + remote_address + " with hash " +
260 hashCode() + " on thread " + Thread.currentThread().getId());
261 }
262 if (running_queries.putIfAbsent(this.hashCode(), this) != null) {
263 if (ENABLE_DUPLICATES) {
264 LOG.warn("Query " + query + " is already executing for endpoint: " +
265 remote_address);
266 } else {
267 throw new QueryException("Query is already executing for endpoint: " +
268 remote_address);
269 }
270 }
271 if (LOG.isDebugEnabled()) {
272 LOG.debug("Successfully put new query for remote " + remote_address +
273 " with hash " + hashCode() + " on thread " +
274 Thread.currentThread().getId() + " w q " + query.toString());
275 }
276 LOG.info("Executing new query=" + JSON.serializeToString(this));
277 }
278
279 /**
280 * Returns the hash based on the remote address and the query

Callers

nothing calls this directly

Calls 7

nanoTimeMethod · 0.95
currentTimeMillisMethod · 0.95
hashCodeMethod · 0.95
serializeToStringMethod · 0.95
isEmptyMethod · 0.80
getIdMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected