当前位置: 首页>>代码示例>>Java>>正文


Java Metrics.newGauge方法代码示例

本文整理汇总了Java中com.yammer.metrics.Metrics.newGauge方法的典型用法代码示例。如果您正苦于以下问题:Java Metrics.newGauge方法的具体用法?Java Metrics.newGauge怎么用?Java Metrics.newGauge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.yammer.metrics.Metrics的用法示例。


在下文中一共展示了Metrics.newGauge方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createColumnFamilyCounter

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
/**
 * Creates a counter that will also have a global counter thats the sum of all counters across 
 * different column families
 */
protected Counter createColumnFamilyCounter(final String name)
{
    Counter cfCounter = Metrics.newCounter(factory.createMetricName(name));
    if (register(name, cfCounter))
    {
        Metrics.newGauge(globalNameFactory.createMetricName(name), new Gauge<Long>()
        {
            public Long value()
            {
                long total = 0;
                for (Metric cfGauge : allColumnFamilyMetrics.get(name))
                {
                    total += ((Counter) cfGauge).count();
                }
                return total;
            }
        });
    }
    return cfCounter;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:ColumnFamilyMetrics.java

示例2: addCounter

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例3: CommitLogMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例4: FileCacheMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例5: createKeyspaceGauge

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
/**
 * Creates a gauge that will sum the current value of a metric for all column families in this keyspace
 * @param name
 * @param MetricValue 
 * @return Gauge&gt;Long> that computes sum of MetricValue.getValue()
 */
private <T extends Number> Gauge<Long> createKeyspaceGauge(String name, final MetricValue extractor)
{
    allMetrics.add(name);
    return Metrics.newGauge(factory.createMetricName(name), new Gauge<Long>()
    {
        public Long value()
        {
            long sum = 0;
            for (ColumnFamilyStore cf : keyspace.getColumnFamilyStores())
            {
                sum += extractor.getValue(cf.metric);
            }
            return sum;
        }
    });
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:23,代码来源:KeyspaceMetrics.java

示例6: CQLMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例7: CommitLogMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例8: FileCacheMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例9: keepGaugesIfTheyThrowRuntimeExceptions

import com.yammer.metrics.Metrics; //导入方法依赖的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

示例10: AbstractDistributedIndexServer

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
public AbstractDistributedIndexServer(ClusterStatus clusterStatus, Configuration configuration, String nodeName,
    String cluster) {
  _clusterStatus = clusterStatus;
  _configuration = configuration;
  _nodeName = nodeName;
  _cluster = cluster;
  MetricName tableCount = new MetricName(ORG_APACHE_BLUR, BLUR, TABLE_COUNT, _cluster);
  MetricName indexCount = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_COUNT, _cluster);
  MetricName segmentCount = new MetricName(ORG_APACHE_BLUR, BLUR, SEGMENT_COUNT, _cluster);
  MetricName indexMemoryUsage = new MetricName(ORG_APACHE_BLUR, BLUR, INDEX_MEMORY_USAGE, _cluster);
  MetricName recordCount = new MetricName(ORG_APACHE_BLUR, BLUR, RECORD_COUNT, _cluster);

  Metrics.newGauge(tableCount, new AtomicLongGauge(_tableCount));
  Metrics.newGauge(indexCount, new AtomicLongGauge(_indexCount));
  Metrics.newGauge(segmentCount, new AtomicLongGauge(_segmentCount));
  Metrics.newGauge(indexMemoryUsage, new AtomicLongGauge(_indexMemoryUsage));
  Metrics.newGauge(recordCount, new AtomicLongGauge(_recordCount));
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:19,代码来源:AbstractDistributedIndexServer.java

示例11: createColumnFamilyGauge

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
/**
 * Create a gauge that will be part of a merged version of all column families.  The global gauge
 * is defined as the globalGauge parameter
 */
protected <G,T> Gauge<T> createColumnFamilyGauge(String name, Gauge<T> gauge, Gauge<G> globalGauge)
{
    Gauge<T> cfGauge = Metrics.newGauge(factory.createMetricName(name), gauge);
    if (register(name, cfGauge))
    {
        Metrics.newGauge(globalNameFactory.createMetricName(name), globalGauge);
    }
    return cfGauge;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:14,代码来源:ColumnFamilyMetrics.java

示例12: ThreadPoolMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
/**
 * Create metrics for given ThreadPoolExecutor.
 *
 * @param executor Thread pool
 * @param path Type of thread pool
 * @param poolName Name of thread pool to identify metrics
 */
public ThreadPoolMetrics(final ThreadPoolExecutor executor, String path, String poolName)
{
    this.factory = new ThreadPoolMetricNameFactory("ThreadPools", path, poolName);

    activeTasks = Metrics.newGauge(factory.createMetricName("ActiveTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return executor.getActiveCount();
        }
    });
    totalBlocked = Metrics.newCounter(factory.createMetricName("TotalBlockedTasks"));
    currentBlocked = Metrics.newCounter(factory.createMetricName("CurrentlyBlockedTasks"));
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getCompletedTaskCount();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getTaskCount() - executor.getCompletedTaskCount();
        }
    });
    maxPoolSize =  Metrics.newGauge(factory.createMetricName("MaxPoolSize"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return executor.getMaximumPoolSize();
        }
    });
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:43,代码来源:ThreadPoolMetrics.java

