lakshmi-manasa-g commented on a change in pull request #938: SAMZA-1531: Support run.id in standalone for batch processing. URL: https://github.com/apache/samza/pull/938#discussion_r264494088
########## File path: samza-core/src/main/java/org/apache/samza/zk/ZkDistributedDataAccess.java ########## @@ -0,0 +1,61 @@ +package org.apache.samza.zk; + +import org.apache.samza.coordinator.DistributedDataAccess; +import org.apache.samza.coordinator.DistributedDataWatcher; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class ZkDistributedDataAccess implements DistributedDataAccess { + public static final Logger LOG = LoggerFactory.getLogger(ZkDistributedDataAccess.class); + private final ZkUtils zkUtils; + private final ZkKeyBuilder keyBuilder; + private DistributedDataWatcher watcher; + + public ZkDistributedDataAccess(ZkUtils zkUtils) { + if (zkUtils == null) { + throw new RuntimeException("Cannot operate ZkDistributedDataAccess without ZkUtils."); + } + this.zkUtils = zkUtils; + this.keyBuilder = zkUtils.getKeyBuilder(); + } + + public Object readData(String key, DistributedDataWatcher watcher) { Review comment: Actually, a watcher is specific to a key/path and hence can not be set in the constructor (as we do not know what the key will be). ZkDistributedDataAccess is used to provide access to (any/all) data in ZK and hence the constructor does not take in a key. here, I am not making in generic enough to use this class to access data for any number of keys. Updating this code to keep a map of <key,watcher> so that several keys could be accessed. However, the issue you mentioned would still be there.. as in for a key if a watcher is passed during readData and then a different watcher is passed in during writeData then it does get overwritten. I believe that is correct as we should associate a watcher with a key and not to the specific way (read vs write) the data at the key was accessed. I do not forsee a necessity for differentiating between read/write when watching the data. please let me know if you think otherwise. ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services