• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CassandraMetricsRegistry类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中org.apache.cassandra.metrics.CassandraMetricsRegistry的典型用法代码示例。如果您正苦于以下问题:Java CassandraMetricsRegistry类的具体用法?Java CassandraMetricsRegistry怎么用?Java CassandraMetricsRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

CassandraMetricsRegistry类属于org.apache.cassandra.metrics包,在下文中一共展示了CassandraMetricsRegistry类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: PrometheusExporter

点赞 3

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
public PrometheusExporter(int port, String path) {
    
    QueuedThreadPool threadPool = new QueuedThreadPool(25);
    server = new Server(threadPool);

    ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);
    server.addConnector(connector);

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

    CollectorRegistry collectorRegistry = new CollectorRegistry();
    
    collectorRegistry.register(new PrometheusExports(CassandraMetricsRegistry.Metrics));

    MetricsServlet metricsServlet = new MetricsServlet(collectorRegistry);

    context.addServlet(new ServletHolder(metricsServlet), "/" + path);
    try {
        server.start();
    } catch (Exception e) {
        System.err.println("cannot start metrics http server " + e.getMessage());
    }
}
 

开发者ID:nabto,
项目名称:cassandra-prometheus,
代码行数:27,
代码来源:PrometheusExporter.java

示例2: getTables

