• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CacheMetrics类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testKeyCacheNonClustered

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
@Test
public void testKeyCacheNonClustered() throws Throwable
{
    String table = createTable("CREATE TABLE %s ("
                               + commonColumnsDef
                               + "PRIMARY KEY ((part_key_a, part_key_b)))");
    insertData(table, null, false);
    clearCache();

    for (int i = 0; i < 10; i++)
    {
        assertRows(execute("SELECT col_text FROM %s WHERE part_key_a = ? AND part_key_b = ?", i, Integer.toOctalString(i)),
                   new Object[]{ String.valueOf(i) + '-' + String.valueOf(0) });
    }

    CacheMetrics metrics = CacheService.instance.keyCache.getMetrics();
    long hits = metrics.hits.getCount();
    long requests = metrics.requests.getCount();
    assertEquals(0, hits);
    assertEquals(10, requests);

    for (int i = 0; i < 100; i++)
    {
        assertRows(execute("SELECT col_text FROM %s WHERE part_key_a = ? AND part_key_b = ?", i, Integer.toOctalString(i)),
                   new Object[]{ String.valueOf(i) + '-' + String.valueOf(0) });
    }

    hits = metrics.hits.getCount();
    requests = metrics.requests.getCount();
    assertEquals(10, hits);
    assertEquals(120, requests);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:33,代码来源:KeyCacheCqlTest.java


示例2: clearCache

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的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


示例3: CacheService

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
public CacheService(APIClient client) {
    super(MBEAN_NAME, client, new CacheMetrics("KeyCache", "key"), new CacheMetrics("RowCache", "row"),
            new CacheMetrics("CounterCache", "counter"));
}
 
开发者ID:scylladb,项目名称:scylla-jmx,代码行数:5,代码来源:CacheService.java


示例4: InstrumentingCache

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
public InstrumentingCache(String type, ICache<K, V> map)
{
    this.map = map;
    this.type = type;
    this.metrics = new CacheMetrics(type, map);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:7,代码来源:InstrumentingCache.java


示例5: clear

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
public void clear()
{
    map.clear();
    metrics = new CacheMetrics(type, map);
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:6,代码来源:InstrumentingCache.java


示例6: getMetrics

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
public CacheMetrics getMetrics()
{
    return metrics;
}
 
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:5,代码来源:InstrumentingCache.java


示例7: testKeyCacheClustered

import org.apache.cassandra.metrics.CacheMetrics; //导入依赖的package包/类
@Test
public void testKeyCacheClustered() throws Throwable
{
    String table = createTable("CREATE TABLE %s ("
                               + commonColumnsDef
                               + "PRIMARY KEY ((part_key_a, part_key_b),clust_key_a,clust_key_b,clust_key_c))");
    insertData(table, null, true);
    clearCache();

    // query on partition key

    // 10 queries, each 50 result rows
    for (int i = 0; i < 10; i++)
    {
        assertEquals(50, execute("SELECT col_text FROM %s WHERE part_key_a = ? AND part_key_b = ?", i, Integer.toOctalString(i)).size());
    }

    CacheMetrics metrics = CacheService.instance.keyCache.getMetrics();
    long hits = metrics.hits.getCount();
    long requests = metrics.requests.getCount();
    assertEquals(0, hits);
    assertEquals(10, requests);

    // 10 queries, each 50 result rows
    for (int i = 0; i < 10; i++)
    {
        assertEquals(50, execute("SELECT col_text FROM %s WHERE part_key_a = ? AND part_key_b = ?", i, Integer.toOctalString(i)).size());
    }

    metrics = CacheService.instance.keyCache.getMetrics();
    hits = metrics.hits.getCount();
    requests = metrics.requests.getCount();
    assertEquals(10, hits);
    assertEquals(10 + 10, requests);

    // 100 queries - must get a hit in key-cache
    for (int i = 0; i < 10; i++)
    {
        for (int c = 0; c < 10; c++)
        {
            assertRows(execute("SELECT col_text, col_long FROM %s WHERE part_key_a = ? AND part_key_b = ? and clust_key_a = ?", i, Integer.toOctalString(i), c),
                       new Object[]{ String.valueOf(i) + '-' + String.valueOf(c), (long) c });
        }
    }

    metrics = CacheService.instance.keyCache.getMetrics();
    hits = metrics.hits.getCount();
    requests = metrics.requests.getCount();
    assertEquals(10 + 100, hits);
    assertEquals(20 + 100, requests);

    // 5000 queries - first 10 partitions already in key cache
    for (int i = 0; i < 100; i++)
    {
        for (int c = 0; c < 50; c++)
        {
            assertRows(execute("SELECT col_text, col_long FROM %s WHERE part_key_a = ? AND part_key_b = ? and clust_key_a = ?", i, Integer.toOctalString(i), c),
                       new Object[]{ String.valueOf(i) + '-' + String.valueOf(c), (long) c });
        }
    }

    hits = metrics.hits.getCount();
    requests = metrics.requests.getCount();
    assertEquals(110 + 4910, hits);
    assertEquals(120 + 5500, requests);
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:67,代码来源:KeyCacheCqlTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HTTPServer类代码示例发布时间:2022-05-22
下一篇:
Java CompilationUnit类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap