當前位置: 首頁>>代碼示例>>Java>>正文


Java Gauge類代碼示例

本文整理匯總了Java中com.yammer.metrics.core.Gauge的典型用法代碼示例。如果您正苦於以下問題:Java Gauge類的具體用法?Java Gauge怎麽用?Java Gauge使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Gauge類屬於com.yammer.metrics.core包,在下文中一共展示了Gauge類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addCounter

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public void addCounter(String name, final Callable<Integer> provider)
{
    Metrics.newGauge(factory.createMetricName(name), new Gauge<Integer>()
    {
        public Integer value()
        {
            try
            {
                return provider.call();
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:18,代碼來源:ClientMetrics.java

示例2: CommitLogMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public CommitLogMetrics(final AbstractCommitLogService service, final CommitLogSegmentManager allocator)
{
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
    waitingOnSegmentAllocation = Metrics.newTimer(factory.createMetricName("WaitingOnSegmentAllocation"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
    waitingOnCommit = Metrics.newTimer(factory.createMetricName("WaitingOnCommit"), TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:27,代碼來源:CommitLogMetrics.java

示例3: FileCacheMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public FileCacheMetrics()
{
    hits = Metrics.newMeter(factory.createMetricName("Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(factory.createMetricName("Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(factory.createMetricName("HitRate"), new RatioGauge()
    {
        protected double getNumerator()
        {
            return hits.count();
        }

        protected double getDenominator()
        {
            return requests.count();
        }
    });
    size = Metrics.newGauge(factory.createMetricName("Size"), new Gauge<Long>()
    {
        public Long value()
        {
            return FileCacheService.instance.sizeInBytes();
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:25,代碼來源:FileCacheMetrics.java

示例4: CQLMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public CQLMetrics()
{
    regularStatementsExecuted = Metrics.newCounter(factory.createMetricName("RegularStatementsExecuted"));
    preparedStatementsExecuted = Metrics.newCounter(factory.createMetricName("PreparedStatementsExecuted"));
    preparedStatementsEvicted = Metrics.newCounter(factory.createMetricName("PreparedStatementsEvicted"));

    preparedStatementsCount = Metrics.newGauge(factory.createMetricName("PreparedStatementsCount"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return QueryProcessor.preparedStatementsCount();
        }
    });
    preparedStatementsRatio = Metrics.newGauge(factory.createMetricName("PreparedStatementsRatio"), new RatioGauge()
    {
        public double getNumerator()
        {
            return preparedStatementsExecuted.count();
        }

        public double getDenominator()
        {
            return regularStatementsExecuted.count() + preparedStatementsExecuted.count();
        }
    });
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:27,代碼來源:CQLMetrics.java

示例5: CommitLogMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public CommitLogMetrics(final ICommitLogExecutorService executor, final CommitLogAllocator allocator)
{
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:25,代碼來源:CommitLogMetrics.java

示例6: FileCacheMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public FileCacheMetrics()
{
    hits = Metrics.newMeter(new MetricName(FileCacheService.class, "Hits"), "hits", TimeUnit.SECONDS);
    requests = Metrics.newMeter(new MetricName(FileCacheService.class, "Requests"), "requests", TimeUnit.SECONDS);
    hitRate = Metrics.newGauge(new MetricName(FileCacheService.class, "HitRate"), new RatioGauge()
    {
        protected double getNumerator()
        {
            return hits.count();
        }

        protected double getDenominator()
        {
            return requests.count();
        }
    });
    size = Metrics.newGauge(new MetricName(FileCacheService.class, "Size"), new Gauge<Long>()
    {
        public Long value()
        {
            return FileCacheService.instance.sizeInBytes();
        }
    });
}
 
開發者ID:pgaref,項目名稱:ACaZoo,代碼行數:25,代碼來源:FileCacheMetrics.java

示例7: getStats

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
@ManagedAttribute
public Map<String, Object> getStats() {
    Map<String, Object> stats = new HashMap<String, Object>();
    
    MetricsRegistry registry = Metrics.defaultRegistry();
    for (Entry<MetricName, Metric> e : registry.allMetrics().entrySet()) {
        MetricName name = e.getKey();
        Metric metric = e.getValue();
        
        if (metric instanceof Meter) {
            Meter m = (Meter) metric;
            stats.put(name.toString(), new MeterPOJO(m));
        } else if (metric instanceof Gauge) {
            Gauge<?> g = (Gauge<?>) metric;
            stats.put(name.toString(), g.value());
        }
    }
    
    return stats;
}
 
開發者ID:pulsarIO,項目名稱:jetstream,代碼行數:21,代碼來源:KafkaMetrics.java

示例8: keepGaugesIfTheyThrowRuntimeExceptions

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
@Test
public void keepGaugesIfTheyThrowRuntimeExceptions() throws Exception {
    MetricPredicate predicate = new FilterMetricPredicate();

    MetricName metricName = new MetricName("test", "test", "delete", "scope", "mBeanName");

    Metric gauge = Metrics.newGauge(metricName, new Gauge<Long>() {
        @Override
        public Long value() {
            throw new RuntimeException("catch me if you can");
        }
    });

    assertTrue(predicate.matches(metricName, gauge));

    assertTrue("The gauge should be there", Metrics.defaultRegistry().allMetrics().containsKey(metricName));
    assertEquals(Metrics.defaultRegistry().allMetrics().get(metricName), gauge);
}
 
開發者ID:damienclaveau,項目名稱:kafka-graphite,代碼行數:19,代碼來源:FilterMetricPredicateTest.java

示例9: CommitLogMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public CommitLogMetrics(final ICommitLogExecutorService executor, final CommitLogAllocator allocator)
{
    completedTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(new MetricName(GROUP_NAME, TYPE_NAME, "TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
}
 
開發者ID:dprguiuc,項目名稱:Cassandra-Wasef,代碼行數:25,代碼來源:CommitLogMetrics.java

示例10: CommitLogMetrics

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public CommitLogMetrics(final AbstractCommitLogService service, final CommitLogSegmentManager allocator)
{
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getCompletedTasks();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return service.getPendingTasks();
        }
    });
    totalCommitLogSize = Metrics.newGauge(factory.createMetricName("TotalCommitLogSize"), new Gauge<Long>()
    {
        public Long value()
        {
            return allocator.bytesUsed();
        }
    });
}
 
開發者ID:mafernandez-stratio,項目名稱:cassandra-cqlMod,代碼行數:25,代碼來源:CommitLogMetrics.java

示例11: before

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
@Before
    public void before() throws Exception {
        final Gauge<Long> gauge = Metrics.newGauge(metricName, new Gauge<Long>() {
            long current = 42;

            @Override
            public Long value() {
                return current;
            }
        });

        server = new Server(8081);
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        server.setHandler(context);

        context.addServlet(new ServletHolder(new JimixServlet()), "/jimix/*");
        server.start();        
//        driver = new FirefoxDriver();
        driver = new PhantomJSDriver();
        driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
    }
 
開發者ID:manuel-woelker,項目名稱:jimix,代碼行數:23,代碼來源:JimixServletIntegrationTest.java

示例12: getProperty

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public static Property getProperty(final Property propertyOrNull, final Metric metric) {
  if (propertyOrNull != null) {
    return propertyOrNull;
  } else {
    // is null, find a default
    if (metric instanceof Counter) {
      return CounterProperty.COUNT;
    } else if (metric instanceof Gauge) {
      return GaugeProperty.VALUE_GAUGE;
    } else if (metric instanceof Timer) {
      return TimerProperty.MEDIAN;
    } else if (metric instanceof Meter) {
      return MeterProperty.FIVE_MINUTE_RATE;
    } else if (metric instanceof Histogram) {
      return HistogramProperty.MEDIAN;
    } else {
      throw new RuntimeException("Unexpected metric type: " + metric.getClass());
    }
  }
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:21,代碼來源:Property.java

示例13: testFetchGauge

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
@Test
public void testFetchGauge() throws Exception {
  final MetricName name = new MetricName("gr", "t1", "n1");
  metricsRegistry.newGauge(name, new Gauge<Integer>() {
    @Override
    public Integer value() {
      return 123;
    }});

  final MuninDataSourceFactory dataSourceFactory = new MuninDataSourceFactory();
  Map<String, MuninGraph> graphs = new HashMap<String, MuninGraph>() {{
    put("foo", new MuninGraph("foo", "gr", "t", asList(
        dataSourceFactory.forMetric(name, null, null, new MuninDataSourceConfig()))));
  }};

  MetricsCommandProcessor sut = new MetricsCommandProcessor(metricsRegistry, new StaticMuninGraphProvider(graphs), hostname);

  assertEquals(asList(
    "n1__value_gauge.value 123",
    "."
    )
    , sut.processCommand("fetch", asList("foo")));
}
 
開發者ID:spotify,項目名稱:metrics-munin-reporter,代碼行數:24,代碼來源:MetricsCommandProcessorTest.java

示例14: DeepPagingCache

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
public DeepPagingCache(long maxEntriesForDeepPaging) {
  _hits = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, DEEP_PAGING_CACHE, HIT), HIT, TimeUnit.SECONDS);
  _misses = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, DEEP_PAGING_CACHE, MISS), MISS, TimeUnit.SECONDS);
  _evictions = Metrics.newMeter(new MetricName(ORG_APACHE_BLUR, DEEP_PAGING_CACHE, EVICTION), EVICTION,
      TimeUnit.SECONDS);
  _lruCache = new ConcurrentLinkedHashMap.Builder<DeepPageKeyPlusPosition, DeepPageContainer>()
      .maximumWeightedCapacity(maxEntriesForDeepPaging)
      .listener(new EvictionListener<DeepPageKeyPlusPosition, DeepPageContainer>() {
        @Override
        public void onEviction(DeepPageKeyPlusPosition key, DeepPageContainer value) {
          _positionCache.remove(key);
          _evictions.mark();
        }
      }).build();
  Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, DEEP_PAGING_CACHE, SIZE), new Gauge<Long>() {
    @Override
    public Long value() {
      return _lruCache.weightedSize();
    }
  });
  _positionCache = new ConcurrentSkipListMap<DeepPageKeyPlusPosition, DeepPageContainer>();
}
 
開發者ID:apache,項目名稱:incubator-blur,代碼行數:23,代碼來源:DeepPagingCache.java

示例15: getCumulativeCounter

import com.yammer.metrics.core.Gauge; //導入依賴的package包/類
private static Metric getCumulativeCounter(MetricsRegistry metricsRegistry,
                                           MetricMetadata metricMetadata) {
    MetricName counterCallbackName = new MetricName(YammerExample.class, "yammer.test.cumulativeCounter");
    Metric cumulativeCounter = SfUtil.cumulativeCounter(
            metricsRegistry,
            counterCallbackName,
            metricMetadata,
            new Gauge<Long>() {

                private long i = 0;

                @Override
                public Long value() {
                    return i++;
                }

            });

    metricMetadata.forMetric(cumulativeCounter)
            .withSourceName(SIGNAL_FX)
            .withDimension(LIBRARY_VERSION, YAMMER);

    return cumulativeCounter;
}
 
開發者ID:signalfx,項目名稱:signalfx-java,代碼行數:25,代碼來源:YammerExample.java


注:本文中的com.yammer.metrics.core.Gauge類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。