Skip to content

Add backward compatibility support for constructing ZKHelixManager#2137

Closed
mgao0 wants to merge 2 commits intoapache:masterfrom
mgao0:managerFactory
Closed

Add backward compatibility support for constructing ZKHelixManager#2137
mgao0 wants to merge 2 commits intoapache:masterfrom
mgao0:managerFactory

Conversation

@mgao0
Copy link
Contributor

@mgao0 mgao0 commented Jun 2, 2022

Issues

  • My PR addresses the following Helix issues and references them in the PR description:

Resolves #2160

Description

  • Here are some details about my PR, including screenshots of any UI changes:

This commit uses a deprecated class HelixZkClient.ZkConnectionConfig to convey the information for non-ZooScalability users in HelixManagerProperty, while ZooScalability users use RealmAwareZkClient.RealmAwareZkConnectionConfig. This commit adds some validation around there should be at least one, and only one of HelixZkClient.ZkConnectionConfig, RealmAwareZkClient.RealmAwareZkConnectionConfig, and zk address exists, and this one field will be used as the source of information to establish connection with ZK server.

Tests

  • The following tests are written for this issue:

Added TestHelixManagerFactory.
Also ran TestMultiZkHelixJavaApis.java to make sure this commit doesn't break current logic for ZooScalability cases.

  • The following is the result of the "mvn test" command on the appropriate module:

Running

Changes that Break Backward Compatibility (Optional)

  • My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:

(Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)

Documentation (Optional)

  • In case of new functionality, my PR adds documentation in the following wiki page:

(Link the GitHub wiki you added)

Commits

  • My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "How to write a good git commit message":
    1. Subject is separated from body by a blank line
    2. Subject is limited to 50 characters (not including Jira issue reference)
    3. Subject does not end with a period
    4. Subject uses the imperative mood ("add", not "adding")
    5. Body wraps at 72 characters
    6. Body explains "what" and "why", not "how"

Code Quality

  • My diff has been formatted using helix-style.xml
    (helix-style-intellij.xml if IntelliJ IDE is used)

@mgao0 mgao0 changed the title Add backward compatibility support for constructing ZKHelixManager [WIP]Add backward compatibility support for constructing ZKHelixManager Jun 2, 2022
@mgao0 mgao0 force-pushed the managerFactory branch from e390c18 to d4212ab Compare June 2, 2022 23:23

public class TestHelixManagerFactory {
private static Logger LOG = LoggerFactory.getLogger(TestHelixManagerFactory.class);

Copy link
Contributor

Choose a reason for hiding this comment

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

Where are the test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's still work in progress. I will add the tests once they are completed.

Comment on lines +1583 to +1593
if (hasRealmAwareZkConnectionConfig) {
RealmAwareZkClient.RealmAwareZkConnectionConfig connectionConfig =
helixManagerProperty.getZkConnectionConfig();
helixManagerProperty.getRealmAwareZkConnectionConfig();
if (connectionConfig.getZkRealmShardingKey() == null || connectionConfig
.getZkRealmShardingKey().isEmpty()) {
throw new HelixException(
"ZKHelixManager::ZK path sharding key must be set for ZKHelixManager! ZKHelixManager "
+ "is only available on single-realm mode.");
}
_realmAwareZkConnectionConfig = connectionConfig;
} else if (hasZkConnectionConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these two be coexist? Or it is either or relationship.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These two and zk address should not coexist, there should be only one of them. Line 1576 - 1577 is used to enforce this relationship.

@mgao0 mgao0 marked this pull request as ready for review June 15, 2022 23:56
@mgao0 mgao0 changed the title [WIP]Add backward compatibility support for constructing ZKHelixManager Add backward compatibility support for constructing ZKHelixManager Jun 16, 2022
public HelixManagerProperty build() {
return new HelixManagerProperty(_version, _healthReportLatency, _helixCloudProperty,
_zkConnectionConfig, _zkClientConfig);
_realmAwareZkConnectionConfig, _zkClientConfig, _zkConnectionConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: For this public function, shall we keep the original signature and add this as a new one?

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, we should have 2 distinct methods

private RealmAwareZkClient.RealmAwareZkClientConfig _zkClientConfig;
// This field is added for backward compatibility, when this field is set,
// _realmAwareZkConnectionConfig should not be set
private HelixZkClient.ZkConnectionConfig _zkConnectionConfig;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we use Optional property indicating that it may not be set?

RealmAwareZkClient.RealmAwareZkClientConfig zkClientConfig) {
RealmAwareZkClient.RealmAwareZkConnectionConfig realmAwareZkConnectionConfig,
RealmAwareZkClient.RealmAwareZkClientConfig zkClientConfig,
HelixZkClient.ZkConnectionConfig zkConnectionConfig) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if i read your previous comment, you want either realmAwareZkConnection or regular ZkConnection, so can we not have 2 distinct constructors and not break any existing users?


public RealmAwareZkClient.RealmAwareZkConnectionConfig getZkConnectionConfig() {
return _zkConnectionConfig;
public RealmAwareZkClient.RealmAwareZkConnectionConfig getRealmAwareZkConnectionConfig() {
Copy link
Contributor

Choose a reason for hiding this comment

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

this can break users as they used to get RealmAwareZkClient earlier, and will need to update code to use appropriate

return _zkClientConfig;
}

public HelixZkClient.ZkConnectionConfig getZkConnectionConfig() {
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is new property, you can rename this method, so that clients don't have to change.

public HelixManagerProperty build() {
return new HelixManagerProperty(_version, _healthReportLatency, _helixCloudProperty,
_zkConnectionConfig, _zkClientConfig);
_realmAwareZkConnectionConfig, _zkClientConfig, _zkConnectionConfig);
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, we should have 2 distinct methods

HelixManagerProperty helixManagerProperty) {
validateZkConnectionSettings(zkAddress, helixManagerProperty);

_zkAddress = zkAddress;
Copy link
Contributor

Choose a reason for hiding this comment

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

any particular reason, zkAddress is not set here. Customer has provided as input.

helixManagerProperty != null && helixManagerProperty.getZkConnectionConfig() != null;
if (Stream.of(zkAddress != null, hasRealmAwareZkConnectionConfig, hasZkConnectionConfig)
.filter(condition -> condition).count() != 1) {
throw new HelixException(
Copy link
Contributor

Choose a reason for hiding this comment

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

i find this pattern a bit counter intuitive. You have 3 different choices. Typically, we would have 3 distinct constructors (eg. Integer(int), Integer(Integer), Integer(string)??)

Other thing is if customer has used a particular constructor, other properties will be null or ignored.AFAIK we don't allow update of Helix manager once constructor is called.

managerParticipant.connect();

// Verify manager
InstanceConfig instanceConfigRead =
Copy link
Contributor

Choose a reason for hiding this comment

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

you will need multiple negative test scenario. ie. only zkAddress case, only realmZkClientConnectconfig and combinations throwing exception etc.

@mgao0
Copy link
Contributor Author

mgao0 commented Jun 17, 2022

Closing this PR as this is not a necessary feature, and may introduce other backward incompatibilities in order to fix it. Will evaluate the situation later and reopen if necessary.

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.

HelixManagerFactory doesn't support instantiating ZKHelixManager with HelixManagerProperty for Non-MSDS use cases

4 participants