當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。