点赞 3

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
public List<Table> getTables(String keyspace) {
    List<Table> result = new ArrayList<>();
    try {
        ObjectName oName = new ObjectName( String.format("org.apache.cassandra.db:type=ColumnFamilies,keyspace=%s,columnfamily=*", keyspace));

        Set<ObjectName> names = mbeanServerConn.queryNames( oName, null);
        for (ObjectName name: names) {
            String sName = name.getKeyProperty("columnfamily");

            oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=ColumnFamily,keyspace=%s,scope=%s,name=%s", keyspace, sName, "TotalDiskSpaceUsed"));
            long size = newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxCounterMBean.class).getCount();

            result.add(new Table(sName, size));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 

开发者ID:skbkontur,
项目名称:cajrr,
代码行数:20,
代码来源:Node.java

示例3: MemtablePool

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
MemtablePool(long maxOnHeapMemory, long maxOffHeapMemory, float cleanThreshold, Runnable cleaner)
{
    this.onHeap = getSubPool(maxOnHeapMemory, cleanThreshold);
    this.offHeap = getSubPool(maxOffHeapMemory, cleanThreshold);
    this.cleaner = getCleaner(cleaner);
    blockedOnAllocating = CassandraMetricsRegistry.Metrics.timer(new DefaultNameFactory("MemtablePool")
                                                                     .createMetricName("BlockedOnAllocation"));
    if (this.cleaner != null)
        this.cleaner.start();
}
 

开发者ID:Netflix,
项目名称:sstable-adaptor,
代码行数:11,
代码来源:MemtablePool.java

示例4: onMeterAdded

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
@Override
public void onMeterAdded(String metricName, Meter meter)
{
    // Given metricName consists of appender name in logback.xml + "." + metric name.
    // We first separate appender name
    int separator = metricName.lastIndexOf('.');
    String appenderName = metricName.substring(0, separator);
    String metric = metricName.substring(separator + 1); // remove "."
    ObjectName name = DefaultNameFactory.createMetricName(appenderName, metric, null).getMBeanName();
    CassandraMetricsRegistry.Metrics.registerMBean(meter, name);
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:12,
代码来源:CassandraDaemon.java

示例5: getCacheMetric

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
/**
 * Retrieve cache metrics based on the cache type (KeyCache, RowCache, or CounterCache)
 * @param cacheType KeyCach, RowCache, or CounterCache
 * @param metricName Capacity, Entries, HitRate, Size, Requests or Hits.
 */
public Object getCacheMetric(String cacheType, String metricName)
{
    try
    {
        switch(metricName)
        {
            case "Capacity":
            case "Entries":
            case "HitRate":
            case "Size":
                return JMX.newMBeanProxy(mbeanServerConn,
                        new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName),
                        CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
            case "Requests":
            case "Hits":
                return JMX.newMBeanProxy(mbeanServerConn,
                        new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName),
                        CassandraMetricsRegistry.JmxMeterMBean.class).getCount();
            default:
                throw new RuntimeException("Unknown cache metric name.");

        }
    }
    catch (MalformedObjectNameException e)
    {
        throw new RuntimeException(e);
    }
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:34,
代码来源:NodeProbe.java

示例6: getProxyMetric

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
/**
 * Retrieve Proxy metrics
 * @param scope RangeSlice, Read or Write
 */
public CassandraMetricsRegistry.JmxTimerMBean getProxyMetric(String scope)
{
    try
    {
        return JMX.newMBeanProxy(mbeanServerConn,
                new ObjectName("org.apache.cassandra.metrics:type=ClientRequest,scope=" + scope + ",name=Latency"),
                CassandraMetricsRegistry.JmxTimerMBean.class);
    }
    catch (MalformedObjectNameException e)
    {
        throw new RuntimeException(e);
    }
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:18,
代码来源:NodeProbe.java

示例7: getCompactionMetric

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
/**
 * Retrieve Proxy metrics
 * @param metricName CompletedTasks, PendingTasks, BytesCompacted or TotalCompactionsCompleted.
 */
public Object getCompactionMetric(String metricName)
{
    try
    {
        switch(metricName)
        {
            case "BytesCompacted":
                return JMX.newMBeanProxy(mbeanServerConn,
                        new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName),
                        CassandraMetricsRegistry.JmxCounterMBean.class);
            case "CompletedTasks":
            case "PendingTasks":
                return JMX.newMBeanProxy(mbeanServerConn,
                        new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName),
                        CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
            case "TotalCompactionsCompleted":
                return JMX.newMBeanProxy(mbeanServerConn,
                        new ObjectName("org.apache.cassandra.metrics:type=Compaction,name=" + metricName),
                        CassandraMetricsRegistry.JmxMeterMBean.class);
            default:
                throw new RuntimeException("Unknown compaction metric.");
        }
    }
    catch (MalformedObjectNameException e)
    {
        throw new RuntimeException(e);
    }
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:33,
代码来源:NodeProbe.java

示例8: getStorageMetric

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
/**
 * Retrieve Proxy metrics
 * @param metricName Exceptions, Load, TotalHints or TotalHintsInProgress.
 */
public long getStorageMetric(String metricName)
{
    try
    {
        return JMX.newMBeanProxy(mbeanServerConn,
                new ObjectName("org.apache.cassandra.metrics:type=Storage,name=" + metricName),
                CassandraMetricsRegistry.JmxCounterMBean.class).getCount();
    }
    catch (MalformedObjectNameException e)
    {
        throw new RuntimeException(e);
    }
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:18,
代码来源:NodeProbe.java

示例9: metricPercentilesAsArray

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
public double[] metricPercentilesAsArray(CassandraMetricsRegistry.JmxHistogramMBean metric)
{
    return new double[]{ metric.get50thPercentile(),
            metric.get75thPercentile(),
            metric.get95thPercentile(),
            metric.get98thPercentile(),
            metric.get99thPercentile(),
            metric.getMin(),
            metric.getMax()};
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java
代码行数:11,
代码来源:NodeProbe.java

示例10: clearCache

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
private static void clearCache()
{
    CassandraMetricsRegistry.Metrics.getNames().forEach(CassandraMetricsRegistry.Metrics::remove);
    CacheService.instance.keyCache.clear();
    CacheMetrics metrics = CacheService.instance.keyCache.getMetrics();
    Assert.assertEquals(0, metrics.entries.getValue().intValue());
    Assert.assertEquals(0L, metrics.hits.getCount());
    Assert.assertEquals(0L, metrics.requests.getCount());
    Assert.assertEquals(0L, metrics.size.getValue().longValue());
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java,
代码行数:11,
代码来源:KeyCacheCqlTest.java

示例11: getColumnFamilyMetric

点赞 2

import org.apache.cassandra.metrics.CassandraMetricsRegistry; //导入依赖的package包/类
/**
 * Retrieve ColumnFamily metrics
 * @param ks Keyspace for which stats are to be displayed.
 * @param cf ColumnFamily for which stats are to be displayed.
 * @param metricName View {@link TableMetrics}.
 */
public Object getColumnFamilyMetric(String ks, String cf, String metricName)
{
    try
    {
        String type = cf.contains(".") ? "IndexTable" : "Table";
        ObjectName oName = new ObjectName(String.format("org.apache.cassandra.metrics:type=%s,keyspace=%s,scope=%s,name=%s", type, ks, cf, metricName));
        switch(metricName)
        {
            case "BloomFilterDiskSpaceUsed":
            case "BloomFilterFalsePositives":
            case "BloomFilterFalseRatio":
            case "BloomFilterOffHeapMemoryUsed":
            case "IndexSummaryOffHeapMemoryUsed":
            case "CompressionMetadataOffHeapMemoryUsed":
            case "CompressionRatio":
            case "EstimatedColumnCountHistogram":
            case "EstimatedPartitionSizeHistogram":
            case "EstimatedPartitionCount":
            case "KeyCacheHitRate":
            case "LiveSSTableCount":
            case "MaxPartitionSize":
            case "MeanPartitionSize":
            case "MemtableColumnsCount":
            case "MemtableLiveDataSize":
            case "MemtableOffHeapSize":
            case "MinPartitionSize":
            case "RecentBloomFilterFalsePositives":
            case "RecentBloomFilterFalseRatio":
            case "SnapshotsSize":
                return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
            case "LiveDiskSpaceUsed":
            case "MemtableSwitchCount":
            case "SpeculativeRetries":
            case "TotalDiskSpaceUsed":
            case "WriteTotalLatency":
            case "ReadTotalLatency":
            case "PendingFlushes":
                return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxCounterMBean.class).getCount();
            case "CoordinatorReadLatency":
            case "CoordinatorScanLatency":
            case "ReadLatency":
            case "WriteLatency":
                return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxTimerMBean.class);
            case "LiveScannedHistogram":
            case "SSTablesPerReadHistogram":
            case "TombstoneScannedHistogram":
                return JMX.newMBeanProxy(mbeanServerConn, oName, CassandraMetricsRegistry.JmxHistogramMBean.class);
            default:
                throw new RuntimeException("Unknown table metric " + metricName);
        }
    }
    catch (MalformedObjectNameException e)
    {
        throw new RuntimeException(e);
    }
}
 

开发者ID:scylladb,
项目名称:scylla-tools-java,
代码行数:63,
代码来源:NodeProbe.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)