use of io.grpc.internal.StreamListener in project grpc-java by grpc.
the class Inbound method onTransportReady.
final void onTransportReady() {
// Report transport readiness to the listener, and the outbound data.
Outbound outbound = null;
StreamListener listener = null;
synchronized (this) {
outbound = this.outbound;
listener = this.listener;
}
if (listener != null) {
listener.onReady();
}
if (outbound != null) {
try {
synchronized (outbound) {
outbound.onTransportReady();
}
} catch (StatusException se) {
synchronized (this) {
closeAbnormal(se.getStatus());
}
}
}
}
use of io.grpc.internal.StreamListener in project grpc-java by grpc.
the class NettyClientHandlerTest method setUp.
/**
* Set up for test.
*/
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
StreamListener.MessageProducer producer = (StreamListener.MessageProducer) invocation.getArguments()[0];
InputStream message;
while ((message = producer.next()) != null) {
streamListenerMessageQueue.add(message);
}
return null;
}
}).when(streamListener).messagesAvailable(ArgumentMatchers.<StreamListener.MessageProducer>any());
lifecycleManager = new ClientTransportLifecycleManager(listener);
// it'll be null which will be testing if we behave correctly when it's not present.
if (setKeepaliveManagerFor.contains(testNameRule.getMethodName())) {
mockKeepAliveManager = mock(KeepAliveManager.class);
}
initChannel(new GrpcHttp2ClientHeadersDecoder(GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE));
streamTransportState = new TransportStateImpl(handler(), channel().eventLoop(), DEFAULT_MAX_MESSAGE_SIZE, transportTracer);
streamTransportState.setListener(streamListener);
grpcHeaders = new DefaultHttp2Headers().scheme(HTTPS).authority(as("www.fake.com")).path(as("/fakemethod")).method(HTTP_METHOD).add(as("auth"), as("sometoken")).add(CONTENT_TYPE_HEADER, CONTENT_TYPE_GRPC).add(TE_HEADER, TE_TRAILERS);
// Simulate receipt of initial remote settings.
ByteBuf serializedSettings = serializeSettings(new Http2Settings());
channelRead(serializedSettings);
}
Aggregations