Skip to content
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

Allow ambry server to update replica info in Helix InstanceConfig #1348

Merged
merged 3 commits into from
Jan 29, 2020

Conversation

jsjtzyy
Copy link
Contributor

@jsjtzyy jsjtzyy commented Dec 30, 2019

Once replica addition or removal is complete on particular datanode,
ambry server is supposed to update InstanceConfig in Helix to broadcast
the replica related changes. This PR introduced a new method that allows
participant to update its node info in cluster. It supports adding new
replica info or removing old replica info. For rollback purpose, we also
add a config to switch on/off update operation.

@jsjtzyy jsjtzyy self-assigned this Dec 30, 2019
@codecov-io
Copy link

codecov-io commented Dec 30, 2019

Codecov Report

Merging #1348 into master will increase coverage by 0.04%.
The diff coverage is 94.68%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #1348      +/-   ##
============================================
+ Coverage     71.98%   72.03%   +0.04%     
- Complexity     6680     6696      +16     
============================================
  Files           486      486              
  Lines         38070    38163      +93     
  Branches       4826     4843      +17     
============================================
+ Hits          27406    27490      +84     
- Misses         9354     9361       +7     
- Partials       1310     1312       +2
Impacted Files Coverage Δ Complexity Δ
...b.ambry.clustermap/StaticClusterAgentsFactory.java 31.57% <0%> (-0.86%) 4 <0> (ø)
...hub.ambry/clustermap/StateTransitionException.java 100% <100%> (ø) 2 <0> (ø) ⬇️
...java/com.github.ambry/config/ClusterMapConfig.java 100% <100%> (ø) 3 <0> (ø) ⬇️
...in/java/com.github.ambry.store/StorageManager.java 88.31% <87.5%> (-0.04%) 54 <0> (ø)
.../com.github.ambry.clustermap/HelixParticipant.java 85.55% <96.34%> (+4.88%) 56 <19> (+19) ⬆️
...github.ambry.rest/AsyncRequestResponseHandler.java 87.87% <0%> (-2.36%) 21% <0%> (ø)
...c/main/java/com.github.ambry.network/Selector.java 78.21% <0%> (-0.79%) 77% <0%> (-1%)
...rc/main/java/com.github.ambry.store/BlobStore.java 89.93% <0%> (-0.23%) 103% <0%> (-1%)
...in/java/com.github.ambry.store/BlobStoreStats.java 70.41% <0%> (ø) 101% <0%> (-2%) ⬇️
.../java/com.github.ambry.router/DeleteOperation.java 94.89% <0%> (+1.45%) 45% <0%> (+1%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dccd32c...c559a6d. Read the comment docs.

@jsjtzyy jsjtzyy changed the title WIP: Allow ambry server to update replica info in Helix InstanceConfig Allow ambry server to update replica info in Helix InstanceConfig Jan 1, 2020
@jsjtzyy jsjtzyy marked this pull request as ready for review January 1, 2020 06:50
@jsjtzyy jsjtzyy requested review from ankagrawal and zzmao January 7, 2020 17:44
Copy link
Contributor

@zzmao zzmao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will take a second review on addNewReplicaInfo and removeOldReplicaInfo

* Update disk/replica infos associated with current data node in cluster (this occurs when replica addition/removal
* on current node is complete and local changes will be broadcast to all listeners in this cluster)
* @param replicaId the {@link ReplicaId} whose info should be updated on current node
* @param shouldPresent Whether the replica info should be present. When {@code true}, replica info will be added if
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Feel addOrRemove is better.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not have two methods: addDataNodeInfoInCluster and removeDataNodeInfoFromCluster?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addOrRemove seems to require an enum. We cannot tell if it should be added or removed by looking at the boolean value (true/false). Aside from shouldPresent, I also consider shouldExist. I am still open to other proper names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldExist feels better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will make the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ankagrawal I guess you are suggesting addReplicaToDataNodeInfo and removeReplicaFromDataNodeInfo. Yes, we could but a single method with boolean variable would suffice and seems to be more concise. In addition, updating data node info only applies to HelixParticipant. That is, we don't need to introduce one more unnecessary method to other implementation of ClusterParticipant (i.e. StaticClusterParticipant).

@@ -16,3 +16,4 @@ host.name=localhost
clustermap.cluster.name=Ambry_Dev
clustermap.datacenter.name=Datacenter
clustermap.host.name=localhost
clustermap.port=6667
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this newly added?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, I just added it here to fix issue #1357 (probably should be in a separate PR but let's get it fixed together with this PR merged)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to ignore this, not related to this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK. I also need this change. :)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

for (String replicaInfo : replicaInfos) {
String[] infos = replicaInfo.split(ClusterMapUtils.REPLICAS_STR_SEPARATOR);
if (infos[0].equals(partitionName)) {
replicaFound = true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split string to arrayList and then removeIf probably needs less code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will make the change.

Copy link
Contributor

@zzmao zzmao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One comment left.

@jsjtzyy
Copy link
Contributor Author

jsjtzyy commented Jan 21, 2020

@ankagrawal gentle reminder to review, thanks!

* Update disk/replica infos associated with current data node in cluster (this occurs when replica addition/removal
* on current node is complete and local changes will be broadcast to all listeners in this cluster)
* @param replicaId the {@link ReplicaId} whose info should be updated on current node
* @param shouldPresent Whether the replica info should be present. When {@code true}, replica info will be added if
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not have two methods: addDataNodeInfoInCluster and removeDataNodeInfoFromCluster?

private boolean addNewReplicaInfo(ReplicaId replicaId, InstanceConfig instanceConfig) {
boolean additionResult = true;
String partitionName = replicaId.getPartitionId().toPathString();
String newReplicaInfo = partitionName + ClusterMapUtils.REPLICAS_STR_SEPARATOR + replicaId.getCapacityInBytes()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor:
Maybe try String.join(ClusterMapUtils.REPLICAS_STR_SEPARATOR, partitionName, replicaId.getCapacityInBytes(), replicaId.getPartitionId().getPartitionClass()) + ClusterMapUtils.REPLICAS_DELIM_STR; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, let me make the change.

@@ -16,3 +16,4 @@ host.name=localhost
clustermap.cluster.name=Ambry_Dev
clustermap.datacenter.name=Datacenter
clustermap.host.name=localhost
clustermap.port=6667
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this.

@jsjtzyy jsjtzyy force-pushed the update-instance-config branch from 896a1fe to c559a6d Compare January 29, 2020 02:32
Copy link
Collaborator

@ankagrawal ankagrawal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Address the minor comment to add the log and then I will merge it after travis is successful.

@ankagrawal ankagrawal merged commit 906d0bb into linkedin:master Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants