Skip to content

GEODE-4147: Add variability to client rebalance logic#1237

Closed
PivotalSarge wants to merge 1 commit intoapache:developfrom
PivotalSarge:feature/GEODE-4147
Closed

GEODE-4147: Add variability to client rebalance logic#1237
PivotalSarge wants to merge 1 commit intoapache:developfrom
PivotalSarge:feature/GEODE-4147

Conversation

@PivotalSarge
Copy link
Copy Markdown
Contributor

  • Add +/-10% variance to the load condition interval.

Thank you for submitting a contribution to Apache Geode.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • [n/a] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.

@upthewaterspout @bschuchardt

Copy link
Copy Markdown
Contributor

@bschuchardt bschuchardt left a comment

Choose a reason for hiding this comment

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

LGTM
I'd like to learn how to use that style of assertions

static int addVarianceToInterval(int interval) {
if (1 <= interval) {
final SplittableRandom random = new SplittableRandom();
final int variance = (interval < 10) ? 1 : random.nextInt(interval / 10);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For a value less than 10 this will give (value - 1) 50% of the time and (value + 1) 50%...it seems it should also have an equal chance to return the unmodified value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because the intent behind this change is to avoid having a lot of activity happen at the same time, I consciously excluded the case where the interval was not changed.

final SplittableRandom random = new SplittableRandom();
final int variance = (interval < 10) ? 1 : random.nextInt(interval / 10);
final int sign = random.nextBoolean() ? 1 : -1;
return interval + (sign * variance);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not sure if this matter, but this will also return the original value twice as often as any other value (i.e. if the interval is 10, this will return 9 1/4 of the time, 11 1/4 of the time, and 10 half the time).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

To quote Inigo Montoya, perhaps that method does not do what I think it does... I'll make that change.

public void testAddVarianceToInterval() {
assertThat(PoolImpl.addVarianceToInterval(0)).as("Zero gets zero variance").isEqualTo(0);
assertThat(PoolImpl.addVarianceToInterval(300000)).as("Large value gets +/-10% variance")
.isNotEqualTo(300000).isGreaterThanOrEqualTo(270000).isLessThanOrEqualTo(330000);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This test will fail about 1 in 30000 times when it returns 300000. Admittedly rare, but could be annoying when it happens.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[I'm looking at older PRs] Would it be correct to just remove .isNotEqualTo(300000)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The change for the previous comment should prevent that.

Copy link
Copy Markdown
Contributor

@upthewaterspout upthewaterspout left a comment

Choose a reason for hiding this comment

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

I'm seeing tests fail with this PR

ConnectionPoolFactoryJUnitTest and all of the CacheXml* tests.

@PivotalSarge
Copy link
Copy Markdown
Contributor Author

Encountering problems with tests; recalling these changes until that can be sorted.

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.

5 participants