Question about RiakCluster - Java client - 2.x

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Question about RiakCluster - Java client - 2.x

Konstantin Kalin
I'm currently migrating Java client from 1.4 to 2.1 and I have a question about RiakCluster class.

We hide Riak Java API by our interface since we use multiple backends and Riak is one of them. 
Let's say I have two independent business activities that makes calls to Riak cluster. Both activities are executed within same Tomcat instance. Currently we use two RiakClient instances (1.4). Each activity initializes its own RiakClient. 
Since I do the migration I cannot decide. Would it have more sense to create a "singleton" object that will own RiakCluster instead of creating two instances? What should I consider as recommended approach? 

Thank you,
Konstantin.  

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Question about RiakCluster - Java client - 2.x

Alex Moore
Hi Konstantin,

The RiakClient class is reentrant and thread-safe, so you should be able to share it among the different workers. You may have to adjust the min / max connection settings to get the most performance, but that's relatively easy.   

One other thing to notice is RiakClient's cleanup() method, since you are working in a servlet / container environment. 

Thanks,
Alex

On Mon, Nov 21, 2016 at 3:49 PM, Konstantin Kalin <[hidden email]> wrote:
I'm currently migrating Java client from 1.4 to 2.1 and I have a question about RiakCluster class.

We hide Riak Java API by our interface since we use multiple backends and Riak is one of them. 
Let's say I have two independent business activities that makes calls to Riak cluster. Both activities are executed within same Tomcat instance. Currently we use two RiakClient instances (1.4). Each activity initializes its own RiakClient. 
Since I do the migration I cannot decide. Would it have more sense to create a "singleton" object that will own RiakCluster instead of creating two instances? What should I consider as recommended approach? 

Thank you,
Konstantin.  

_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com



_______________________________________________
riak-users mailing list
[hidden email]
http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
Loading...