public class LoadBalancer
extends java.lang.Object
implements io.reactivesocket.ReactiveSocket
ReactiveSocket implementation will load balance the request across a
pool of children ReactiveSockets.
It estimates the load of each ReactiveSocket based on statistics collected.| Modifier and Type | Field and Description |
|---|---|
static double |
DEFAULT_EXP_FACTOR |
static double |
DEFAULT_HIGHER_QUANTILE |
static double |
DEFAULT_LOWER_QUANTILE |
static int |
DEFAULT_MAX_APERTURE |
static double |
DEFAULT_MAX_PENDING |
static long |
DEFAULT_MAX_REFRESH_PERIOD_MS |
static int |
DEFAULT_MIN_APERTURE |
static double |
DEFAULT_MIN_PENDING |
| Constructor and Description |
|---|
LoadBalancer(org.reactivestreams.Publisher<? extends java.util.Collection<io.reactivesocket.client.ReactiveSocketClient>> factories) |
LoadBalancer(org.reactivestreams.Publisher<? extends java.util.Collection<io.reactivesocket.client.ReactiveSocketClient>> factories,
double expFactor,
double lowQuantile,
double highQuantile,
double minPendings,
double maxPendings,
int minAperture,
int maxAperture,
long maxRefreshPeriodMs,
io.reactivesocket.internal.EventPublisher<io.reactivesocket.events.ClientEventListener> eventPublisher) |
| Modifier and Type | Method and Description |
|---|---|
double |
availability() |
org.reactivestreams.Publisher<java.lang.Void> |
close() |
org.reactivestreams.Publisher<java.lang.Void> |
fireAndForget(io.reactivesocket.Payload payload) |
org.reactivestreams.Publisher<java.lang.Void> |
metadataPush(io.reactivesocket.Payload payload) |
org.reactivestreams.Publisher<java.lang.Void> |
onClose() |
org.reactivestreams.Publisher<io.reactivesocket.Payload> |
requestChannel(org.reactivestreams.Publisher<io.reactivesocket.Payload> payloads) |
org.reactivestreams.Publisher<io.reactivesocket.Payload> |
requestResponse(io.reactivesocket.Payload payload) |
org.reactivestreams.Publisher<io.reactivesocket.Payload> |
requestStream(io.reactivesocket.Payload payload) |
org.reactivestreams.Publisher<io.reactivesocket.Payload> |
requestSubscription(io.reactivesocket.Payload payload) |
java.lang.String |
toString() |
public static final double DEFAULT_EXP_FACTOR
public static final double DEFAULT_LOWER_QUANTILE
public static final double DEFAULT_HIGHER_QUANTILE
public static final double DEFAULT_MIN_PENDING
public static final double DEFAULT_MAX_PENDING
public static final int DEFAULT_MIN_APERTURE
public static final int DEFAULT_MAX_APERTURE
public static final long DEFAULT_MAX_REFRESH_PERIOD_MS
public LoadBalancer(org.reactivestreams.Publisher<? extends java.util.Collection<io.reactivesocket.client.ReactiveSocketClient>> factories,
double expFactor,
double lowQuantile,
double highQuantile,
double minPendings,
double maxPendings,
int minAperture,
int maxAperture,
long maxRefreshPeriodMs,
io.reactivesocket.internal.EventPublisher<io.reactivesocket.events.ClientEventListener> eventPublisher)
factories - the source (factories) of ReactiveSocketexpFactor - how aggressive is the algorithm toward outliers. A higher
number means we send aggressively less traffic to a server
slightly slower.lowQuantile - the lower bound of the latency band of acceptable values.
Any server below that value will be aggressively favored.highQuantile - the higher bound of the latency band of acceptable values.
Any server above that value will be aggressively penalized.minPendings - The lower band of the average outstanding messages per server.maxPendings - The higher band of the average outstanding messages per server.minAperture - the minimum number of connections we want to maintain,
independently of the load.maxAperture - the maximum number of connections we want to maintain,
independently of the load.maxRefreshPeriodMs - the maximum time between two "refreshes" of the list of active
ReactiveSocket. This is at that time that the slowest
ReactiveSocket is closed. (unit is millisecond)public LoadBalancer(org.reactivestreams.Publisher<? extends java.util.Collection<io.reactivesocket.client.ReactiveSocketClient>> factories)
public org.reactivestreams.Publisher<java.lang.Void> fireAndForget(io.reactivesocket.Payload payload)
fireAndForget in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<io.reactivesocket.Payload> requestResponse(io.reactivesocket.Payload payload)
requestResponse in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<io.reactivesocket.Payload> requestSubscription(io.reactivesocket.Payload payload)
requestSubscription in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<io.reactivesocket.Payload> requestStream(io.reactivesocket.Payload payload)
requestStream in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<java.lang.Void> metadataPush(io.reactivesocket.Payload payload)
metadataPush in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<io.reactivesocket.Payload> requestChannel(org.reactivestreams.Publisher<io.reactivesocket.Payload> payloads)
requestChannel in interface io.reactivesocket.ReactiveSocketpublic double availability()
availability in interface io.reactivesocket.Availabilityavailability in interface io.reactivesocket.ReactiveSocketpublic java.lang.String toString()
toString in class java.lang.Objectpublic org.reactivestreams.Publisher<java.lang.Void> close()
close in interface io.reactivesocket.ReactiveSocketpublic org.reactivestreams.Publisher<java.lang.Void> onClose()
onClose in interface io.reactivesocket.ReactiveSocket