Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ali-middleware-5-self
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
ali-middleware-5-self
Commits
ab6d7646
There was a problem fetching the pipeline stages.
Commit
ab6d7646
authored
5 years ago
by
Recolic Keghart
Browse files
Options
Downloads
Patches
Plain Diff
init
parent
295f3718
No related branches found
No related tags found
No related merge requests found
Pipeline
#743
failed with stages
in 3 minutes and 47 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java
+5
-2
5 additions, 2 deletions
...ay/src/main/java/com/aliware/tianchi/UserLoadBalance.java
with
5 additions
and
2 deletions
workspace-gateway/src/main/java/com/aliware/tianchi/UserLoadBalance.java
+
5
−
2
View file @
ab6d7646
...
...
@@ -6,6 +6,7 @@ import org.apache.dubbo.rpc.Invoker;
import
org.apache.dubbo.rpc.RpcException
;
import
org.apache.dubbo.rpc.cluster.LoadBalance
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ThreadLocalRandom
;
...
...
@@ -18,9 +19,11 @@ import java.util.concurrent.ThreadLocalRandom;
* 选手需要基于此类实现自己的负载均衡算法
*/
public
class
UserLoadBalance
implements
LoadBalance
{
private
int
n
=
0
;
private
int
[]
peers
=
{
0
,
0
,
0
,
1
,
1
,
2
};
@Override
public
<
T
>
Invoker
<
T
>
select
(
List
<
Invoker
<
T
>>
invokers
,
URL
url
,
Invocation
invocation
)
throws
RpcException
{
return
invokers
.
get
(
ThreadLocalRandom
.
current
().
nextInt
(
invokers
.
size
()));
++
n
;
return
invokers
.
get
(
peers
[
n
%
6
]);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment