Near cache configuration not recognized on clients

373 views
Skip to first unread message

Ulf Gitschthaler

unread,
Jun 10, 2014, 7:05:38 AM6/10/14
to haze...@googlegroups.com
Hi, 

I am currently working on a server-client setup. Hazelcast will be used as a distributed cache for hibernate second level caching. Basically the setup seems to work on my local maschine (having one separated cluster with two servers, a management console and a client that connects to the cluster). Cache entities are correctly displayed in the mancenter but my near cache configuration on the client is completely ignored. 

My configuration looks as following: 

1.) hazelcast on the servier side (stick with default except for management center)

~/Downloads/hazelcast-3.2.2/bin$ diff hazelcast.xml hazelcast.xml.bak
25c25
<     <management-center enabled="true">http://192.168.71.128:9090/mancenter</management-center>
---
>     <management-center enabled="false">http://localhost:8080/mancenter</management-center>

2.) hibernate.cfg.xml has following properties

<property name="hibernate.cache.use_query_cache">true</property>
<property name="hibernate.cache.region.factory_class">com.hazelcast.hibernate.HazelcastCacheRegionFactory</property>
<property name="hibernate.cache.hazelcast.use_native_client">true</property>
<property name="hibernate.cache.hazelcast.native_client_address">127.0.0.1</property>
<property name="hibernate.cache.hazelcast.configuration_file_path">hazelcast-client-me.xml</property>
<property name="hibernate.cache.hazelcast.native_client_group">dev</property>
<property name="hibernate.cache.hazelcast.native_client_password">dev-pass</property>

3.) hazelcast-client-me.xml 

<hazelcast-client xsi:schemaLocation="http://www.hazelcast.com/schema/client-config
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>dev</name>
        <password>dev-pass</password>
    </group>
    <network>
        <cluster-members>
        <address>192.168.71.128:5701</address>
            <address>192.168.71.128:5702</address>
        </cluster-members>
        <smart-routing>true</smart-routing>
        <redo-operation>true</redo-operation>
    </network>
    <near-cache name="com.helloworld.entities.HelloWorld">
        <max-size>2000</max-size>
        <time-to-live-seconds>100</time-to-live-seconds>
        <max-idle-seconds>100</max-idle-seconds>
        <eviction-policy>LFU</eviction-policy>
        <invalidate-on-change>true</invalidate-on-change>
        <in-memory-format>OBJECT</in-memory-format>
    </near-cache>

    <executor-pool-size>40</executor-pool-size>
</hazelcast-client>

The entity (HelloWorld) is displayed in the mancenter but the near cache data table stays empty all the time. 

I am, not sure how the near cache is connected to the entites. My assumption was, that it's done via the name attribute inside the near-cache tag but it does not work as expected. 

Thanks in advance for any hints, examples etc.!


Enes Akar

unread,
Jun 10, 2014, 7:16:13 AM6/10/14
to haze...@googlegroups.com
Hi;

The near cache stats you see in management center are the near cache configured in server side

Stats for client-side near caches are planned feature for management center but not yet implemented.


--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hazelcast+...@googlegroups.com.
To post to this group, send email to haze...@googlegroups.com.
Visit this group at http://groups.google.com/group/hazelcast.
To view this discussion on the web visit https://groups.google.com/d/msgid/hazelcast/6eff662d-3dad-46dc-875e-c62031ded850%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Enes Akar
Director of Engineering
Mahir İz Cad. No:35, Altunizade, İstanbul

Ulf Gitschthaler

unread,
Jun 10, 2014, 7:22:06 AM6/10/14
to haze...@googlegroups.com
Hi, 

Thx for the fast answer! Is my assumption valid that the near cache is configured using the entities class names, like: 

<near-cache name="com.helloworld.entities.User">...</near-cache>
<near-cache name="com.helloworld.entities.Email">...</near-cache>


How can I quickyl check if near cache is enabled for the given entities and measure cache statistics etc?? 

Enes Akar

unread,
Jun 10, 2014, 8:13:54 AM6/10/14
to haze...@googlegroups.com
you can reach near cache stats from client:
  NearCacheStats stats = map.getLocalMapStats().getNearCacheStats();

Just the map's name is enough. The same name you have used for configuring the map on server side.

<near-cache name="MapName">...</near-cache>




For more options, visit https://groups.google.com/d/optout.

Ulf Gitschthaler

unread,
Jun 10, 2014, 8:41:35 AM6/10/14
to haze...@googlegroups.com
Ok, just to get the whole picture for my setup: 

1.) I have to define the maps on the server side. As I read in the documentation, one takes normally the full entity class name as map name 
2.) For the client side I have to pick the entities using the same name as the maps in 1.) for the near cache configuration

Regarding the near cache statistics. JMX is only available if we go for the Enterprise licnese? 

chuckhut...@gmail.com

unread,
Sep 13, 2016, 2:57:50 AM9/13/16
to Hazelcast

I have a question about the Hazelcast near cache statistics.  If the near cache is configured on the Hazelcast client, will those statistics be reflect/computed/aggregated in any way in the Hazelcast management center?

 

The reason I am asking this is all of our near cache statistics are zero – entries, entry memory, hits, misses.  The ratio is NAN.  And the documentation is not very clear with respect to this so I am not sure if I misconfigured something or if this behavior is expected.

 

Your post on 6/10/2014 leads me to believe that this capability is not functioning yet  - https://groups.google.com/forum/#!msg/hazelcast/tG89BAU56pA/BGfPg2FSzE8J

 

The near cache stats you see in management center are the near cache configured in server side

 

Stats for client-side near caches are planned feature for management center but not yet implemented

 

Thanks in advance for your help.

Reply all
Reply to author
Forward
0 new messages