You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "NealSun96 (via GitHub)" <gi...@apache.org> on 2023/01/30 18:54:42 UTC
[GitHub] [helix] NealSun96 opened a new pull request, #2357: Enable MSDS auto refresh for DedicatedZkClient
NealSun96 opened a new pull request, #2357:
URL: https://github.com/apache/helix/pull/2357
### Issues
- [x] My PR addresses the following Helix issues and references them in the PR description:
Fixes #2356
### Description
- [ ] Here are some details about my PR, including screenshots of any UI changes:
1. DedicatedZkClient now auto refreshes MSDS when the sharding key is missing, just like FederatedZkClient.
2. Since two classes both auto refreshes MSDS, the throttling logic has been moved to the RoutingDataManager layer, with a new API added that supports throttling; the old API remains for backward compatibility purpose.
3. The class level synchronization in FederatedZkClient is deemed unnecessary after reviewing.
### Tests
- [x] The following tests are written for this issue:
TestDedicatedZkClient
- The following is the result of the "mvn test" command on the appropriate module:
(If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
### Changes that Break Backward Compatibility (Optional)
- My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
### Documentation (Optional)
- In case of new functionality, my PR adds documentation in the following wiki page:
(Link the GitHub wiki you added)
### Commits
- My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
1. Subject is separated from body by a blank line
1. Subject is limited to 50 characters (not including Jira issue reference)
1. Subject does not end with a period
1. Subject uses the imperative mood ("add", not "adding")
1. Body wraps at 72 characters
1. Body explains "what" and "why", not "how"
### Code Quality
- My diff has been formatted using helix-style.xml
(helix-style-intellij.xml if IntelliJ IDE is used)
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on PR #2357:
URL: https://github.com/apache/helix/pull/2357#issuecomment-1423024888
This PR is ready to merge, approved by @desaikomal, @qqu0127, and @junkaixue
Commit message:
Enable MSDS auto refresh for DedicatedZkClient
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] qqu0127 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093857837
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,63 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
Review Comment:
yes
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] qqu0127 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093766631
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -183,6 +199,25 @@ public long getLastResetTimestamp() {
return _lastResetTimestamp;
}
+ /**
+ * Resolves the routing data update interval value from System Properties.
+ */
+ public void parseRoutingDataUpdateInterval() {
Review Comment:
Does this have to be public? I thought this is only used during construction?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,63 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
Review Comment:
nit: I think usually we put additional message to the exception before re-throw. We probably don't need the error log that way.
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,63 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e1) {
+ synchronized (this) {
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
Review Comment:
For my own understanding, what and how is the difference between the first and second check?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -59,6 +61,9 @@ public class RoutingDataManager {
// Tracks the time at which reset() was called last. Used to throttle reset()
private volatile long _lastResetTimestamp;
+ // Interval value used to throttle reset()
+ private long _routingDataUpdateInterval;
+
// Singleton instance
private static RoutingDataManager _instance;
Review Comment:
not directly related to your PR, but this should have been a volatile in the first place.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] junkaixue commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "junkaixue (via GitHub)" <gi...@apache.org>.
junkaixue commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1091047750
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,67 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e1) {
+ synchronized (this) {
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e2) {
+ // Try 1) Refresh MetadataStoreRoutingData from RoutingDataManager
+ // This is an in-memory refresh from the Singleton RoutingDataManager - other
+ // ZkClient objects may have triggered a cache refresh, so we first update the
+ // in-memory reference. This refresh only affects this object/thread, so we synchronize
+ // on "this".
+ _metadataStoreRoutingData =
+ RealmAwareZkClient.getMetadataStoreRoutingData(_connectionConfig);
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e3) {
+ synchronized (this) {
Review Comment:
Reentrant locking usually applies to the logic spread around different code paths.
In the same piece of code why we need to reacquire the lock again?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -183,6 +195,23 @@ public long getLastResetTimestamp() {
return _lastResetTimestamp;
}
+ /**
+ * Resolves the routing data update interval value from System Properties.
+ */
+ private static long getRoutingDataUpdateInterval() {
+ long routingDataUpdateInterval;
+ try {
+ routingDataUpdateInterval =
+ Long.parseLong(System.getProperty(RoutingSystemPropertyKeys.ROUTING_DATA_UPDATE_INTERVAL_MS));
+ if (routingDataUpdateInterval < 0) {
+ routingDataUpdateInterval = RoutingDataConstants.DEFAULT_ROUTING_DATA_UPDATE_INTERVAL_MS;
+ }
+ } catch (NumberFormatException e) {
+ routingDataUpdateInterval = RoutingDataConstants.DEFAULT_ROUTING_DATA_UPDATE_INTERVAL_MS;
Review Comment:
Logs?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,67 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
Review Comment:
Do we need to do it three times? I know this could be similar to safety check logic. But why not just synchronize this on the method and check twice?
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -175,6 +178,15 @@ public synchronized void reset() {
_lastResetTimestamp = System.currentTimeMillis();
}
+ public synchronized void reset(boolean enforceThrottle) {
Review Comment:
Do you mean forceReset? enforceThrottle is hard to understand.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] qqu0127 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093833585
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -59,6 +61,9 @@ public class RoutingDataManager {
// Tracks the time at which reset() was called last. Used to throttle reset()
private volatile long _lastResetTimestamp;
+ // Interval value used to throttle reset()
+ private long _routingDataUpdateInterval;
+
// Singleton instance
private static RoutingDataManager _instance;
Review Comment:
There is something tricky JMM does on instruction reordering for optimization, there is also impact from register caching. In short, volatile ensures all threads always read from the main memory thus ensure the visibility. https://en.wikipedia.org/wiki/Double-checked_locking#Usage_in_Java
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093813231
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,63 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e1) {
+ synchronized (this) {
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
Review Comment:
The first check is the initial read attempt. If it fails we enter the update logic.
The second check is because another thread might have updated the in-memory cache, so we check again.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] qqu0127 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "qqu0127 (via GitHub)" <gi...@apache.org>.
qqu0127 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093857449
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -183,6 +199,25 @@ public long getLastResetTimestamp() {
return _lastResetTimestamp;
}
+ /**
+ * Resolves the routing data update interval value from System Properties.
+ */
+ public void parseRoutingDataUpdateInterval() {
Review Comment:
Got it, if there is a need for runtime adjustment (in real use case), it might be better as a simple setter. We can separate out the config reading part.
No strong preference though.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093808509
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -59,6 +61,9 @@ public class RoutingDataManager {
// Tracks the time at which reset() was called last. Used to throttle reset()
private volatile long _lastResetTimestamp;
+ // Interval value used to throttle reset()
+ private long _routingDataUpdateInterval;
+
// Singleton instance
private static RoutingDataManager _instance;
Review Comment:
I'm curious, why does singleton pattern need volatile again? Once the object is created, the reference will never be changed, right?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1092340500
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,67 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
Review Comment:
This line is the initial lookup that always happens, and the next 2 times are for in-memory lookups and HTTP/ZK lookups respectively.
I think the current approach is acceptable, and the only problem is with the double synchronized blocks. I will combine them into 1.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] desaikomal commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "desaikomal (via GitHub)" <gi...@apache.org>.
desaikomal commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1094631966
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -166,8 +172,18 @@ public MetadataStoreRoutingData getMetadataStoreRoutingData(
/**
* Clears the statically-cached routing data and private fields.
+ * @param isForcedReset - if true, ignore throttle settings
*/
- public synchronized void reset() {
+ public synchronized void reset(boolean isForcedReset) {
Review Comment:
all the methods in this change are calling with "true". and pure reset() is private. so do we really have a usecase with "false" ?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1097906322
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -59,6 +61,9 @@ public class RoutingDataManager {
// Tracks the time at which reset() was called last. Used to throttle reset()
private volatile long _lastResetTimestamp;
+ // Interval value used to throttle reset()
+ private long _routingDataUpdateInterval;
+
// Singleton instance
private static RoutingDataManager _instance;
Review Comment:
Thanks for the explanation! Added volatile for thread safety.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1097908114
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -183,6 +199,25 @@ public long getLastResetTimestamp() {
return _lastResetTimestamp;
}
+ /**
+ * Resolves the routing data update interval value from System Properties.
+ */
+ public void parseRoutingDataUpdateInterval() {
Review Comment:
The parsing logic is universal, though. I will keep it the current way; the other approaches don't seem clean.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1091278958
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -175,6 +178,15 @@ public synchronized void reset() {
_lastResetTimestamp = System.currentTimeMillis();
}
+ public synchronized void reset(boolean enforceThrottle) {
Review Comment:
This one is "resetWithThrottle", the above one is technically "forceReset". I didn't want to change it and inflate PR size, but I'm leaning towards changing it now. I can
1. Change it to be `reset(false)` and make `reset()` private;
2. or change it to be `forceReset()`.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093809255
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -183,6 +199,25 @@ public long getLastResetTimestamp() {
return _lastResetTimestamp;
}
+ /**
+ * Resolves the routing data update interval value from System Properties.
+ */
+ public void parseRoutingDataUpdateInterval() {
Review Comment:
It's public for testing purpose; and technically, this function is a setter (there may be necessity to refresh the interval). Open for suggestions.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1093812812
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,63 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
Review Comment:
As in `MultiZkException(newMessage, e)`?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1097909472
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/routing/RoutingDataManager.java:
##########
@@ -166,8 +172,18 @@ public MetadataStoreRoutingData getMetadataStoreRoutingData(
/**
* Clears the statically-cached routing data and private fields.
+ * @param isForcedReset - if true, ignore throttle settings
*/
- public synchronized void reset() {
+ public synchronized void reset(boolean isForcedReset) {
Review Comment:
reset(false) is used in FederatedZkClient and DedicatedZkClient.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 merged pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 merged PR #2357:
URL: https://github.com/apache/helix/pull/2357
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org
[GitHub] [helix] NealSun96 commented on a diff in pull request #2357: Enable MSDS auto refresh for DedicatedZkClient
Posted by "NealSun96 (via GitHub)" <gi...@apache.org>.
NealSun96 commented on code in PR #2357:
URL: https://github.com/apache/helix/pull/2357#discussion_r1092340791
##########
zookeeper-api/src/main/java/org/apache/helix/zookeeper/impl/client/DedicatedZkClient.java:
##########
@@ -582,4 +588,67 @@ private void checkIfPathContainsShardingKey(String path) {
+ " does not have a valid sharding key or its ZK sharding key is not found in the cached routing data!");
}
}
+
+ private String getZkRealm(String path) {
+ if (_routingDataUpdateOnCacheMissEnabled) {
+ try {
+ return updateRoutingDataOnCacheMiss(path);
+ } catch (InvalidRoutingDataException e) {
+ LOG.error(
+ "DedicatedZkClient::getZkRealm: Failed to update routing data due to invalid routing "
+ + "data!", e);
+ throw new MultiZkException(e);
+ }
+ }
+ return _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ }
+
+ /**
+ * Perform a 2-tier routing data cache update:
+ * 1. Do an in-memory update from the singleton RoutingDataManager
+ * 2. Do an I/O based read from the routing data source by resetting RoutingDataManager
+ * @param path
+ * @return
+ * @throws InvalidRoutingDataException
+ */
+ private String updateRoutingDataOnCacheMiss(String path) throws InvalidRoutingDataException {
+ String zkRealm;
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e1) {
+ synchronized (this) {
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e2) {
+ // Try 1) Refresh MetadataStoreRoutingData from RoutingDataManager
+ // This is an in-memory refresh from the Singleton RoutingDataManager - other
+ // ZkClient objects may have triggered a cache refresh, so we first update the
+ // in-memory reference. This refresh only affects this object/thread, so we synchronize
+ // on "this".
+ _metadataStoreRoutingData =
+ RealmAwareZkClient.getMetadataStoreRoutingData(_connectionConfig);
+ try {
+ zkRealm = _metadataStoreRoutingData.getMetadataStoreRealm(path);
+ } catch (NoSuchElementException e3) {
+ synchronized (this) {
Review Comment:
This synchronized should be removed.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org