Package fontsvg

Examples of fontsvg.FreeSansBoldGM$Metric


  public void testPutMetrics() throws Exception {
    SubsetConfiguration configuration = createNiceMock(SubsetConfiguration.class);
    Connection connection = createNiceMock(Connection.class);
    CallableStatement cstmt = createNiceMock(CallableStatement.class);
    MetricsRecord record = createNiceMock(MetricsRecord.class);
    Metric metric = createNiceMock(Metric.class);

    // set expectations
    expect(configuration.getParent()).andReturn(null);
    expect(configuration.getPrefix()).andReturn("prefix");
    expect(configuration.getString("databaseUrl")).andReturn("url");

    expect(record.context()).andReturn("context");
    expect(record.name()).andReturn("typeName");
    expect(record.tags()).andReturn(new HashSet<MetricsTag>());
    expect(record.timestamp()).andReturn(9999L);

    expect(record.metrics()).andReturn(Collections.singleton(metric));

    expect(metric.name()).andReturn("name").anyTimes();
    expect(metric.value()).andReturn(1234);

    expect(connection.prepareCall("{call dbo.uspGetMetricRecord(?, ?, ?, ?, ?, ?, ?, ?, ?)}")).andReturn(cstmt);
    cstmt.setNString(1, "context");
    cstmt.setNString(2, "typeName");
    cstmt.setNString(eq(3), (String) anyObject());
View Full Code Here


    public void testPutMetrics() throws Exception {
        SubsetConfiguration configuration = createNiceMock(SubsetConfiguration.class);
        Connection connection = createNiceMock(Connection.class);
        CallableStatement cstmt = createNiceMock(CallableStatement.class);
        MetricsRecord record = createNiceMock(MetricsRecord.class);
        Metric metric = createNiceMock(Metric.class);

        // set expectations
        expect(configuration.getParent()).andReturn(null);
        expect(configuration.getPrefix()).andReturn("prefix");
        expect(configuration.getString("databaseUrl")).andReturn("url");

        expect(record.context()).andReturn("context");
        expect(record.name()).andReturn("typeName");
        expect(record.tags()).andReturn(new HashSet<MetricsTag>());
        expect(record.timestamp()).andReturn(9999L);

        expect(record.metrics()).andReturn(Collections.singleton(metric));

        expect(metric.name()).andReturn("name").anyTimes();
        expect(metric.value()).andReturn(1234);

        expect(connection.prepareCall("{call dbo.uspGetMetricRecord(?, ?, ?, ?, ?, ?, ?, ?, ?)}")).andReturn(cstmt);
        cstmt.setNString(1, "context");
        cstmt.setNString(2, "typeName");
        cstmt.setNString(eq(3), (String) anyObject());
View Full Code Here

  private MetricsTag makeTag(String name, String value) {
    return new MetricsTag(name, "", value);
  }

  private Metric makeMetric(String name, Number value) {
    Metric metric = mock(Metric.class);
    when(metric.name()).thenReturn(name);
    when(metric.value()).thenReturn(value);
    return metric;
  }
View Full Code Here

        // and get the updated data
        cachedMetrics = metricsCache.update(record);

        if (cachedMetrics != null && cachedMetrics.metricsEntrySet() != null) {
          for (Map.Entry<String, Metric> entry : cachedMetrics.metricsEntrySet()) {
            Metric metric = entry.getValue();
            sb.append(metric.name());
            String name = sb.toString();

            // visit the metric to identify the Ganglia type and slope
            metric.visit(gangliaMetricVisitor);
            type = gangliaMetricVisitor.getType();
            slopeFromMetric = gangliaMetricVisitor.getSlope();


            GangliaConf gConf = getGangliaConfForMetric(name);
            calculatedSlope = calculateSlope(gConf, slopeFromMetric);

            // send metric to Ganglia
            emitMetric(groupName, name, type, metric.value().toString(),
                gConf, calculatedSlope);

            // reset the length of the buffer for next iteration
            sb.setLength(sbBaseLen);
          }
        }
      } else {
        // we support sparse updates

        Collection<Metric> metrics = (Collection<Metric>) record.metrics();
        if (metrics.size() > 0) {
          // we got metrics. so send the latest
          for (Metric metric : record.metrics()) {
            sb.append(metric.name());
            String name = sb.toString();

            // visit the metric to identify the Ganglia type and slope
            metric.visit(gangliaMetricVisitor);
            type = gangliaMetricVisitor.getType();
            slopeFromMetric = gangliaMetricVisitor.getSlope();


            GangliaConf gConf = getGangliaConfForMetric(name);
            calculatedSlope = calculateSlope(gConf, slopeFromMetric);

            // send metric to Ganglia
            emitMetric(groupName, name, type, metric.value().toString(),
                gConf, calculatedSlope);

            // reset the length of the buffer for next iteration
            sb.setLength(sbBaseLen);
          }
View Full Code Here

      final Iterator<Metric> it = delegate.metrics().iterator();
      public Iterator<Metric> iterator() {
        return new TryIterator<Metric>() {
          public Metric tryNext() {
            if (it.hasNext()) do {
              Metric next = it.next();
              if (filter.accepts(next.name())) {
                return next;
              }
            } while (it.hasNext());
            return done();
          }
View Full Code Here

     * Get the metric value
     * @param key name of the metric
     * @return the metric value
     */
    public Number getMetric(String key) {
      Metric metric = metrics.get(key);
      return metric != null ? metric.value() : null;
    }
View Full Code Here

  private MetricsTag makeTag(String name, String value) {
    return new MetricsTag(name, "", value);
  }

  private Metric makeMetric(String name, Number value) {
    Metric metric = mock(Metric.class);
    when(metric.name()).thenReturn(name);
    when(metric.value()).thenReturn(value);
    return metric;
  }
View Full Code Here

TOP

Related Classes of fontsvg.FreeSansBoldGM$Metric

Copyright © 2018 www.massapicom. 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.