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

Method getLastWriteTimes

src/meta/TSUIDQuery.java:249–330  ·  view source on GitHub ↗

Fetches a list of TSUIDs given the metric and optional tag pairs. The query format is similar to TsdbQuery but doesn't support grouping operators for tags. Only TSUIDs that had "ts_counter" qualifiers will be returned. NOTE: If you called #setQuery(String, Map) successfully this will imm

()

Source from the content-addressed store, hash-verified

247 * was null
248 */
249 public Deferred<ByteMap<Long>> getLastWriteTimes() {
250 class ResolutionCB implements Callback<Deferred<ByteMap<Long>>, Object> {
251 @Override
252 public Deferred<ByteMap<Long>> call(Object arg0) throws Exception {
253 final Scanner scanner = getScanner();
254 scanner.setQualifier(TSMeta.COUNTER_QUALIFIER());
255 final Deferred<ByteMap<Long>> results = new Deferred<ByteMap<Long>>();
256 final ByteMap<Long> tsuids = new ByteMap<Long>();
257
258 final class ErrBack implements Callback<Object, Exception> {
259 @Override
260 public Object call(final Exception e) throws Exception {
261 results.callback(e);
262 return null;
263 }
264 @Override
265 public String toString() {
266 return "Error callback";
267 }
268 }
269
270 /**
271 * Scanner callback that will call itself while iterating through the
272 * tsdb-meta table
273 */
274 final class ScannerCB implements Callback<Object,
275 ArrayList<ArrayList<KeyValue>>> {
276
277 /**
278 * Starts the scanner and is called recursively to fetch the next set of
279 * rows from the scanner.
280 * @return The map of spans if loaded successfully, null if no data was
281 * found
282 */
283 public Object scan() {
284 return scanner.nextRows().addCallback(this).addErrback(new ErrBack());
285 }
286
287 /**
288 * Loops through each row of the scanner results and parses out data
289 * points and optional meta data
290 * @return null if no rows were found, otherwise the TreeMap with spans
291 */
292 @Override
293 public Object call(final ArrayList<ArrayList<KeyValue>> rows)
294 throws Exception {
295 try {
296 if (rows == null) {
297 results.callback(tsuids);
298 return null;
299 }
300
301 for (final ArrayList<KeyValue> row : rows) {
302 final byte[] tsuid = row.get(0).key();
303 tsuids.put(tsuid, row.get(0).timestamp());
304 }
305 return scan();
306 } catch (Exception e) {

Callers 1

Calls 2

resolveMetricMethod · 0.95
callMethod · 0.45

Tested by

no test coverage detected