Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonGenerator.writeStartObject()


          json.writeStartObject();
         
          json.writeStringField("metric", dps.metricName());
         
          json.writeFieldName("tags");
          json.writeStartObject();
          if (dps.getTags() != null) {
            for (Map.Entry<String, String> tag : dps.getTags().entrySet()) {
              json.writeStringField(tag.getKey(), tag.getValue());
            }
          }
View Full Code Here


  private byte[] getStorageJSON() {
    // 256 bytes is a good starting value, assumes default info
    final ByteArrayOutputStream output = new ByteArrayOutputStream(256);
    try {
      final JsonGenerator json = JSON.getFactory().createGenerator(output);
      json.writeStartObject();
      json.writeStringField("tsuid", tsuid);
      json.writeStringField("displayName", display_name);
      json.writeStringField("description", description);
      json.writeStringField("notes", notes);
      json.writeNumberField("created", created);
View Full Code Here

              }
              json.writeEndArray();
            }
            json.writeEndArray();
          } else {
            json.writeStartObject();
            for (final DataPoint dp : dps) {
              if (dp.timestamp() < (data_query.startTime()) ||
                  dp.timestamp() > (data_query.endTime())) {
                continue;
              }
View Full Code Here

   *            OutputStream to write JSON to
   * @throws IOException
   */
  public void serialize(@Nonnull Iterable<QueryResult> results, @Nonnull OutputStream out) throws IOException {
    JsonGenerator g = jsonFactory.createGenerator(out, JsonEncoding.UTF8);
    g.writeStartObject();
    g.writeNumberField("timestamp", System.currentTimeMillis() / 1000);
    g.writeNumberField("proto_version", STACKDRIVER_PROTOCOL_VERSION);
    g.writeArrayFieldStart("data");

    for (QueryResult metric : results) {
View Full Code Here

    g.writeNumberField("timestamp", System.currentTimeMillis() / 1000);
    g.writeNumberField("proto_version", STACKDRIVER_PROTOCOL_VERSION);
    g.writeArrayFieldStart("data");

    for (QueryResult metric : results) {
      g.writeStartObject();
      g.writeStringField("name", metric.getName());
      if (instanceId != null && !instanceId.isEmpty()) {
        g.writeStringField("instance", instanceId);
      }
      g.writeNumberField("collected_at", metric.getEpoch(TimeUnit.SECONDS));
View Full Code Here

        for (QueryResult counter : counters) {
           if( 0 == first ) {
              time = counter.getEpoch(TimeUnit.SECONDS);
              myID = counter.getType();
              first = 1;
              g.writeStartObject();
              g.writeStringField("identifier", myID);
              g.writeNumberField("timestamp", time);
              g.writeObjectFieldStart("values");
           }
           if (counter.getValue() instanceof Integer) {
View Full Code Here

        }
    }

    public void serialize(@Nonnull Iterable<QueryResult> counters, @Nonnull Iterable<QueryResult> gauges, @Nonnull OutputStream out) throws IOException {
        JsonGenerator g = jsonFactory.createGenerator(out, JsonEncoding.UTF8);
        g.writeStartObject();
        g.writeArrayFieldStart("counters");

        for (QueryResult counter : counters) {
            g.writeStartObject();
            g.writeStringField("name", counter.getName());
View Full Code Here

        JsonGenerator g = jsonFactory.createGenerator(out, JsonEncoding.UTF8);
        g.writeStartObject();
        g.writeArrayFieldStart("counters");

        for (QueryResult counter : counters) {
            g.writeStartObject();
            g.writeStringField("name", counter.getName());
            if (source != null && !source.isEmpty()) {
                g.writeStringField("source", source);
            }
            g.writeNumberField("measure_time", counter.getEpoch(TimeUnit.SECONDS));
View Full Code Here

        g.writeEndArray();

        g.writeArrayFieldStart("gauges");

        for (QueryResult gauge : gauges) {
            g.writeStartObject();
            g.writeStringField("name", gauge.getName());
            if (source != null && !source.isEmpty()) {
                g.writeStringField("source", source);
            }
            g.writeNumberField("measure_time", gauge.getEpoch(TimeUnit.SECONDS));
View Full Code Here

  @Override
  public String apply(MetricRegistry metricRegistry) throws Exception {
    OutputStream out = new ByteArrayOutputStream();
    JsonGenerator json = factory.createGenerator(out);

    json.writeStartObject();
    json.writeNumberField("timestamp", clock.getTime());
    writeTimers(json, metricRegistry.getTimers());
    writeGauges(json, metricRegistry.getGauges());
    writeMeters(json, metricRegistry.getMeters());
    writeCounters(json, metricRegistry.getCounters());
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.