Вопрос

I'm using Hector to read from Cassandra DB.

I would like to know if Hector's queries objects are thread safe, specifically I would like to know if the following are thread safe:

  • SliceQuery
  • StringSerializer.get()

I create my query using this code:

StringSerializer stringSerializer = StringSerializer.get();
query = HFactory.createSliceQuery(connectionEvent.getKeyspace(), stringSerializer, stringSerializer, stringSerializer);

Can I take this code to the class level, assuming it is thread safe and then use it in the class methods (which should be thread safe for a multi-threaded environment)?

I have found no documentation that relates to this subject. In case those objects are not thread safe I will make sure their initialization takes place inside the methods.

Это было полезно?

Решение

The StringSerializer is thread safe hence can be put in class level, the query on the other hand isn't hence needs to be created again during each request.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top