-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gateway - Add GatewayCurrentStateCache for gateway service #2895
Gateway - Add GatewayCurrentStateCache for gateway service #2895
Conversation
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Outdated
Show resolved
Hide resolved
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Outdated
Show resolved
Hide resolved
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Outdated
Show resolved
Hide resolved
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Outdated
Show resolved
Hide resolved
f8f9c6a
to
7acfcbb
Compare
7acfcbb
to
45312d1
Compare
currentMap.get(instance).entrySet().stream().forEach(e -> { | ||
if (currentState.get(e.getKey()) != null) { | ||
e.setValue(currentState.get(e.getKey())); | ||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why update the entry of the diff map? That's tmp object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are updating the currentMap
, with diff map value.
bd7865d
to
bc8698f
Compare
helix-gateway/src/main/java/org/apache/helix/gateway/service/GatewayServiceManager.java
Outdated
Show resolved
Hide resolved
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Outdated
Show resolved
Hide resolved
public void updateCacheWithCurrentStateDiff(Map<String, Map<String, Map<String, String>>> currentStateDiff) { | ||
for (String instance : currentStateDiff.keySet()) { | ||
Map<String, Map<String, String>> currentStateDiffMap = currentStateDiff.get(instance); | ||
_currentStateMap.computeIfAbsent(instance, k -> new ShardStateMap(new HashMap<>())) | ||
.updateShardStateMapWithDiff(currentStateDiffMap); | ||
} | ||
} | ||
|
||
/** | ||
* Update the target state with the changed target state maps. | ||
* All existing target states remains the same | ||
* @param targetStateChangeMap | ||
*/ | ||
public void updateTargetStateWithDiff(String instance, Map<String, Map<String, String>> targetStateChangeMap) { | ||
_targetStateMap.computeIfAbsent(instance, k -> new ShardStateMap(new HashMap<>())) | ||
.updateShardStateMapWithDiff(targetStateChangeMap); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need 2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They update different maps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or let's combine? Have the second one as a private wrapper function. So the first one can do:
for (xxxxx) {
private func on each instance
}
Because I think the logic of codes are almost same.
bc8698f
to
39325a2
Compare
public void updateCacheWithCurrentStateDiff(Map<String, Map<String, Map<String, String>>> currentStateDiff) { | ||
for (String instance : currentStateDiff.keySet()) { | ||
Map<String, Map<String, String>> currentStateDiffMap = currentStateDiff.get(instance); | ||
_currentStateMap.computeIfAbsent(instance, k -> new ShardStateMap(new HashMap<>())) | ||
.updateShardStateMapWithDiff(currentStateDiffMap); | ||
} | ||
} | ||
|
||
/** | ||
* Update the target state with the changed target state maps. | ||
* All existing target states remains the same | ||
* @param targetStateChangeMap | ||
*/ | ||
public void updateTargetStateWithDiff(String instance, Map<String, Map<String, String>> targetStateChangeMap) { | ||
_targetStateMap.computeIfAbsent(instance, k -> new ShardStateMap(new HashMap<>())) | ||
.updateShardStateMapWithDiff(targetStateChangeMap); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or let's combine? Have the second one as a private wrapper function. So the first one can do:
for (xxxxx) {
private func on each instance
}
Because I think the logic of codes are almost same.
helix-gateway/src/main/java/org/apache/helix/gateway/util/GatewayCurrentStateCache.java
Show resolved
Hide resolved
This change is ready to be merged. Approved by @junkaixue This pull request introduces a caching mechanism for the Helix Gateway service. The main changes include: Addition of a new GatewayCurrentStateCache class in GatewayCurrentStateCache.java, which manages caching of current and target states for instances in a cluster. |
This pull request introduces a caching mechanism for the Helix Gateway service. The main changes include: Addition of a new GatewayCurrentStateCache class in GatewayCurrentStateCache.java, which manages caching of current and target states for instances in a cluster.
This pull request introduces a caching mechanism for the Helix Gateway service. The main changes include: Addition of a new GatewayCurrentStateCache class in GatewayCurrentStateCache.java, which manages caching of current and target states for instances in a cluster.
This pull request introduces a caching mechanism for the Helix Gateway service. The main changes include: Addition of a new GatewayCurrentStateCache class in GatewayCurrentStateCache.java, which manages caching of current and target states for instances in a cluster.
Issues
#2821
Description
This pull request introduces a caching mechanism for the Helix Gateway service. The main changes include:
Addition of a new
GatewayCurrentStateCache
class inGatewayCurrentStateCache.java
, which manages caching of current and target states for instances in a cluster.Modification of
GatewayServiceManager.java
to incorporate the new caching functionality:_currentStateCacheMap
is added to storeGatewayCurrentStateCache
objects for each cluster.getCurrentStateCache(String clusterName)
is introduced to retrieve or create a cache for a given cluster.Test
A new test class
TestGatewayCurrentStateCache.java
has been added with the following tests:Changes that Break Backward Compatibility
N/A
Documentation
N/A
Created with Palmier