narendly commented on a change in pull request #855: Make ZkBaseDataAccessor
realm-aware
URL: https://github.com/apache/helix/pull/855#discussion_r388080036
##########
File path:
helix-core/src/main/java/org/apache/helix/manager/zk/ZkBaseDataAccessor.java
##########
@@ -1248,4 +1240,123 @@ public void close() {
_zkClient.close();
}
}
+
+ public static class Builder {
+ private String zkAddress;
+ private RealmAwareZkClient.RealmMode realmMode;
+ private RealmAwareZkClient.RealmAwareZkConnectionConfig
realmAwareZkConnectionConfig;
+ private RealmAwareZkClient.RealmAwareZkClientConfig
realmAwareZkClientConfig;
+
+ public Builder() {
+ }
+
+ public ZkBaseDataAccessor.Builder setZkAddress(String zkAddress) {
+ this.zkAddress = zkAddress;
+ return this;
+ }
+
+ public ZkBaseDataAccessor.Builder
setRealmMode(RealmAwareZkClient.RealmMode realmMode) {
+ this.realmMode = realmMode;
+ return this;
+ }
+
+ public ZkBaseDataAccessor.Builder setRealmAwareZkConnectionConfig(
+ RealmAwareZkClient.RealmAwareZkConnectionConfig
realmAwareZkConnectionConfig) {
+ this.realmAwareZkConnectionConfig = realmAwareZkConnectionConfig;
+ return this;
+ }
+
+ public ZkBaseDataAccessor.Builder setRealmAwareZkClientConfig(
+ RealmAwareZkClient.RealmAwareZkClientConfig realmAwareZkClientConfig) {
+ this.realmAwareZkClientConfig = realmAwareZkClientConfig;
+ return this;
+ }
+
+ public ZkBaseDataAccessor<?> build() throws Exception {
+ validate();
+ return new ZkBaseDataAccessor<>(this);
+ }
+
+ /**
+ * Validate the given parameters before creating an instance of
ConfigAccessor.
+ */
+ private void validate() {
Review comment:
Ideally, validation logic should also resolve things like ZkClientType (if
it's not set), so that the constructor should only worry about "constructing",
not figuring out what's set or not. Let's try to separate logic as much as we
can - this will help future development much easier in my opinion.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]