Problem with multithreadeding in Java

Allexandre Sampaio allexandresss at gmail.com
Sat Apr 15 08:37:29 EDT 2017


Hi Alex, the code bellow is used to set up the Riak Client (if no one is
already started) or share the client with the threads.

 public RiakClient getDB() throws UnknownHostException {
        if (client == null) {
            client = RiakClient.newClient("localhost");
        }
        return client;
    }

According to the Java library's documentation on GitHub, the object
returned as a client could be used by multiple threads...
The class where I'm doing this is a singleton class, in a facade model.

Att.,

*Allexandre Sampaio*
*Sistemas de Informação - IFBA*
*Vitória da Conquista - BA*
*(77) 99964 3521*

2017-04-14 22:13 GMT-03:00 Alex Moore <amoore at basho.com>:

> Hi Allexandre,
>
> Could you share your code for setting up the RiakNode/RiakCluster/RiakClient
> objects on the Java side, and how you are sharing them amongst your worker
> threads?
>
> Thanks,
> Alex
> Clients Team Lead
>
> On Thu, Apr 13, 2017 at 6:09 PM, Allexandre Sampaio <
> allexandresss at gmail.com> wrote:
>
>> Hi, I'm using Riak TS in a multithreaded application, running on an
>> Ubuntu 16.04 server, for a college project. The library I'm using is
>> riak-client-2.1.1, with all of its dependencies.
>> The problem starts when I try to set more than some dozens threads, so
>> the Riak service starts to refuse the connection and throw errors.
>> I've checked and all the threads are using the same client (that is
>> thread safe, according to its docs).
>> I also tried to change the riak conf file to allow the maximum of threads
>> (1024), but it didn't change nothing...
>>
>> Need help.
>> Thanks!
>>
>> Att.,
>> *Allexandre Sampaio*
>> *Sistemas de Informação - IFBA*
>>
>> *Vitória da Conquista - BA, Brasil*
>> *(77) 99964 3521*
>>
>> _______________________________________________
>> riak-users mailing list
>> riak-users at lists.basho.com
>> http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.basho.com/pipermail/riak-users_lists.basho.com/attachments/20170415/1468cbf2/attachment-0002.html>


More information about the riak-users mailing list