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

Method execute

src/tsd/SearchRpc.java:56–98  ·  view source on GitHub ↗

Handles the /api/search/<type> endpoint @param tsdb The TSDB to which we belong @param query The HTTP query to work with

(TSDB tsdb, HttpQuery query)

Source from the content-addressed store, hash-verified

54 * @param query The HTTP query to work with
55 */
56 @Override
57 public void execute(TSDB tsdb, HttpQuery query) {
58
59 final HttpMethod method = query.getAPIMethod();
60 if (method != HttpMethod.GET && method != HttpMethod.POST) {
61 throw new BadRequestException("Unsupported method: " + method.getName());
62 }
63
64 // the uri will be /api/vX/search/<type> or /api/search/<type>
65 final String[] uri = query.explodeAPIPath();
66 final String endpoint = uri.length > 1 ? uri[1] : "";
67 final SearchType type;
68 final SearchQuery search_query;
69
70 try {
71 type = SearchQuery.parseSearchType(endpoint);
72 } catch (IllegalArgumentException e) {
73 throw new BadRequestException("Invalid search query type supplied", e);
74 }
75
76 if (query.hasContent()) {
77 search_query = query.serializer().parseSearchQueryV1();
78 } else {
79 search_query = parseQueryString(query, type);
80 }
81
82 search_query.setType(type);
83
84 if (type == SearchType.LOOKUP) {
85 processLookup(tsdb, query, search_query);
86 return;
87 }
88
89 try {
90 final SearchQuery results =
91 tsdb.executeSearch(search_query).joinUninterruptibly();
92 query.sendReply(query.serializer().formatSearchResultsV1(results));
93 } catch (IllegalStateException e) {
94 throw new BadRequestException("Searching is not enabled", e);
95 } catch (Exception e) {
96 throw new RuntimeException(e);
97 }
98 }
99
100 /**
101 * Parses required search values from the query string

Callers

nothing calls this directly

Calls 13

parseSearchTypeMethod · 0.95
parseQueryStringMethod · 0.95
setTypeMethod · 0.95
processLookupMethod · 0.95
getAPIMethodMethod · 0.80
serializerMethod · 0.80
executeSearchMethod · 0.80
sendReplyMethod · 0.80
getNameMethod · 0.65
explodeAPIPathMethod · 0.45
hasContentMethod · 0.45
parseSearchQueryV1Method · 0.45

Tested by

no test coverage detected