Issue #922 - Implements methods Connection.getBytes[In|Out]().

Using int rather than long as return value for generated bytes.
This commit is contained in:
Simone Bordet 2016-09-14 16:57:11 +02:00
parent aa00e4207d
commit 464dd0667a
14 changed files with 27 additions and 27 deletions

View File

@ -1108,7 +1108,7 @@ public abstract class HTTP2Session extends ContainerLifeCycle implements ISessio
private class ControlEntry extends HTTP2Flusher.Entry
{
private long bytes;
private int bytes;
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 int length;
private long bytes;
private int bytes;
private DataEntry(DataFrame frame, IStream stream, Callback callback)
{

View File

@ -36,12 +36,12 @@ public class DataGenerator
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);
}
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)
throw new IllegalArgumentException("Invalid stream id: " + streamId);
@ -61,7 +61,7 @@ public class DataGenerator
if (frames * maxFrameSize != length)
++frames;
long totalLength = 0;
int totalLength = 0;
int begin = data.position();
int end = data.limit();
for (int i = 1; i <= frames; ++i)
@ -77,7 +77,7 @@ public class DataGenerator
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();

View File

@ -29,7 +29,7 @@ public class DisconnectGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
return 0;
}

View File

@ -33,7 +33,7 @@ public abstract class FrameGenerator
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)
{

View File

@ -75,12 +75,12 @@ public class Generator
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);
}
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);
}

View File

@ -36,13 +36,13 @@ public class GoAwayGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
GoAwayFrame goAwayFrame = (GoAwayFrame)frame;
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)
throw new IllegalArgumentException("Invalid last stream id: " + lastStreamId);

View File

@ -50,13 +50,13 @@ public class HeadersGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
HeadersFrame headersFrame = (HeadersFrame)frame;
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)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -35,13 +35,13 @@ public class PingGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
PingFrame pingFrame = (PingFrame)frame;
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)
throw new IllegalArgumentException("Invalid payload length: " + payload.length);

View File

@ -32,7 +32,7 @@ public class PrefaceGenerator extends FrameGenerator
}
@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);
return PrefaceFrame.PREFACE_BYTES.length;

View File

@ -35,13 +35,13 @@ public class PriorityGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
PriorityFrame priorityFrame = (PriorityFrame)frame;
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);
generatePriorityBody(header, streamId, parentStreamId, weight, exclusive);

View File

@ -40,13 +40,13 @@ public class PushPromiseGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
PushPromiseFrame pushPromiseFrame = (PushPromiseFrame)frame;
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)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -35,13 +35,13 @@ public class ResetGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
ResetFrame resetFrame = (ResetFrame)frame;
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)
throw new IllegalArgumentException("Invalid stream id: " + streamId);

View File

@ -36,13 +36,13 @@ public class SettingsGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
SettingsFrame settingsFrame = (SettingsFrame)frame;
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.
int entryLength = 2 + 4;

View File

@ -35,13 +35,13 @@ public class WindowUpdateGenerator extends FrameGenerator
}
@Override
public long generate(ByteBufferPool.Lease lease, Frame frame)
public int generate(ByteBufferPool.Lease lease, Frame frame)
{
WindowUpdateFrame windowUpdateFrame = (WindowUpdateFrame)frame;
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)
throw new IllegalArgumentException("Invalid window update: " + windowUpdate);