Hibernate - one Hazelcast Instance per Database?

91 views
Skip to first unread message

Andreas Fey

unread,
Jan 12, 2011, 10:02:29 AM1/12/11
to Hazelcast
Hi all,

I set up Hazelcast as 2nd level cache for hibernate, and after some
tries it worked. What I do not understand is, why is Hazelcast
creating one Instance per Database? I have four databases in my
application, leading to five Hazelcast instances (4 + one backup, I
think), all one the same machine; I would claim that this does not
help to improve performance, rather decreasing it, because the
partitioning changes all the time, leading to - in my eyes - senseless
object de-/serializations between those instances.

Thanks for your help or ideas.

Andreas

Mehmet Dogan

unread,
Jan 12, 2011, 10:24:47 AM1/12/11
to haze...@googlegroups.com
Hi,

By saying 4 databases do you mean 4 Hibernate session factories? 

If you do not configure "hibernate.cache.provider_configuration_file_resource_path" variable then
Hazelcast cache provider will use default (and single) instance for all. But if you set that parameter it will always create new instance per session factory.
All instance lifecycle is managed by Hibernate and created Hazelcast instance has no idea if there is another instance started or they share same configuration or not.
Maybe we can think a smooth way to support one instance for multiple session factories.

@mm

--
You received this message because you are subscribed to the Google Groups "Hazelcast" group.
To post to this group, send email to haze...@googlegroups.com.
To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/hazelcast?hl=en.


Mehmet Dogan

unread,
Jan 12, 2011, 11:12:09 AM1/12/11
to haze...@googlegroups.com
And to do custom configuration for Hazelcast, you can use single hazelcast.xml. Just drop xml file in your root of classpath. 
No need to specify hibernate.cache.provider_configuration_file_resource_path explicitly.

@mm

Andreas Fey

unread,
Jan 13, 2011, 3:21:56 AM1/13/11
to Hazelcast
Dear all,

I have no "hibernate.cache.provider_configuration_file_resource_path"
setting, and I am using a custom hazelcast.xml file. What I meant was
4 different hibernate instances, each using one own database.

Any other ideas?

Best,
Andreas

Mehmet Dogan

unread,
Jan 13, 2011, 4:01:43 AM1/13/11
to haze...@googlegroups.com
Just to verify if what I understand is what you mean or not;
  • You are using single hazelcast.xml.
  • Your app has 4 hibernate instances.
  • You get 5 hazelcast instances.
And some questions to clarify case;
  1. What version of hazelcast (and hibernate) are you using?
  2. Are we talking about a single app or multiple apps (... multiple webapps in same server/jvm)? Are there more than one classloader dealing with hibernate and hazelcast classes?
  3. Where do you see 5 hazelcast instances? In app logs or hz monitor or .. ?

@mm

Andreas Fey

unread,
Jan 13, 2011, 4:28:16 AM1/13/11
to Hazelcast
Hi,


On 13 Jan., 10:01, Mehmet Dogan <mehmetdog...@gmail.com> wrote:
> Just to verify if what I understand is what you mean or not;
>
>    - You are using single hazelcast.xml.
>    - Your app has 4 hibernate instances.
>    - You get 5 hazelcast instances.
>

correct.

> And some questions to clarify case;
>
>    1. What version of hazelcast (and hibernate) are you using?
Hazelcast-1.9
Hibernate-3.6
>    2. Are we talking about a single app or multiple apps (... multiple
>    webapps in same server/jvm)? Are there more than one classloader dealing
>    with hibernate and hazelcast classes?
It's only one web application
>    3. Where do you see 5 hazelcast instances? In app logs or hz monitor or
>    .. ?
During tomcat start in the log:
Members [5] {
Member [192.168.100.38:5704]
Member [192.168.100.38:5705] this
Member [192.168.100.38:5702]
Member [192.168.100.38:5703]
Member [192.168.100.38:5701]
}
or in the cluster manager.




>
> @mm
>
> On Thu, Jan 13, 2011 at 10:21, Andreas Fey
> <andreas.fey....@googlemail.com>wrote:
> > hazelcast+...@googlegroups.com<hazelcast%2Bunsu...@googlegroups.com>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/hazelcast?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Hazelcast" group.
> > To post to this group, send email to haze...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > hazelcast+...@googlegroups.com<hazelcast%2Bunsu...@googlegroups.com>
> > .

Mehmet Dogan

unread,
Jan 13, 2011, 8:04:10 AM1/13/11
to haze...@googlegroups.com
Alright, got the point, you are on version 1.9 and this is a problem with that build.
If you can switch, just try version 1.9.1.  
After version 1.9.1 Hazelcast-Hibernate provider uses Hazelcast.getDefaultInstance()  if a custom hazelcast configuration is not defined.
Prior to 1.9.1 provider always creates a new instance.

@mm

To unsubscribe from this group, send email to hazelcast+...@googlegroups.com.

Andreas Fey

unread,
Jan 13, 2011, 10:48:44 AM1/13/11
to Hazelcast
OK, this looks really better! One (new) thing remains; when I start
the Cluster Monitor (version 1.9.1, too), i get the following error
during connection tries:

SCHWERWIEGEND: Exception while dispatching incoming RPC call
com.google.gwt.user.client.rpc.SerializationException: Type
'com.hazelcast.monitor.client.ClusterView' was not assignable to
'com.google.gwt.user.client.rpc.IsSerializable' and did not have a
custom field serializer.For security purposes, this type will not be
serialized.: instance =
com.hazelcast.monitor.client.ClusterView@607dcb35
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serialize(ServerSerializationStreamWriter.java:
610)
at
com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamWriter.writeObject(AbstractSerializationStreamWriter.java:
129)
at com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter
$ValueWriter$8.write(ServerSerializationStreamWriter.java:152)
at
com.google.gwt.user.server.rpc.impl.ServerSerializationStreamWriter.serializeValue(ServerSerializationStreamWriter.java:
534)
at com.google.gwt.user.server.rpc.RPC.encodeResponse(RPC.java:609)
at
com.google.gwt.user.server.rpc.RPC.encodeResponseForSuccess(RPC.java:
467)
at
com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:
564)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:
188)
at
com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:
224)
at
com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:
62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:
290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:
206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:
233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:
191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:
127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:
102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:
109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:
298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:
857)
at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:
489)
at java.lang.Thread.run(Thread.java:680)

Andreas Fey

unread,
Jan 13, 2011, 11:03:19 AM1/13/11
to Hazelcast

Mehmet Dogan

unread,
Jan 13, 2011, 11:24:40 AM1/13/11
to haze...@googlegroups.com
AFAIK, after gwt version 1.5 there is no need to implement "com.google.gwt.user.client.rpc.IsSerializable", "java.io.Serializable" is enough.
I just tried 1.9.1 monitor app in tomcat 5.5 and worked without error.
And hazelcast-monitor-1.9.1.war has version 2.0. Is there any other gwt library in your tomcat classpath?

@mm

Andreas Fey

unread,
Jan 14, 2011, 3:43:01 AM1/14/11
to Hazelcast
You are right, it works in standalone tomcat; I tried it with the
Tomcat Server Eclipse Plugin first, hence the error.

Great tool guys, I hope we will get nice perfomance results ;-)
Reply all
Reply to author
Forward
0 new messages