简体   繁体   English

如何从Coherence缓存中获取统计信息?

[英]How can I get statistics back from a Coherence cache?

I'm looking into Oracle Coherence for a client, and one of the things they are interested in is getting statistical information back from it to understand usage patterns etc. 我正在研究Oracle Coherence的客户端,他们感兴趣的一件事就是从中获取统计信息以了解使用模式等。

I know I can get some information from JMX, however there is also a CacheStatistics interface provided which I'd like to get data from. 我知道我可以从JMX获得一些信息,但是我还提供了一个CacheStatistics接口,我想从中获取数据。 However I can't see how I should go from having a cache object to getting its statistics. 但是,我无法看到如何从缓存对象获取其统计信息。

The code below is my poc implementation, and I can use the 'cache' object to put and get values from the cache, is there a way to link from the cache to the associated statistics? 下面的代码是我的poc实现,我可以使用'cache'对象来放置和获取缓存中的值,有没有办法从缓存链接到相关的统计信息? I guess I'm missing something simple somewhere... 我想我在某处遗漏了一些简单的东西......

    NamedCache cache = CacheFactory.getCache(cacheName);
    if(cache.isActive()){
            //Wrong because there's no link to the cache..
        SimpleCacheStatistics scs = new SimpleCacheStatistics();

        long hits = scs.getCacheHits();
        System.out.println("Cache hits:" +hits+"\n   : "+scs.toString());
    }

If the cache is a nearcache, then you can do the following.Also check the API to get backcache to see its statistics. 如果缓存是nearcache,那么您可以执行以下操作。还要检查API以获取后台缓存以查看其统计信息。

if (cache instanceof NearCache) {
    System.out.println("\tstatistics :" + ((LocalCache)((NearCache)cache).getFrontMap()).getCacheStatistics());
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM