Class GrpclbState.LbStream
- java.lang.Object
-
- io.grpc.grpclb.GrpclbState.LbStream
-
- All Implemented Interfaces:
StreamObserver<LoadBalanceResponse>
- Enclosing class:
- GrpclbState
private class GrpclbState.LbStream extends java.lang.Object implements StreamObserver<LoadBalanceResponse>
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanclosed(package private) booleaninitialResponseReceived(package private) StreamObserver<LoadBalanceRequest>lbRequestWriter(package private) GrpclbClientLoadRecorderloadRecorder(package private) longloadReportIntervalMillis(package private) SynchronizationContext.ScheduledHandleloadReportTimer(package private) LoadBalancerGrpc.LoadBalancerStubstub
-
Constructor Summary
Constructors Constructor Description LbStream(LoadBalancerGrpc.LoadBalancerStub stub)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcleanUp()(package private) voidclose(java.lang.Exception error)private voidhandleResponse(LoadBalanceResponse response)private voidhandleStreamClosed(Status error)voidonCompleted()Receives a notification of successful stream completion.voidonError(java.lang.Throwable error)Receives a terminating error from the stream.voidonNext(LoadBalanceResponse response)Receives a value from the stream.private voidscheduleNextLoadReport()private voidsendLoadReport()(package private) voidstart()
-
-
-
Field Detail
-
loadRecorder
final GrpclbClientLoadRecorder loadRecorder
-
stub
final LoadBalancerGrpc.LoadBalancerStub stub
-
lbRequestWriter
StreamObserver<LoadBalanceRequest> lbRequestWriter
-
initialResponseReceived
boolean initialResponseReceived
-
closed
boolean closed
-
loadReportIntervalMillis
long loadReportIntervalMillis
-
loadReportTimer
SynchronizationContext.ScheduledHandle loadReportTimer
-
-
Constructor Detail
-
LbStream
LbStream(LoadBalancerGrpc.LoadBalancerStub stub)
-
-
Method Detail
-
start
void start()
-
onNext
public void onNext(LoadBalanceResponse response)
Description copied from interface:StreamObserverReceives 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:
onNextin interfaceStreamObserver<LoadBalanceResponse>- Parameters:
response- the value passed to the stream
-
onError
public void onError(java.lang.Throwable error)
Description copied from interface:StreamObserverReceives 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
onErrorno further calls to any method are allowed.tshould be aStatusExceptionorStatusRuntimeException, but otherThrowabletypes are possible. Callers should generally convert from aStatusviaStatus.asException()orStatus.asRuntimeException(). Implementations should generally convert to aStatusviaStatus.fromThrowable(Throwable).- Specified by:
onErrorin interfaceStreamObserver<LoadBalanceResponse>- Parameters:
error- the error occurred on the stream
-
onCompleted
public void onCompleted()
Description copied from interface:StreamObserverReceives 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
onCompletedno further calls to any method are allowed.- Specified by:
onCompletedin interfaceStreamObserver<LoadBalanceResponse>
-
sendLoadReport
private void sendLoadReport()
-
scheduleNextLoadReport
private void scheduleNextLoadReport()
-
handleResponse
private void handleResponse(LoadBalanceResponse response)
-
handleStreamClosed
private void handleStreamClosed(Status error)
-
close
void close(java.lang.Exception error)
-
cleanUp
private void cleanUp()
-
-