PawasChhokra commented on a change in pull request #1008: SAMZA-2174: Throw a 
record too large exception for oversized records in changelog
URL: https://github.com/apache/samza/pull/1008#discussion_r308499129
 
 

 ##########
 File path: 
samza-kv/src/main/scala/org/apache/samza/storage/kv/BaseKeyValueStorageEngineFactory.scala
 ##########
 @@ -124,22 +129,46 @@ trait BaseKeyValueStorageEngineFactory[K, V] extends 
StorageEngineFactory[K, V]
       new LoggedStore(rawStore, changeLogSystemStreamPartition, collector, 
loggedStoreMetrics)
     }
 
-    // wrap with serialization
-    val serializedMetrics = new SerializedKeyValueStoreMetrics(storeName, 
registry)
-    val serialized = new SerializedKeyValueStore[K, V](maybeLoggedStore, 
keySerde, msgSerde, serializedMetrics)
+    var toBeAccessLoggedStore: KeyValueStore[K, V] = null
 
-    // maybe wrap with caching
-    val maybeCachedStore = if (enableCache) {
-      val cachedStoreMetrics = new CachedStoreMetrics(storeName, registry)
-      new CachedStore(serialized, cacheSize, batchSize, cachedStoreMetrics)
-    } else {
-      serialized
+    // If large messages are disallowed in config, then this creates a 
LargeMessageSafeKeyValueStore that throws a
+    // RecordTooLargeException when a large message is encountered.
+    if (disallowLargeMessages) {
+      // maybe wrap with caching
+      val maybeCachedStore = if (enableCache) {
+        createCachedStore(storeName, registry, maybeLoggedStore, cacheSize, 
batchSize)
+      } else {
+        maybeLoggedStore
+      }
+
+      // wrap with large message checking
+      val largeMessageSafeKeyValueStore = new 
LargeMessageSafeStore(maybeCachedStore, storeName, false, maxMessageSize)
+      // wrap with serialization
+      val serializedMetrics = new SerializedKeyValueStoreMetrics(storeName, 
registry)
+      toBeAccessLoggedStore = new SerializedKeyValueStore[K, 
V](largeMessageSafeKeyValueStore, keySerde, msgSerde, serializedMetrics)
+
+    }
+    else {
+      var toBeSerializedStore = maybeLoggedStore
 
 Review comment:
   Done.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to