Examples of TSMeta


Examples of net.opentsdb.meta.TSMeta

                // and send it to the search plugin so we don't have to do that
                // here or in the local callback
                return TSMeta.incrementAndGetCounter(tsdb, tsuid)
                  .addCallbackDeferring(new CreatedCB());
              } else {
                TSMeta new_meta = new TSMeta(tsuid, timestamp);
                tsdb.indexTSMeta(new_meta);
                LOG.info("Counter exists but meta was null, creating meta data for timeseries [" +
                    tsuid_string + "]");
                return new_meta.storeNew(tsdb);   
              }
            }
          }
         
          // Take care of situations where the counter is created but the
          // meta data is not. May happen if the TSD crashes or is killed
          // improperly before the meta is flushed to storage.
          return TSMeta.counterExistsInStorage(tsdb, tsuid)
            .addCallbackDeferring(new CounterCB());
        }

        // verify the tsuid is good, it's possible for this to become
        // corrupted
        if (meta.getTSUID() == null ||
            meta.getTSUID().isEmpty()) {
          LOG.warn("Replacing corrupt meta data for timeseries [" +
              tsuid_string + "]");
          TSMeta new_meta = new TSMeta(tsuid, timestamp);
          tsdb.indexTSMeta(new_meta);
          return new_meta.storeNew(tsdb);
        } else {
          // we only want to update the time if it was outside of an
          // hour otherwise it's probably an accurate timestamp
          if (meta.getCreated() > (timestamp + 3600) ||
              meta.getCreated() == 0) {
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

                // and send it to the search plugin so we don't have to do that
                // here or in the local callback
                return TSMeta.incrementAndGetCounter(tsdb, tsuid)
                  .addCallbackDeferring(new CreatedCB());
              } else {
                TSMeta new_meta = new TSMeta(tsuid, timestamp);
                tsdb.indexTSMeta(new_meta);
                LOG.info("Counter exists but meta was null, creating meta data for timeseries [" +
                    tsuid_string + "]");
                return new_meta.storeNew(tsdb);   
              }
            }
          }
         
          // Take care of situations where the counter is created but the
          // meta data is not. May happen if the TSD crashes or is killed
          // improperly before the meta is flushed to storage.
          return TSMeta.counterExistsInStorage(tsdb, tsuid)
            .addCallbackDeferring(new CounterCB());
        }

        // verify the tsuid is good, it's possible for this to become
        // corrupted
        if (meta.getTSUID() == null ||
            meta.getTSUID().isEmpty()) {
          LOG.warn("Replacing corrupt meta data for timeseries [" +
              tsuid_string + "]");
          TSMeta new_meta = new TSMeta(tsuid, timestamp);
          tsdb.indexTSMeta(new_meta);
          return new_meta.storeNew(tsdb);
        } else {
          // we only want to update the time if it was outside of an
          // hour otherwise it's probably an accurate timestamp
          if (meta.getCreated() > (timestamp + 3600) ||
              meta.getCreated() == 0) {
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

                // and send it to the search plugin so we don't have to do that
                // here or in the local callback
                return TSMeta.incrementAndGetCounter(tsdb, tsuid)
                  .addCallbackDeferring(new CreatedCB());
              } else {
                TSMeta new_meta = new TSMeta(tsuid, timestamp);
                tsdb.indexTSMeta(new_meta);
                LOG.info("Counter exists but meta was null, creating meta data for timeseries [" +
                    tsuid_string + "]");
                return new_meta.storeNew(tsdb);   
              }
            }
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

        for (String tsuid : tsuids) {
          final HashMap<String, Object> tsuid_results =
            new HashMap<String, Object>();
         
          try {
            final TSMeta meta = TSMeta.getTSMeta(tsdb, tsuid)
              .joinUninterruptibly();
            // if the meta doesn't exist, we can't process, so just log a
            // message to the results and move on to the next TSUID
            if (meta == null) {
              tsuid_results.put("branch", null);
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

            return Deferred.fromResult(search_query);
          }
         
          switch(search_query.getType()) {
            case TSMETA:
              final TSMeta meta = new TSMeta("000001000001000001");
              meta.setCreated(1356998400);
              meta.setDescription("System CPU metric");
             
              UIDMeta uid = new UIDMeta(UniqueIdType.METRIC, "000001");
              final Field uid_name = UIDMeta.class.getDeclaredField("name");
              uid_name.setAccessible(true);
              uid_name.set(uid, "sys.cpu.0");
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

   * Sets up a TSMeta object and associated UIDMeta objects in storage for
   * testing the "test" call. These are necessary as the TSMeta is loaded when
   * parsed through the tree.
   */
  private void setupTSMeta() throws Exception {
    final TSMeta meta = new TSMeta("000001000001000001000002000002");
    storage.addColumn(UniqueId.stringToUid("000001000001000001000002000002"),
        NAME_FAMILY, "ts_meta".getBytes(MockBase.ASCII()),
        (byte[])TSMetagetStorageJSON.invoke(meta));
   
    final UIDMeta metric = new UIDMeta(UniqueIdType.METRIC, new byte[] { 0, 0, 1 },
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

    // GET
    if (method == HttpMethod.GET) {
     
      final String tsuid = query.getRequiredQueryStringParam("tsuid");
      try {
        final TSMeta meta = TSMeta.getTSMeta(tsdb, tsuid).joinUninterruptibly();
        if (meta != null) {
          query.sendReply(query.serializer().formatTSMetaV1(meta));
        } else {
          throw new BadRequestException(HttpResponseStatus.NOT_FOUND,
              "Could not find Timeseries meta data");
        }
      } catch (NoSuchUniqueName e) {
        // this would only happen if someone deleted a UID but left the
        // the timeseries meta data
        throw new BadRequestException(HttpResponseStatus.NOT_FOUND,
            "Unable to find one of the UIDs", e);
      } catch (BadRequestException e) {
        throw e;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    // POST / PUT
    } else if (method == HttpMethod.POST || method == HttpMethod.PUT) {
     
      final TSMeta meta;
      if (query.hasContent()) {
        meta = query.serializer().parseTSMetaV1();
      } else {
        meta = this.parseTSMetaQS(query);
      }
     
      /**
       * Storage callback used to determine if the storage call was successful
       * or not. Also returns the updated object from storage.
       */
      class SyncCB implements Callback<Deferred<TSMeta>, Boolean> {

        @Override
        public Deferred<TSMeta> call(Boolean success) throws Exception {
          if (!success) {
            throw new BadRequestException(
                HttpResponseStatus.INTERNAL_SERVER_ERROR,
                "Failed to save the TSMeta to storage",
                "This may be caused by another process modifying storage data");
          }
         
          return TSMeta.getTSMeta(tsdb, meta.getTSUID());
        }
       
      }
     
      try {
        final Deferred<TSMeta> process_meta = meta.syncToStorage(tsdb,
            method == HttpMethod.PUT).addCallbackDeferring(new SyncCB());
        final TSMeta updated_meta = process_meta.joinUninterruptibly();
        tsdb.indexTSMeta(updated_meta);
        query.sendReply(query.serializer().formatTSMetaV1(updated_meta));
      } catch (IllegalStateException e) {
        query.sendStatusOnly(HttpResponseStatus.NOT_MODIFIED);
      } catch (IllegalArgumentException e) {
        throw new BadRequestException(e);
      } catch (NoSuchUniqueName e) {
        // this would only happen if someone deleted a UID but left the
        // the timeseries meta data
        throw new BadRequestException(HttpResponseStatus.NOT_FOUND,
            "Unable to find one or more UIDs", e);
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    // DELETE 
    } else if (method == HttpMethod.DELETE) {
     
      final TSMeta meta;
      if (query.hasContent()) {
        meta = query.serializer().parseTSMetaV1();
      } else {
        meta = this.parseTSMetaQS(query);
      }
      try{
        meta.delete(tsdb);
        tsdb.deleteTSMeta(meta.getTSUID());
      } catch (IllegalArgumentException e) {
        throw new BadRequestException("Unable to delete TSMeta information", e);
      }
      query.sendStatusOnly(HttpResponseStatus.NO_CONTENT);
    } else {
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

   * @throws BadRequestException if a required value was missing or could not
   * be parsed
   */
  private TSMeta parseTSMetaQS(final HttpQuery query) {
    final String tsuid = query.getRequiredQueryStringParam("tsuid");
    final TSMeta meta = new TSMeta(tsuid);
   
    final String display_name = query.getQueryStringParam("display_name");
    if (display_name != null) {
      meta.setDisplayName(display_name);
    }
 
    final String description = query.getQueryStringParam("description");
    if (description != null) {
      meta.setDescription(description);
    }
   
    final String notes = query.getQueryStringParam("notes");
    if (notes != null) {
      meta.setNotes(notes);
    }
   
    final String units = query.getQueryStringParam("units");
    if (units != null) {
      meta.setUnits(units);
    }
   
    final String data_type = query.getQueryStringParam("data_type");
    if (data_type != null) {
      meta.setDataType(data_type);
    }
   
    final String retention = query.getQueryStringParam("retention");
    if (retention != null && !retention.isEmpty()) {
      try {
        meta.setRetention(Integer.parseInt(retention));
      } catch (NumberFormatException nfe) {
        throw new BadRequestException("Unable to parse 'retention' value");
      }
    }
   
    final String max = query.getQueryStringParam("max");
    if (max != null && !max.isEmpty()) {
      try {
        meta.setMax(Float.parseFloat(max));
      } catch (NumberFormatException nfe) {
        throw new BadRequestException("Unable to parse 'max' value");
      }
    }
   
    final String min = query.getQueryStringParam("min");
    if (min != null && !min.isEmpty()) {
      try {
        meta.setMin(Float.parseFloat(min));
      } catch (NumberFormatException nfe) {
        throw new BadRequestException("Unable to parse 'min' value");
      }
    }
   
View Full Code Here

Examples of net.opentsdb.meta.TSMeta

    assertEquals("2.0.0", search.version());
  }
 
  @Test
  public void indexTSMeta() throws Exception  {
    assertNotNull(search.indexTSMeta(new TSMeta()));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.