public static StreamResponse decode(ByteBuf buf) { String streamId = Encoders.Strings.decode(buf); long byteCount = buf.readLong(); return new StreamResponse(streamId, byteCount, null); }
@Override public int hashCode() { return Objects.hashCode(byteCount, streamId, body()); }
return StreamResponse.decode(in);
return StreamResponse.decode(in);
public static StreamResponse decode(ByteBuf buf) { String streamId = Encoders.Strings.decode(buf); long byteCount = buf.readLong(); return new StreamResponse(streamId, byteCount, null); }
@Override public String toString() { return Objects.toStringHelper(this) .add("streamId", streamId) .add("byteCount", byteCount) .add("body", body()) .toString(); }
return StreamResponse.decode(in);
public static StreamResponse decode(ByteBuf buf) { String streamId = Encoders.Strings.decode(buf); long byteCount = buf.readLong(); return new StreamResponse(streamId, byteCount, null); }
@Override public int hashCode() { return Objects.hashCode(byteCount, streamId, body()); }
return StreamResponse.decode(in);
public static StreamResponse decode(ByteBuf buf) { String streamId = Encoders.Strings.decode(buf); long byteCount = buf.readLong(); return new StreamResponse(streamId, byteCount, null); }
@Override public String toString() { return Objects.toStringHelper(this) .add("streamId", streamId) .add("byteCount", byteCount) .add("body", body()) .toString(); }
private void processStreamRequest(final StreamRequest req) { ManagedBuffer buf; try { buf = streamManager.openStream(req.streamId); } catch (Exception e) { logger.error(String.format( "Error opening stream %s for request from %s", req.streamId, getRemoteAddress(channel)), e); respond(new StreamFailure(req.streamId, Throwables.getStackTraceAsString(e))); return; } if (buf != null) { respond(new StreamResponse(req.streamId, buf.size(), buf)); } else { respond(new StreamFailure(req.streamId, String.format( "Stream '%s' was not found.", req.streamId))); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("streamId", streamId) .add("byteCount", byteCount) .add("body", body()) .toString(); }
private void processStreamRequest(final StreamRequest req) { ManagedBuffer buf; try { buf = streamManager.openStream(req.streamId); } catch (Exception e) { logger.error(String.format( "Error opening stream %s for request from %s", req.streamId, getRemoteAddress(channel)), e); respond(new StreamFailure(req.streamId, Throwables.getStackTraceAsString(e))); return; } if (buf != null) { respond(new StreamResponse(req.streamId, buf.size(), buf)); } else { respond(new StreamFailure(req.streamId, String.format( "Stream '%s' was not found.", req.streamId))); } }
@Override public String toString() { return Objects.toStringHelper(this) .add("streamId", streamId) .add("byteCount", byteCount) .add("body", body()) .toString(); }
respond(new StreamResponse(req.streamId, buf.size(), buf)).addListener(future -> { streamManager.streamSent(req.streamId); });
assert responseAndPromisePairs.size() == 3; assert responseAndPromisePairs.get(2).getLeft() instanceof StreamResponse; assert ((StreamResponse) (responseAndPromisePairs.get(2).getLeft())).body() == managedBuffers.get(2);
respond(new StreamResponse(req.streamId, buf.size(), buf)).addListener(future -> { streamManager.streamSent(req.streamId); });
@Test public void testActiveStreams() throws Exception { Channel c = new LocalChannel(); c.pipeline().addLast(TransportFrameDecoder.HANDLER_NAME, new TransportFrameDecoder()); TransportResponseHandler handler = new TransportResponseHandler(c); StreamResponse response = new StreamResponse("stream", 1234L, null); StreamCallback cb = mock(StreamCallback.class); handler.addStreamCallback("stream", cb); assertEquals(1, handler.numOutstandingRequests()); handler.handle(response); assertEquals(1, handler.numOutstandingRequests()); handler.deactivateStream(); assertEquals(0, handler.numOutstandingRequests()); StreamFailure failure = new StreamFailure("stream", "uh-oh"); handler.addStreamCallback("stream", cb); assertEquals(1, handler.numOutstandingRequests()); handler.handle(failure); assertEquals(0, handler.numOutstandingRequests()); }