Added Ring hash selection strategy
Motivation:
this Resolves #4698 issue
Added Ring hash strategy for For a broader selection.
Motification:
- Added(RingHashEndpointSelectionStrategy): Implement a ring hash using the md5 hash algorithm and a ConcurrentSkipListMap
Result:
For now on, users will be able to use Ring hashes for load balancing.
Looking at the wighted round robin, it looks like we need to identify the keys via host and port, am I understanding this correctly?๐ค
Thanks for continuing updating this PR. Please feel free to let us know when it's ready for reviews. If you feel it's not yet, please consider switching it to a draft PR. ๐
Thanks for continuing updating this PR. Please feel free to let us know when it's ready for reviews. If you feel it's not yet, please consider switching it to a draft PR. ๐
Thanks for pointing out this great feature. It turned out to be longer than I thought, so I fixed it to draft status
I've worked on some of the details.๐ I'm still struggling with writing tests.๐ญ How about testing the size of the ring or the element it contains?(I've put this approach now.) I also considered injecting the ring directly into the ring hash, but realized that it would be difficult to handle the hashing.
P.S.
I don't know why the lint test fails.
If I run ./gradlew lint --parallel command in local, it will succeed.
Below is a part of the failed lint task log.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':core:compileTestJava'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:135)
at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:74)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
I don't feel like this PR is ready yet. This is because I've heard from @minwoox that endpoints can be change dynamically. As result, I'll be working on incorporating this idea into code this week.๐
Resolved everything in the comment.๐ I'm not sure about test for ring hashing's equality, but round robin has an equality test. so I have concern about if I should consider that.๐ @minwoox PTAL ๐
Codecov Report
Attention: Patch coverage is 92.39130% with 7 lines in your changes missing coverage. Please review.
Project coverage is 74.70%. Comparing base (
9a29b39) to head (1a64c77). Report is 23 commits behind head on main.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| ...nt/endpoint/RingHashEndpointSelectionStrategy.java | 92.30% | 2 Missing and 5 partials :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #4831 +/- ##
============================================
+ Coverage 74.66% 74.70% +0.03%
- Complexity 21681 21705 +24
============================================
Files 1896 1898 +2
Lines 80320 80475 +155
Branches 10548 10570 +22
============================================
+ Hits 59974 60116 +142
- Misses 15318 15322 +4
- Partials 5028 5037 +9
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
๐ Build Scanยฎ (commit: 0f12d268b51aa3b026c790a15e635ec117b66b95)
| Job name | Status | Build Scanยฎ |
|---|---|---|
| build-ubicloud-standard-8-jdk-8 | โ | https://ge.armeria.dev/s/534qu5cdpyhjc |
| build-ubicloud-standard-8-jdk-21-snapshot-blockhound | โ | https://ge.armeria.dev/s/ydl3vhtxcrvby |
| build-ubicloud-standard-8-jdk-17-min-java-17-coverage | โ (failure) | https://ge.armeria.dev/s/ssx26i3nkaqmq |
| build-ubicloud-standard-8-jdk-17-min-java-11 | โ | https://ge.armeria.dev/s/3no2euebo4bzc |
| build-ubicloud-standard-8-jdk-17-leak | โ | https://ge.armeria.dev/s/lylgm3eu2g35i |
| build-ubicloud-standard-8-jdk-11 | โ | https://ge.armeria.dev/s/bb7yppkcmxp5m |
| build-macos-12-jdk-21 | โ | https://ge.armeria.dev/s/qnjigh4nzdonc |
gentle ping @trustin @ikhoon @jrhee17 @minwoox
gentle ping @trustin @ikhoon @jrhee17 @minwoox
gentle ping @trustin @ikhoon @jrhee17 @minwoox
~~I fixed some minor mistakes, changed the hashing algorithm, and of course shaded the dependencies. PTAL ๐~~
I just realized a mistake in the shading implementation and am fixing it.
@ikhoon @trustin @minwoox @jrhee17 finally fixed the shading feature! I actually unzipped it to check it out and it looks like this. PTAL ๐
unzip -l build/libs/armeria-shaded-1.30.2-SNAPSHOT.jar | grep openhft
0 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/
256 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Access$1.class
3183 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Access$ReverseAccess.class
3538 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Access.class
1539 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/LongHashFunction.class
268 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Primitives$1.class
786 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Primitives$ByteOrderHelper.class
894 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Primitives$ByteOrderHelperReverse.class
1420 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/Primitives.class
274 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$1.class
1156 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$OldUnsafeAccessBigEndian.class
1169 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess$OldUnsafeAccessLittleEndian.class
4253 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/UnsafeAccess.class
1717 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/XxHash$AsLongHashFunction.class
2833 09-15-2024 21:15 com/linecorp/armeria/internal/shaded/openhft/XxHash.class
gentle ping @trustin @ikhoon @jrhee17 @minwoox