当前位置: 首页>>代码示例>>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;未经允许,请勿转载。