-
Notifications
You must be signed in to change notification settings - Fork 275
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
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.
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 |
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.
Minor: Feel addOrRemove
is better.
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 not have two methods: addDataNodeInfoInCluster and removeDataNodeInfoFromCluster?
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.
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.
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.
shouldExist
feels better.
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.
ok, will make the change.
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.
@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).
7cc6be2
to
f679e74
Compare
@@ -16,3 +16,4 @@ host.name=localhost | |||
clustermap.cluster.name=Ambry_Dev | |||
clustermap.datacenter.name=Datacenter | |||
clustermap.host.name=localhost | |||
clustermap.port=6667 |
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 is this newly added?
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.
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)
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.
Feel free to ignore this, not related to this PR.
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.
It's OK. I also need this change. :)
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.
Thanks for fixing this.
for (String replicaInfo : replicaInfos) { | ||
String[] infos = replicaInfo.split(ClusterMapUtils.REPLICAS_STR_SEPARATOR); | ||
if (infos[0].equals(partitionName)) { | ||
replicaFound = true; |
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.
split string to arrayList and then removeIf
probably needs less code.
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.
Good point, will make the change.
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.
LGTM. One comment left.
@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 |
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 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() |
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.
Minor:
Maybe try String.join(ClusterMapUtils.REPLICAS_STR_SEPARATOR, partitionName, replicaId.getCapacityInBytes(), replicaId.getPartitionId().getPartitionClass()) + ClusterMapUtils.REPLICAS_DELIM_STR; ?
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.
sure, let me make the change.
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipant.java
Show resolved
Hide resolved
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipant.java
Show resolved
Hide resolved
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipant.java
Show resolved
Hide resolved
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipant.java
Show resolved
Hide resolved
ambry-clustermap/src/main/java/com.github.ambry.clustermap/HelixParticipant.java
Show resolved
Hide resolved
@@ -16,3 +16,4 @@ host.name=localhost | |||
clustermap.cluster.name=Ambry_Dev | |||
clustermap.datacenter.name=Datacenter | |||
clustermap.host.name=localhost | |||
clustermap.port=6667 |
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.
Thanks for fixing this.
896a1fe
to
c559a6d
Compare
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.
LGTM.
Address the minor comment to add the log and then I will merge it after travis is successful.
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.