示例13: ThreadPoolMetrics

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
/**
 * Create metrics for given ThreadPoolExecutor.
 *
 * @param executor Thread pool
 * @param path Type of thread pool
 * @param poolName Name of thread pool to identify metrics
 */
public ThreadPoolMetrics(final ThreadPoolExecutor executor, String path, String poolName)
{
    this.factory = new ThreadPoolMetricNameFactory(path, poolName);

    activeTasks = Metrics.newGauge(factory.createMetricName("ActiveTasks"), new Gauge<Integer>()
    {
        public Integer value()
        {
            return executor.getActiveCount();
        }
    });
    totalBlocked = Metrics.newCounter(factory.createMetricName("TotalBlockedTasks"));
    currentBlocked = Metrics.newCounter(factory.createMetricName("CurrentlyBlockedTasks"));
    completedTasks = Metrics.newGauge(factory.createMetricName("CompletedTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getCompletedTaskCount();
        }
    });
    pendingTasks = Metrics.newGauge(factory.createMetricName("PendingTasks"), new Gauge<Long>()
    {
        public Long value()
        {
            return executor.getTaskCount() - executor.getCompletedTaskCount();
        }
    });
}
 
开发者ID:pgaref,项目名称:ACaZoo,代码行数:36,代码来源:ThreadPoolMetrics.java

示例14: ByteArrayPrimitiveFactory

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
public ByteArrayPrimitiveFactory(BlurConfiguration configuration) {
  super(configuration);
  Metrics.newGauge(new MetricName(ORG_APACHE_BLUR, FST, SIZE), new Gauge<Long>() {
    @Override
    public Long value() {
      return _size.get();
    }
  });
}
 
开发者ID:apache,项目名称:incubator-blur,代码行数:10,代码来源:ByteArrayPrimitiveFactory.java

示例15: deleteGaugesIfTheyThrowNoSuchElementException

import com.yammer.metrics.Metrics; //导入方法依赖的package包/类
@Test
public void deleteGaugesIfTheyThrowNoSuchElementException() throws Exception {
    MetricPredicate predicate = new FilterMetricPredicate();

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

    Metric gaugeToBeDeleted = Metrics.newGauge(metricNameToBeDeleted, new Gauge<Long>() {
        @Override
        public Long value() {
            throw new NoSuchElementException("catch me if you can - i'm the the same as in KAFKA-1866");
        }
    });

    MetricName metricNameToStay = new MetricName("stay", "stay", "stay", "scope", "stay:mBeanName");
    Metric gaugeToStay = Metrics.newGauge(metricNameToStay, new Gauge<Long>() {
        @Override
        public Long value() {
            return 42L;
        }
    });


    assertFalse(predicate.matches(metricNameToBeDeleted, gaugeToBeDeleted));
    assertTrue(predicate.matches(metricNameToStay, gaugeToStay));


    assertFalse("The gauge should be deleted", Metrics.defaultRegistry().allMetrics().containsKey(metricNameToBeDeleted));
    assertTrue("The gauge should be there", Metrics.defaultRegistry().allMetrics().containsKey(metricNameToStay));
    assertEquals(Metrics.defaultRegistry().allMetrics().get(metricNameToStay), gaugeToStay);
}
 
开发者ID:damienclaveau,项目名称:kafka-graphite,代码行数:31,代码来源:FilterMetricPredicateTest.java


注:本文中的com.yammer.metrics.Metrics.newGauge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。