Class GrpclbState.LbStream
- All Implemented Interfaces:
StreamObserver<LoadBalanceResponse>
- Enclosing class:
GrpclbState
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) boolean
(package private) boolean
(package private) StreamObserver
<LoadBalanceRequest> (package private) final GrpclbClientLoadRecorder
(package private) long
(package private) SynchronizationContext.ScheduledHandle
(package private) final LoadBalancerGrpc.LoadBalancerStub
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
cleanUp()
(package private) void
private void
handleResponse
(LoadBalanceResponse response) private void
handleStreamClosed
(Status error) void
Receives a notification of successful stream completion.void
Receives a terminating error from the stream.void
onNext
(LoadBalanceResponse response) Receives a value from the stream.private void
private void
(package private) void
start()
-
Field Details
-
loadRecorder
-
stub
-
lbRequestWriter
StreamObserver<LoadBalanceRequest> lbRequestWriter -
initialResponseReceived
boolean initialResponseReceived -
closed
boolean closed -
loadReportIntervalMillis
long loadReportIntervalMillis -
loadReportTimer
SynchronizationContext.ScheduledHandle loadReportTimer
-
-
Constructor Details
-
LbStream
LbStream(LoadBalancerGrpc.LoadBalancerStub stub)
-
-
Method Details
-
start
void start() -
onNext
Description copied from interface:StreamObserver
Receives a value from the stream.Can be called many times but is never called after
StreamObserver.onError(Throwable)
orStreamObserver.onCompleted()
are called.Unary calls must invoke onNext at most once. Clients may invoke onNext at most once for server streaming calls, but may receive many onNext callbacks. Servers may invoke onNext at most once for client streaming calls, but may receive many onNext callbacks.
If an exception is thrown by an implementation the caller is expected to terminate the stream by calling
StreamObserver.onError(Throwable)
with the caught exception prior to propagating it.- Specified by:
onNext
in interfaceStreamObserver<LoadBalanceResponse>
- Parameters:
response
- the value passed to the stream
-
onError
Description copied from interface:StreamObserver
Receives a terminating error from the stream.May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of
onError
no further calls to any method are allowed.t
should be aStatusException
orStatusRuntimeException
, but otherThrowable
types are possible. Callers should generally convert from aStatus
viaStatus.asException()
orStatus.asRuntimeException()
. Implementations should generally convert to aStatus
viaStatus.fromThrowable(Throwable)
.- Specified by:
onError
in interfaceStreamObserver<LoadBalanceResponse>
- Parameters:
error
- the error occurred on the stream
-
onCompleted
public void onCompleted()Description copied from interface:StreamObserver
Receives a notification of successful stream completion.May only be called once and if called it must be the last method called. In particular if an exception is thrown by an implementation of
onCompleted
no further calls to any method are allowed.- Specified by:
onCompleted
in interfaceStreamObserver<LoadBalanceResponse>
-
sendLoadReport
private void sendLoadReport() -
scheduleNextLoadReport
private void scheduleNextLoadReport() -
handleResponse
-
handleStreamClosed
-
close
-
cleanUp
private void cleanUp()
-