forked from apple/servicetalk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move much of the RR connection selection process to Host
Motivation: RoundRobinLoadBalancer contains the logic that dictates how an individual connection is selected from a Host. This means the RR lb is not just a load balancer but also the connection pool. Modifications: - Extract the connection selection out of the RR balancer and put it in Host. Result: We're continuing to separate concerns into their own abstractions. The current process of connection selection by host can now more easily shared and refined in the future.
- Loading branch information
1 parent
c667bb5
commit 549b94e
Showing
3 changed files
with
214 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
servicetalk-loadbalancer/src/main/java/io/servicetalk/loadbalancer/LBExceptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright © 2021-2023 Apple Inc. and the ServiceTalk project authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.servicetalk.loadbalancer; | ||
|
||
import io.servicetalk.client.api.ConnectionRejectedException; | ||
import io.servicetalk.client.api.NoActiveHostException; | ||
import io.servicetalk.client.api.NoAvailableHostException; | ||
import io.servicetalk.concurrent.internal.ThrowableUtils; | ||
|
||
final class LBExceptions { | ||
|
||
static final class StacklessNoAvailableHostException extends NoAvailableHostException { | ||
private static final long serialVersionUID = 5942960040738091793L; | ||
|
||
private StacklessNoAvailableHostException(final String message) { | ||
super(message); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
public static StacklessNoAvailableHostException newInstance(String message, Class<?> clazz, String method) { | ||
return ThrowableUtils.unknownStackTrace(new StacklessNoAvailableHostException(message), clazz, method); | ||
} | ||
} | ||
|
||
static final class StacklessNoActiveHostException extends NoActiveHostException { | ||
|
||
private static final long serialVersionUID = 7500474499335155869L; | ||
|
||
private StacklessNoActiveHostException(final String message) { | ||
super(message); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
public static StacklessNoActiveHostException newInstance(String message, Class<?> clazz, String method) { | ||
return ThrowableUtils.unknownStackTrace(new StacklessNoActiveHostException(message), clazz, method); | ||
} | ||
} | ||
|
||
static final class StacklessConnectionRejectedException extends ConnectionRejectedException { | ||
private static final long serialVersionUID = -4940708893680455819L; | ||
|
||
private StacklessConnectionRejectedException(final String message) { | ||
super(message); | ||
} | ||
|
||
@Override | ||
public Throwable fillInStackTrace() { | ||
return this; | ||
} | ||
|
||
public static StacklessConnectionRejectedException newInstance(String message, Class<?> clazz, String method) { | ||
return ThrowableUtils.unknownStackTrace(new StacklessConnectionRejectedException(message), clazz, method); | ||
} | ||
} | ||
|
||
private LBExceptions() { | ||
// no instances | ||
} | ||
} |
Oops, something went wrong.