Sameer,

It is mainly to guard for concurrent access for interactive queries:

https://kafka.apache.org/0110/documentation/streams/developer-guide#streams_interactive_queries

In Kafka Streams, we allow users to independently query the running state
stores in real-time in their own caller thread while the application's
thread is continuously updating these stores, and hence the synchronization.


Guozhang


On Sun, Aug 13, 2017 at 10:24 PM, Sameer Kumar <sam.kum.w...@gmail.com>
wrote:

> Hi,
>
> I was inspecting RocksDBStore and I saw get and put methods being
> synchronized.
>
> Are there any issues in RocksDB due to which we have used it. Could someone
> please enlighten more on this.
>
>  @Override
>     public synchronized V get(K key) {
>         validateStoreOpen();
>         byte[] byteValue = getInternal(serdes.rawKey(key));
>         if (byteValue == null) {
>             return null;
>         } else {
>             return serdes.valueFrom(byteValue);
>         }
>     }
>
>     @SuppressWarnings("unchecked")
>     @Override
>     public synchronized void put(K key, V value) {
>         validateStoreOpen();
>         byte[] rawKey = serdes.rawKey(key);
>         byte[] rawValue = serdes.rawValue(value);
>         putInternal(rawKey, rawValue);
>     }
>
> -Sameer.
>



-- 
-- Guozhang

Reply via email to