-
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
Added HelixPopulateTool and tests. #1176
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1176 +/- ##
===========================================
- Coverage 69.86% 69.67% -0.2%
+ Complexity 5374 5371 -3
===========================================
Files 428 429 +1
Lines 32863 32949 +86
Branches 4147 4160 +13
===========================================
- Hits 22960 22957 -3
- Misses 8772 8856 +84
- Partials 1131 1136 +5
Continue to review full report at Codecov.
|
@@ -0,0 +1,126 @@ | |||
/* | |||
* Copyright 2017 LinkedIn Corp. All rights reserved. |
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.
2019, please
@@ -0,0 +1,183 @@ | |||
/* | |||
* Copyright 2017 LinkedIn Corp. All rights reserved. |
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.
same here
private static String SEPARATOR = "/"; | ||
static List<String> ignoreResourceKeyWords = Arrays.asList("aggregation", "trigger", "stats"); | ||
|
||
public static void main(String args[]) { |
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.
use java style: String[] args
OptionSpec createClusterOpt = parser.accepts("createCluster", | ||
"Create resources in dest by copying from src to dest. --createCluster --dest destZkEndpoint/destClusterName"); | ||
OptionSpec updateClusterOpt = parser.accepts("updateCluster", | ||
"Update resources in dest by copying from src to dest. --updateCluster" |
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.
Still don't quite understand Create resources in dest by copying from src to dest
in createCluster
. I feel like maybe we can change the description a little bit. Let's discuss offline.
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.
no copy required. Just create. Update.
if (options.has(updateClusterOpt)) { | ||
System.out.println("Updating cluster: " + destClusterName); | ||
String srcZkString = options.valueOf(srcOpt).split(SEPARATOR)[0]; | ||
String srcClusterName = options.valueOf(srcOpt).split(SEPARATOR)[1]; |
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.
move System.out.println("Updating cluster: " + destClusterName);
here and add more info like " from existing cluster: " + srcClusterName
.
ClusterConfig clusterConfig = configAccessor.getClusterConfig(destClusterName); | ||
clusterConfig.setPersistBestPossibleAssignment(true); | ||
configAccessor.setClusterConfig(destClusterName, clusterConfig); | ||
System.out.println("Cluster " + destClusterName + " create done."); |
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: how about this:
System.out.println("Cluster " + destClusterName + " is successfully created!");
* @param destClusterName the dest cluster's name | ||
*/ | ||
static void updateResourceAndPartition(String srcZkString, String srcClusterName, String destZkString, | ||
String destClusterName, boolean dryRun) { |
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.
add java doc for dryRun
} | ||
|
||
/** | ||
* Update dest cluster information based on src cluster. Dest cluster resource will be recreated if src cluster has any 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.
minor question: is recreated
automatically? In other words, any changes in src cluster will trigger changes in dest cluster automatically?
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.
Never mind, I understand what you mean here by reading following code. However, I feel like it could be better to change the description as:
Dest cluster resource will be recreated if it mismatches that in src cluster.
} | ||
} | ||
} | ||
System.out.println("Cluster " + destClusterName + " update done."); |
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: how about System.out.println("Cluster " + destClusterName + " is successfully updated!");
Set<String> srcPartitions = srcAdmin.getResourceIdealState(srcClusterName, resource).getPartitionSet(); | ||
Set<String> destPartitions = destAdmin.getResourceIdealState(destClusterName, resource).getPartitionSet(); | ||
for (String partition : srcPartitions) { | ||
if (!destPartitions.contains(partition)) { |
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.
what if destPartitions
has partition that is not in srcPartitions
?
@jsjtzyy Addressed your comments and enhanced a test. |
String destZkString = options.valueOf(destOpt).split(SEPARATOR)[0]; | ||
String destClusterName = options.valueOf(destOpt).split(SEPARATOR)[1]; | ||
if (!destClusterName.contains("VCR")) { | ||
System.out.println("dest should be a VCR cluster.(VCR string should be included)"); |
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.
System.err.println.
destZkClient.setZkSerializer(new ZNRecordSerializer()); | ||
HelixAdmin destAdmin = new ZKHelixAdmin(destZkClient); | ||
if (destAdmin.getClusters().contains(destClusterName)) { | ||
System.out.println("Failed to create cluster becuase " + destClusterName + " already exist."); |
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.
err
public static void main(String[] args) { | ||
OptionParser parser = new OptionParser(); | ||
OptionSpec createClusterOpt = parser.accepts("createCluster", | ||
"Create resources in dest cluster. --createCluster --dest destZkEndpoint/destClusterName"); |
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.
Does it actually create resources or just the cluster?
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.
just cluster.
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 add in comment.
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.
Issues addressed in #1179
System.out.println("DryRun: Drop Resource " + resource); | ||
} else { | ||
// This resource need to be recreate. | ||
destAdmin.dropResource(destClusterName, resource); |
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 looks like this should only be done if the resource exists in dest and is different from src. You might need another boolean variable like dropChangedResource to condition this action.
System.out.println("DryRun: Add Resource " + resource + " with partition " + srcPartitions); | ||
} else { | ||
destAdmin.addResource(destClusterName, resource, idealState); | ||
destAdmin.rebalance(destClusterName, resource, 3, "", ""); |
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.
Not obvious what constant 3 refers to. Variable or comment would be helpful.
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.
Please address comments in follow up PR.
Fix some issue in #1176 Add controlResource and maintainCluster support.
Add HelixPopulateTool to create or update a helix cluster zk info.