Issue #922 - Implements methods Connection.getBytes[In|Out]().
Using int rather than long as return value for generated bytes.
This commit is contained in:
parent
aa00e4207d
commit
464dd0667a
|
@ -1108,7 +1108,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
|
|
||||||
private class ControlEntry extends HTTP2Flusher.Entry
|
private class ControlEntry extends HTTP2Flusher.Entry
|
||||||
{
|
{
|
||||||
private long bytes;
|
private int bytes;
|
||||||
|
|
||||||
private ControlEntry(Frame frame, IStream stream, Callback callback)
|
private ControlEntry(Frame frame, IStream stream, Callback callback)
|
||||||
{
|
{
|
||||||
|
@ -1224,7 +1224,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
|
||||||
private class DataEntry extends HTTP2Flusher.Entry
|
private class DataEntry extends HTTP2Flusher.Entry
|
||||||
{
|
{
|
||||||
private int length;
|
private int length;
|
||||||
private long bytes;
|
private int bytes;
|
||||||
|
|
||||||
private DataEntry(DataFrame frame, IStream stream, Callback callback)
|
private DataEntry(DataFrame frame, IStream stream, Callback callback)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,12 +36,12 @@ public class DataGenerator
|
||||||
this.headerGenerator = headerGenerator;
|
this.headerGenerator = headerGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generate(ByteBufferPool.Lease lease, DataFrame frame, int maxLength)
|
public int generate(ByteBufferPool.Lease lease, DataFrame frame, int maxLength)
|
||||||
{
|
{
|
||||||
return generateData(lease, frame.getStreamId(), frame.getData(), frame.isEndStream(), maxLength);
|
return generateData(lease, frame.getStreamId(), frame.getData(), frame.isEndStream(), maxLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateData(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last, int maxLength)
|
public int generateData(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last, int maxLength)
|
||||||
{
|
{
|
||||||
if (streamId < 0)
|
if (streamId < 0)
|
||||||
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
||||||
|
@ -61,7 +61,7 @@ public class DataGenerator
|
||||||
if (frames * maxFrameSize != length)
|
if (frames * maxFrameSize != length)
|
||||||
++frames;
|
++frames;
|
||||||
|
|
||||||
long totalLength = 0;
|
int totalLength = 0;
|
||||||
int begin = data.position();
|
int begin = data.position();
|
||||||
int end = data.limit();
|
int end = data.limit();
|
||||||
for (int i = 1; i <= frames; ++i)
|
for (int i = 1; i <= frames; ++i)
|
||||||
|
@ -77,7 +77,7 @@ public class DataGenerator
|
||||||
return totalLength;
|
return totalLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
private long generateFrame(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last)
|
private int generateFrame(ByteBufferPool.Lease lease, int streamId, ByteBuffer data, boolean last)
|
||||||
{
|
{
|
||||||
int length = data.remaining();
|
int length = data.remaining();
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class DisconnectGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class FrameGenerator
|
||||||
this.headerGenerator = headerGenerator;
|
this.headerGenerator = headerGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract long generate(ByteBufferPool.Lease lease, Frame frame);
|
public abstract int generate(ByteBufferPool.Lease lease, Frame frame);
|
||||||
|
|
||||||
protected ByteBuffer generateHeader(ByteBufferPool.Lease lease, FrameType frameType, int length, int flags, int streamId)
|
protected ByteBuffer generateHeader(ByteBufferPool.Lease lease, FrameType frameType, int length, int flags, int streamId)
|
||||||
{
|
{
|
||||||
|
|
|
@ -75,12 +75,12 @@ public class Generator
|
||||||
headerGenerator.setMaxFrameSize(maxFrameSize);
|
headerGenerator.setMaxFrameSize(maxFrameSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long control(ByteBufferPool.Lease lease, Frame frame)
|
public int control(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
return generators[frame.getType().getType()].generate(lease, frame);
|
return generators[frame.getType().getType()].generate(lease, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long data(ByteBufferPool.Lease lease, DataFrame frame, int maxLength)
|
public int data(ByteBufferPool.Lease lease, DataFrame frame, int maxLength)
|
||||||
{
|
{
|
||||||
return dataGenerator.generate(lease, frame, maxLength);
|
return dataGenerator.generate(lease, frame, maxLength);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class GoAwayGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
|
GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
|
||||||
return generateGoAway(lease, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload());
|
return generateGoAway(lease, goAwayFrame.getLastStreamId(), goAwayFrame.getError(), goAwayFrame.getPayload());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateGoAway(ByteBufferPool.Lease lease, int lastStreamId, int error, byte[] payload)
|
public int generateGoAway(ByteBufferPool.Lease lease, int lastStreamId, int error, byte[] payload)
|
||||||
{
|
{
|
||||||
if (lastStreamId < 0)
|
if (lastStreamId < 0)
|
||||||
throw new IllegalArgumentException("Invalid last stream id: " + lastStreamId);
|
throw new IllegalArgumentException("Invalid last stream id: " + lastStreamId);
|
||||||
|
|
|
@ -50,13 +50,13 @@ public class HeadersGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
HeadersFrame headersFrame = (HeadersFrame)frame;
|
HeadersFrame headersFrame = (HeadersFrame)frame;
|
||||||
return generateHeaders(lease, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream());
|
return generateHeaders(lease, headersFrame.getStreamId(), headersFrame.getMetaData(), headersFrame.getPriority(), headersFrame.isEndStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateHeaders(ByteBufferPool.Lease lease, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream)
|
public int generateHeaders(ByteBufferPool.Lease lease, int streamId, MetaData metaData, PriorityFrame priority, boolean endStream)
|
||||||
{
|
{
|
||||||
if (streamId < 0)
|
if (streamId < 0)
|
||||||
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class PingGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
PingFrame pingFrame = (PingFrame)frame;
|
PingFrame pingFrame = (PingFrame)frame;
|
||||||
return generatePing(lease, pingFrame.getPayload(), pingFrame.isReply());
|
return generatePing(lease, pingFrame.getPayload(), pingFrame.isReply());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generatePing(ByteBufferPool.Lease lease, byte[] payload, boolean reply)
|
public int generatePing(ByteBufferPool.Lease lease, byte[] payload, boolean reply)
|
||||||
{
|
{
|
||||||
if (payload.length != PingFrame.PING_LENGTH)
|
if (payload.length != PingFrame.PING_LENGTH)
|
||||||
throw new IllegalArgumentException("Invalid payload length: " + payload.length);
|
throw new IllegalArgumentException("Invalid payload length: " + payload.length);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class PrefaceGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
lease.append(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES), false);
|
lease.append(ByteBuffer.wrap(PrefaceFrame.PREFACE_BYTES), false);
|
||||||
return PrefaceFrame.PREFACE_BYTES.length;
|
return PrefaceFrame.PREFACE_BYTES.length;
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class PriorityGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
PriorityFrame priorityFrame = (PriorityFrame)frame;
|
PriorityFrame priorityFrame = (PriorityFrame)frame;
|
||||||
return generatePriority(lease, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive());
|
return generatePriority(lease, priorityFrame.getStreamId(), priorityFrame.getParentStreamId(), priorityFrame.getWeight(), priorityFrame.isExclusive());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generatePriority(ByteBufferPool.Lease lease, int streamId, int parentStreamId, int weight, boolean exclusive)
|
public int generatePriority(ByteBufferPool.Lease lease, int streamId, int parentStreamId, int weight, boolean exclusive)
|
||||||
{
|
{
|
||||||
ByteBuffer header = generateHeader(lease, FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId);
|
ByteBuffer header = generateHeader(lease, FrameType.PRIORITY, PriorityFrame.PRIORITY_LENGTH, Flags.NONE, streamId);
|
||||||
generatePriorityBody(header, streamId, parentStreamId, weight, exclusive);
|
generatePriorityBody(header, streamId, parentStreamId, weight, exclusive);
|
||||||
|
|
|
@ -40,13 +40,13 @@ public class PushPromiseGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame;
|
PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame;
|
||||||
return generatePushPromise(lease, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData());
|
return generatePushPromise(lease, pushPromiseFrame.getStreamId(), pushPromiseFrame.getPromisedStreamId(), pushPromiseFrame.getMetaData());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generatePushPromise(ByteBufferPool.Lease lease, int streamId, int promisedStreamId, MetaData metaData)
|
public int generatePushPromise(ByteBufferPool.Lease lease, int streamId, int promisedStreamId, MetaData metaData)
|
||||||
{
|
{
|
||||||
if (streamId < 0)
|
if (streamId < 0)
|
||||||
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class ResetGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
ResetFrame resetFrame = (ResetFrame)frame;
|
ResetFrame resetFrame = (ResetFrame)frame;
|
||||||
return generateReset(lease, resetFrame.getStreamId(), resetFrame.getError());
|
return generateReset(lease, resetFrame.getStreamId(), resetFrame.getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateReset(ByteBufferPool.Lease lease, int streamId, int error)
|
public int generateReset(ByteBufferPool.Lease lease, int streamId, int error)
|
||||||
{
|
{
|
||||||
if (streamId < 0)
|
if (streamId < 0)
|
||||||
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
throw new IllegalArgumentException("Invalid stream id: " + streamId);
|
||||||
|
|
|
@ -36,13 +36,13 @@ public class SettingsGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
SettingsFrame settingsFrame = (SettingsFrame)frame;
|
SettingsFrame settingsFrame = (SettingsFrame)frame;
|
||||||
return generateSettings(lease, settingsFrame.getSettings(), settingsFrame.isReply());
|
return generateSettings(lease, settingsFrame.getSettings(), settingsFrame.isReply());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateSettings(ByteBufferPool.Lease lease, Map<Integer, Integer> settings, boolean reply)
|
public int generateSettings(ByteBufferPool.Lease lease, Map<Integer, Integer> settings, boolean reply)
|
||||||
{
|
{
|
||||||
// Two bytes for the identifier, four bytes for the value.
|
// Two bytes for the identifier, four bytes for the value.
|
||||||
int entryLength = 2 + 4;
|
int entryLength = 2 + 4;
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class WindowUpdateGenerator extends FrameGenerator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long generate(ByteBufferPool.Lease lease, Frame frame)
|
public int generate(ByteBufferPool.Lease lease, Frame frame)
|
||||||
{
|
{
|
||||||
WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame;
|
WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame;
|
||||||
return generateWindowUpdate(lease, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta());
|
return generateWindowUpdate(lease, windowUpdateFrame.getStreamId(), windowUpdateFrame.getWindowDelta());
|
||||||
}
|
}
|
||||||
|
|
||||||
public long generateWindowUpdate(ByteBufferPool.Lease lease, int streamId, int windowUpdate)
|
public int generateWindowUpdate(ByteBufferPool.Lease lease, int streamId, int windowUpdate)
|
||||||
{
|
{
|
||||||
if (windowUpdate < 0)
|
if (windowUpdate < 0)
|
||||||
throw new IllegalArgumentException("Invalid window update: " + windowUpdate);
|
throw new IllegalArgumentException("Invalid window update: " + windowUpdate);
|
||||||
|
|
Loading…
Reference in New Issue