Merge remote-tracking branch 'upstream/3' into feature/zerocopyframedecoder

This commit is contained in:
Gerd Behrmann 2012-06-19 19:10:42 +02:00
commit a3f46b5359
40 changed files with 973 additions and 337 deletions

View File

@ -26,7 +26,7 @@
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
<packaging>bundle</packaging>
<version>3.5.0.Final</version>
<version>3.5.1.Final-SNAPSHOT</version>
<name>The Netty Project</name>
<url>http://netty.io/</url>
@ -665,7 +665,7 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netty-build</artifactId>
<version>8</version>
<version>9</version>
</dependency>
</dependencies>
</plugin>

View File

@ -34,6 +34,7 @@
<include>**/src/**</include>
</includes>
<excludes>
<exclude>**/bin/**</exclude>
<exclude>**/target/**</exclude>
<exclude>**/.*/**</exclude>
</excludes>

View File

@ -0,0 +1,288 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package org.jboss.netty.handler.codec.compression;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.zip.CRC32;
import java.util.zip.Deflater;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.ChannelFutureListener;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.channel.ChannelStateEvent;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.LifeCycleAwareChannelHandler;
import org.jboss.netty.handler.codec.oneone.OneToOneEncoder;
/**
* Compresses a {@link ChannelBuffer} using the deflate algorithm.
* @apiviz.landmark
* @apiviz.has org.jboss.netty.handler.codec.compression.ZlibWrapper
*/
public class JdkZlibEncoder extends OneToOneEncoder implements LifeCycleAwareChannelHandler {
private final byte[] out = new byte[8192];
private final Deflater deflater;
private final AtomicBoolean finished = new AtomicBoolean();
private volatile ChannelHandlerContext ctx;
/*
* GZIP support
*/
private final boolean gzip;
private final CRC32 crc = new CRC32();
private static final byte[] gzipHeader = {0x1f, (byte) 0x8b, Deflater.DEFLATED, 0, 0, 0, 0, 0, 0, 0};
private boolean writeHeader = true;
/**
* Creates a new zlib encoder with the default compression level ({@code 6})
* and the default wrapper ({@link ZlibWrapper#ZLIB}).
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder() {
this(6);
}
/**
* Creates a new zlib encoder with the specified {@code compressionLevel}
* and the default wrapper ({@link ZlibWrapper#ZLIB}).
*
* @param compressionLevel
* {@code 1} yields the fastest compression and {@code 9} yields the
* best compression. {@code 0} means no compression. The default
* compression level is {@code 6}.
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder(int compressionLevel) {
this(ZlibWrapper.ZLIB, compressionLevel);
}
/**
* Creates a new zlib encoder with the default compression level ({@code 6})
* and the specified wrapper.
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder(ZlibWrapper wrapper) {
this(wrapper, 6);
}
/**
* Creates a new zlib encoder with the specified {@code compressionLevel}
* and the specified wrapper.
*
* @param compressionLevel
* {@code 1} yields the fastest compression and {@code 9} yields the
* best compression. {@code 0} means no compression. The default
* compression level is {@code 6}.
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder(ZlibWrapper wrapper, int compressionLevel) {
if (compressionLevel < 0 || compressionLevel > 9) {
throw new IllegalArgumentException(
"compressionLevel: " + compressionLevel + " (expected: 0-9)");
}
if (wrapper == null) {
throw new NullPointerException("wrapper");
}
if (wrapper == ZlibWrapper.ZLIB_OR_NONE) {
throw new IllegalArgumentException(
"wrapper '" + ZlibWrapper.ZLIB_OR_NONE + "' is not " +
"allowed for compression.");
}
gzip = wrapper == ZlibWrapper.GZIP;
deflater = new Deflater(compressionLevel, wrapper != ZlibWrapper.ZLIB);
}
/**
* Creates a new zlib encoder with the default compression level ({@code 6})
* and the specified preset dictionary. The wrapper is always
* {@link ZlibWrapper#ZLIB} because it is the only format that supports
* the preset dictionary.
*
* @param dictionary the preset dictionary
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder(byte[] dictionary) {
this(6, dictionary);
}
/**
* Creates a new zlib encoder with the specified {@code compressionLevel}
* and the specified preset dictionary. The wrapper is always
* {@link ZlibWrapper#ZLIB} because it is the only format that supports
* the preset dictionary.
*
* @param compressionLevel
* {@code 1} yields the fastest compression and {@code 9} yields the
* best compression. {@code 0} means no compression. The default
* compression level is {@code 6}.
* @param dictionary the preset dictionary
*
* @throws CompressionException if failed to initialize zlib
*/
public JdkZlibEncoder(int compressionLevel, byte[] dictionary) {
if (compressionLevel < 0 || compressionLevel > 9) {
throw new IllegalArgumentException(
"compressionLevel: " + compressionLevel + " (expected: 0-9)");
}
if (dictionary == null) {
throw new NullPointerException("dictionary");
}
gzip = false;
deflater = new Deflater(compressionLevel);
deflater.setDictionary(dictionary);
}
public ChannelFuture close() {
ChannelHandlerContext ctx = this.ctx;
if (ctx == null) {
throw new IllegalStateException("not added to a pipeline");
}
return finishEncode(ctx, null);
}
public boolean isClosed() {
return finished.get();
}
@Override
protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
if (!(msg instanceof ChannelBuffer) || finished.get()) {
return msg;
}
ChannelBuffer uncompressed = (ChannelBuffer) msg;
byte[] in = new byte[uncompressed.readableBytes()];
uncompressed.readBytes(in);
int sizeEstimate = (int) Math.ceil(in.length * 1.001) + 12;
ChannelBuffer compressed = ChannelBuffers.dynamicBuffer(sizeEstimate, channel.getConfig().getBufferFactory());
synchronized (deflater) {
if (gzip) {
crc.update(in);
if (writeHeader) {
compressed.writeBytes(gzipHeader);
writeHeader = false;
}
}
deflater.setInput(in);
while (!deflater.needsInput()) {
int numBytes = deflater.deflate(out, 0, out.length, Deflater.SYNC_FLUSH);
compressed.writeBytes(out, 0, numBytes);
}
}
return compressed;
}
@Override
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent evt)
throws Exception {
if (evt instanceof ChannelStateEvent) {
ChannelStateEvent e = (ChannelStateEvent) evt;
switch (e.getState()) {
case OPEN:
case CONNECTED:
case BOUND:
if (Boolean.FALSE.equals(e.getValue()) || e.getValue() == null) {
finishEncode(ctx, evt);
return;
}
}
}
super.handleDownstream(ctx, evt);
}
private ChannelFuture finishEncode(final ChannelHandlerContext ctx, final ChannelEvent evt) {
if (!finished.compareAndSet(false, true)) {
if (evt != null) {
ctx.sendDownstream(evt);
}
return Channels.succeededFuture(ctx.getChannel());
}
ChannelBuffer footer = ChannelBuffers.EMPTY_BUFFER;
synchronized (deflater) {
int numBytes = 0;
deflater.finish();
if (!deflater.finished()) {
numBytes = deflater.deflate(out, 0, out.length);
}
int footerSize = gzip ? numBytes + 8 : numBytes;
if (footerSize > 0) {
footer = ctx.getChannel().getConfig().getBufferFactory().getBuffer(footerSize);
footer.writeBytes(out, 0, numBytes);
if (gzip) {
int crcValue = (int) crc.getValue();
int uncBytes = deflater.getTotalIn();
footer.writeByte(crcValue);
footer.writeByte(crcValue >>> 8);
footer.writeByte(crcValue >>> 16);
footer.writeByte(crcValue >>> 24);
footer.writeByte(uncBytes);
footer.writeByte(uncBytes >>> 8);
footer.writeByte(uncBytes >>> 16);
footer.writeByte(uncBytes >>> 24);
}
}
deflater.end();
}
ChannelFuture future = Channels.future(ctx.getChannel());
Channels.write(ctx, future, footer);
if (evt != null) {
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture future) throws Exception {
ctx.sendDownstream(evt);
}
});
}
return future;
}
public void beforeAdd(ChannelHandlerContext ctx) throws Exception {
this.ctx = ctx;
}
public void afterAdd(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void beforeRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// Unused
}
}

View File

@ -20,6 +20,7 @@ import java.net.SocketAddress;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBufferFactory;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.buffer.CompositeChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
@ -181,6 +182,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
private final boolean unfold;
protected ChannelBuffer cumulation;
private volatile ChannelHandlerContext ctx;
private int copyThreshold;
protected FrameDecoder() {
this(false);
@ -190,6 +192,48 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
this.unfold = unfold;
}
/**
* See {@link #setMaxCumulationBufferCapacity(int)} for explaintation of this setting
*
*/
public final int getMaxCumulationBufferCapacity() {
return copyThreshold;
}
/**
* Set the maximal capacity of the internal cumulation ChannelBuffer to use
* before the {@link FrameDecoder} tries to minimize the memory usage by
* "byte copy".
*
*
* What you use here really depends on your application and need. Using
* {@link Integer#MAX_VALUE} will disable all byte copies but give you the
* cost of a higher memory usage if big {@link ChannelBuffer}'s will be
* received.
*
* By default a threshold of <code>0</code> is used, which means it will
* always copy to try to reduce memory usage
*
*
* @param copyThreshold
* the threshold (in bytes) or {@link Integer#MAX_VALUE} to
* disable it. The value must be at least 0
* @throws IllegalStateException
* get thrown if someone tries to change this setting after the
* Decoder was added to the {@link ChannelPipeline}
*/
public final void setMaxCumulationBufferCapacity(int copyThreshold) {
if (copyThreshold < 0) {
throw new IllegalArgumentException("MaxCumulationBufferCapacity must be >= 0");
}
if (ctx == null) {
this.copyThreshold = copyThreshold;
} else {
throw new IllegalStateException("MaxCumulationBufferCapacity " +
"can only be changed before the Decoder was added to the ChannelPipeline");
}
}
@Override
public void messageReceived(
ChannelHandlerContext ctx, MessageEvent e) throws Exception {
@ -213,43 +257,35 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
// the cumulation buffer is not created yet so just pass the input to callDecode(...) method
callDecode(ctx, e.getChannel(), input, e.getRemoteAddress());
} finally {
if (input.readable()) {
// seems like there is something readable left in the input buffer. So create
// the cumulation buffer and copy the input into it
(cumulation = newCumulationBuffer(ctx, input.readableBytes())).writeBytes(input);
int readable = input.readableBytes();
if (readable > 0) {
int cap = input.capacity();
// check if readableBytes == capacity we can safe the copy as we will not be able to
// optimize memory usage anyway
if (readable != cap && cap > copyThreshold) {
// seems like there is something readable left in the input buffer. So create
// the cumulation buffer and copy the input into it
cumulation = newCumulationBuffer(ctx, input.readableBytes());
cumulation.writeBytes(input);
} else {
// just use the input as cumulation buffer for now
cumulation = input;
}
}
}
} else {
assert cumulation.readable();
boolean fit = false;
int readable = input.readableBytes();
int writable = cumulation.writableBytes();
int w = writable - readable;
if (w < 0) {
int readerIndex = cumulation.readerIndex();
if (w + readerIndex >= 0) {
// the input will fit if we discard all read bytes, so do it
cumulation.discardReadBytes();
fit = true;
}
} else {
// ok the input fit into the cumulation buffer
fit = true;
}
ChannelBuffer buf;
if (fit) {
// the input fit in the cumulation buffer so copy it over
buf = cumulation;
buf.writeBytes(input);
} else {
// wrap the cumulation and input
buf = ChannelBuffers.wrappedBuffer(cumulation, input);
cumulation = buf;
}
// wrap the cumulation and input
//
// We use a CompositeBuffer all the time as its always faster the
// byte-copy if the wrapped buffer count == 2
ChannelBuffer buf = ChannelBuffers.wrappedBuffer(cumulation, input);
cumulation = buf;
// Wrap in try / finally.
//
@ -257,13 +293,34 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
try {
callDecode(ctx, e.getChannel(), buf, e.getRemoteAddress());
} finally {
if (!buf.readable()) {
int readable = buf.readableBytes();
if (readable == 0) {
// nothing readable left so reset the state
cumulation = null;
} else {
// create a new buffer and copy the readable buffer into it
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
cumulation.writeBytes(buf);
int cap = buf.capacity();
if (readable != cap && cap > copyThreshold) {
// the readable bytes are > as the configured
// copyThreshold, so create a new buffer and copy the
// bytes into it
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
cumulation.writeBytes(buf);
} else {
if (readable == cap) {
cumulation = buf;
} else {
// create a new cumulation buffer that holds the
// unwrapped parts of the CompositeChannelBuffer
// that are not read yet.
cumulation = ChannelBuffers.wrappedBuffer(((CompositeChannelBuffer) buf)
.decompose(buf.readerIndex(), buf.readableBytes())
.toArray(new ChannelBuffer[0]));
}
}
}
}

View File

@ -16,9 +16,11 @@
package org.jboss.netty.handler.codec.http;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.handler.codec.compression.JdkZlibEncoder;
import org.jboss.netty.handler.codec.compression.ZlibEncoder;
import org.jboss.netty.handler.codec.compression.ZlibWrapper;
import org.jboss.netty.handler.codec.embedder.EncoderEmbedder;
import org.jboss.netty.util.internal.DetectionUtil;
/**
* Compresses an {@link HttpMessage} and an {@link HttpChunk} in {@code gzip} or
@ -98,8 +100,13 @@ public class HttpContentCompressor extends HttpContentEncoder {
return null;
}
return new EncoderEmbedder<ChannelBuffer>(
new ZlibEncoder(wrapper, compressionLevel, windowBits, memLevel));
if (DetectionUtil.javaVersion() >= 7) {
return new EncoderEmbedder<ChannelBuffer>(
new JdkZlibEncoder(wrapper, compressionLevel));
} else {
return new EncoderEmbedder<ChannelBuffer>(
new ZlibEncoder(wrapper, compressionLevel, windowBits, memLevel));
}
}
@Override

View File

@ -289,10 +289,17 @@ public abstract class AbstractDiskHttpData extends AbstractHttpData {
FileOutputStream outputStream = new FileOutputStream(dest);
FileChannel in = inputStream.getChannel();
FileChannel out = outputStream.getChannel();
long destsize = in.transferTo(0, size, out);
int chunkSize = 8196;
long position = 0;
while (position < size) {
if (chunkSize < size - position) {
chunkSize = (int) (size - position);
}
position += in.transferTo(position, chunkSize , out);
}
in.close();
out.close();
if (destsize == size) {
if (position == size) {
file.delete();
file = dest;
isRenamed = true;

View File

@ -19,6 +19,7 @@ import java.net.SocketAddress;
import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.buffer.CompositeChannelBuffer;
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelHandler;
import org.jboss.netty.channel.ChannelHandlerContext;
@ -439,26 +440,51 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
input, replayable,
e.getRemoteAddress());
} finally {
if (input.readable()) {
int readable = input.readableBytes();
if (readable > 0) {
int cap = input.capacity();
boolean copy = false;
// check if readableBytes == capacity we can safe the copy as we will not be able to
// optimize memory usage anyway
if (readable != cap && cap > getMaxCumulationBufferCapacity()) {
copy = true;
}
// seems like there is something readable left in the input buffer
// or decoder wants a replay - create the cumulation buffer and
// copy the input into it
ChannelBuffer cumulation;
if (checkpoint > 0) {
int bytesToPreserve = inputSize - (checkpoint - oldReaderIndex);
cumulation = this.cumulation =
newCumulationBuffer(ctx, bytesToPreserve);
cumulation.writeBytes(input, checkpoint, bytesToPreserve);
if (copy) {
cumulation = this.cumulation =
newCumulationBuffer(ctx, bytesToPreserve);
cumulation.writeBytes(input, checkpoint, bytesToPreserve);
} else {
cumulation = this.cumulation =
input.slice(checkpoint, bytesToPreserve);
}
} else if (checkpoint == 0) {
cumulation = this.cumulation =
newCumulationBuffer(ctx, inputSize);
cumulation.writeBytes(input, oldReaderIndex, inputSize);
cumulation.readerIndex(input.readerIndex());
if (copy) {
cumulation = this.cumulation =
newCumulationBuffer(ctx, inputSize);
cumulation.writeBytes(input, oldReaderIndex, inputSize);
cumulation.readerIndex(input.readerIndex());
} else {
cumulation = this.cumulation =
input.slice(oldReaderIndex, inputSize);
cumulation.readerIndex(input.readerIndex());
}
} else {
cumulation = this.cumulation =
newCumulationBuffer(ctx, input.readableBytes());
cumulation.writeBytes(input);
if (copy) {
cumulation = this.cumulation =
newCumulationBuffer(ctx, input.readableBytes());
cumulation.writeBytes(input);
} else {
cumulation = this.cumulation =
input;
}
}
replayable = new ReplayingDecoderBuffer(cumulation);
} else {
@ -469,35 +495,10 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
} else {
assert cumulation.readable();
boolean fit = false;
int readable = input.readableBytes();
int writable = cumulation.writableBytes();
int w = writable - readable;
if (w < 0) {
int readerIndex = cumulation.readerIndex();
if (w + readerIndex >= 0) {
// the input will fit if we discard all read bytes, so do it
cumulation.discardReadBytes();
fit = true;
}
} else {
// ok the input fit into the cumulation buffer
fit = true;
}
ChannelBuffer buf;
if (fit) {
// the input fit in the cumulation buffer so copy it over
buf = cumulation;
buf.writeBytes(input);
} else {
// wrap the cumulation and input
buf = ChannelBuffers.wrappedBuffer(cumulation, input);
cumulation = buf;
replayable = new ReplayingDecoderBuffer(cumulation);
}
// wrap the cumulation and input
ChannelBuffer buf = ChannelBuffers.wrappedBuffer(cumulation, input);
cumulation = buf;
replayable = new ReplayingDecoderBuffer(cumulation);
// Wrap in try / finally.
//
@ -505,16 +506,35 @@ public abstract class ReplayingDecoder<T extends Enum<T>>
try {
callDecode(ctx, e.getChannel(), buf, replayable, e.getRemoteAddress());
} finally {
if (!buf.readable()) {
int readable = buf.readableBytes();
if (readable == 0) {
// nothing readable left so reset the state
cumulation = null;
replayable = ReplayingDecoderBuffer.EMPTY_BUFFER;
} else {
// create a new buffer and copy the readable buffer into it
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
cumulation.writeBytes(buf);
replayable = new ReplayingDecoderBuffer(cumulation);
int cap = buf.capacity();
if (readable != cap && cap > getMaxCumulationBufferCapacity()) {
// the readable bytes are > as the configured
// copyThreshold, so create a new buffer and copy the
// bytes into it
cumulation = newCumulationBuffer(ctx, buf.readableBytes());
cumulation.writeBytes(buf);
} else {
if (readable == cap) {
cumulation = buf;
} else {
// create a new cumulation buffer that holds the
// unwrapped parts of the CompositeChannelBuffer
// that are not read yet.
cumulation = ChannelBuffers.wrappedBuffer(((CompositeChannelBuffer) buf)
.decompose(buf.readerIndex(), buf.readableBytes())
.toArray(new ChannelBuffer[0]));
}
}
replayable = new ReplayingDecoderBuffer(cumulation);
}
}

View File

@ -24,7 +24,7 @@ import org.jboss.netty.util.internal.StringUtil;
*/
public class DefaultSpdyDataFrame implements SpdyDataFrame {
private int streamID;
private int streamId;
private boolean last;
private boolean compressed;
private ChannelBuffer data = ChannelBuffers.EMPTY_BUFFER;
@ -32,22 +32,30 @@ public class DefaultSpdyDataFrame implements SpdyDataFrame {
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
*/
public DefaultSpdyDataFrame(int streamID) {
setStreamID(streamID);
public DefaultSpdyDataFrame(int streamId) {
setStreamId(streamId);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public boolean isLast() {
@ -92,7 +100,7 @@ public class DefaultSpdyDataFrame implements SpdyDataFrame {
buf.append(')');
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Size = ");
buf.append(data.readableBytes());

View File

@ -22,49 +22,57 @@ import org.jboss.netty.util.internal.StringUtil;
*/
public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
private int lastGoodStreamID;
private int lastGoodStreamId;
private SpdySessionStatus status;
/**
* Creates a new instance.
*
* @param lastGoodStreamID the Last-good-stream-ID of this frame
* @param lastGoodStreamId the Last-good-stream-ID of this frame
*/
public DefaultSpdyGoAwayFrame(int lastGoodStreamID) {
this(lastGoodStreamID, 0);
public DefaultSpdyGoAwayFrame(int lastGoodStreamId) {
this(lastGoodStreamId, 0);
}
/**
* Creates a new instance.
*
* @param lastGoodStreamID the Last-good-stream-ID of this frame
* @param lastGoodStreamId the Last-good-stream-ID of this frame
* @param statusCode the Status code of this frame
*/
public DefaultSpdyGoAwayFrame(int lastGoodStreamID, int statusCode) {
this(lastGoodStreamID, SpdySessionStatus.valueOf(statusCode));
public DefaultSpdyGoAwayFrame(int lastGoodStreamId, int statusCode) {
this(lastGoodStreamId, SpdySessionStatus.valueOf(statusCode));
}
/**
* Creates a new instance.
*
* @param lastGoodStreamID the Last-good-stream-ID of this frame
* @param lastGoodStreamId the Last-good-stream-ID of this frame
* @param status the status of this frame
*/
public DefaultSpdyGoAwayFrame(int lastGoodStreamID, SpdySessionStatus status) {
setLastGoodStreamID(lastGoodStreamID);
public DefaultSpdyGoAwayFrame(int lastGoodStreamId, SpdySessionStatus status) {
setLastGoodStreamId(lastGoodStreamId);
setStatus(status);
}
public int getLastGoodStreamID() {
return lastGoodStreamID;
return getLastGoodStreamId();
}
public void setLastGoodStreamID(int lastGoodStreamID) {
if (lastGoodStreamID < 0) {
public int getLastGoodStreamId() {
return lastGoodStreamId;
}
public void setLastGoodStreamID(int lastGoodStreamId) {
setLastGoodStreamId(lastGoodStreamId);
}
public void setLastGoodStreamId(int lastGoodStreamId) {
if (lastGoodStreamId < 0) {
throw new IllegalArgumentException("Last-good-stream-ID"
+ " cannot be negative: " + lastGoodStreamID);
+ " cannot be negative: " + lastGoodStreamId);
}
this.lastGoodStreamID = lastGoodStreamID;
this.lastGoodStreamId = lastGoodStreamId;
}
public SpdySessionStatus getStatus() {
@ -81,7 +89,7 @@ public class DefaultSpdyGoAwayFrame implements SpdyGoAwayFrame {
buf.append(getClass().getSimpleName());
buf.append(StringUtil.NEWLINE);
buf.append("--> Last-good-stream-ID = ");
buf.append(lastGoodStreamID);
buf.append(lastGoodStreamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Status: ");
buf.append(status.toString());

View File

@ -24,29 +24,37 @@ import org.jboss.netty.util.internal.StringUtil;
public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
implements SpdyHeadersFrame {
private int streamID;
private int streamId;
private boolean last;
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
*/
public DefaultSpdyHeadersFrame(int streamID) {
public DefaultSpdyHeadersFrame(int streamId) {
super();
setStreamID(streamID);
setStreamId(streamId);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public boolean isLast() {
@ -66,7 +74,7 @@ public class DefaultSpdyHeadersFrame extends DefaultSpdyHeaderBlock
buf.append(')');
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Headers:");
buf.append(StringUtil.NEWLINE);

View File

@ -22,23 +22,31 @@ import org.jboss.netty.util.internal.StringUtil;
*/
public class DefaultSpdyPingFrame implements SpdyPingFrame {
private int ID;
private int id;
/**
* Creates a new instance.
*
* @param ID the unique ID of this frame
* @param id the unique ID of this frame
*/
public DefaultSpdyPingFrame(int ID) {
setID(ID);
public DefaultSpdyPingFrame(int id) {
setId(id);
}
public int getID() {
return ID;
return getId();
}
public void setID(int ID) {
this.ID = ID;
public int getId() {
return id;
}
public void setID(int id) {
setId(id);
}
public void setId(int id) {
this.id = id;
}
@Override
@ -47,7 +55,7 @@ public class DefaultSpdyPingFrame implements SpdyPingFrame {
buf.append(getClass().getSimpleName());
buf.append(StringUtil.NEWLINE);
buf.append("--> ID = ");
buf.append(ID);
buf.append(id);
return buf.toString();
}
}

View File

@ -22,40 +22,48 @@ import org.jboss.netty.util.internal.StringUtil;
*/
public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
private int streamID;
private int streamId;
private SpdyStreamStatus status;
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
* @param statusCode the Status code of this frame
*/
public DefaultSpdyRstStreamFrame(int streamID, int statusCode) {
this(streamID, SpdyStreamStatus.valueOf(statusCode));
public DefaultSpdyRstStreamFrame(int streamId, int statusCode) {
this(streamId, SpdyStreamStatus.valueOf(statusCode));
}
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
* @param status the status of this frame
*/
public DefaultSpdyRstStreamFrame(int streamID, SpdyStreamStatus status) {
setStreamID(streamID);
public DefaultSpdyRstStreamFrame(int streamId, SpdyStreamStatus status) {
setStreamId(streamId);
setStatus(status);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public SpdyStreamStatus getStatus() {
@ -72,7 +80,7 @@ public class DefaultSpdyRstStreamFrame implements SpdyRstStreamFrame {
buf.append(getClass().getSimpleName());
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Status: ");
buf.append(status.toString());

View File

@ -36,6 +36,10 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
}
public Set<Integer> getIDs() {
return getIds();
}
public Set<Integer> getIds() {
return settingsMap.keySet();
}
@ -80,9 +84,13 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
}
public boolean persistValue(int ID) {
return isPersistValue(ID);
}
public boolean isPersistValue(int ID) {
Integer key = new Integer(ID);
if (settingsMap.containsKey(key)) {
return settingsMap.get(key).getPersist();
return settingsMap.get(key).isPersist();
} else {
return false;
}
@ -98,7 +106,7 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
public boolean isPersisted(int ID) {
Integer key = new Integer(ID);
if (settingsMap.containsKey(key)) {
return settingsMap.get(key).getPersisted();
return settingsMap.get(key).isPersisted();
} else {
return false;
}
@ -131,9 +139,9 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
buf.append(":");
buf.append(setting.getValue());
buf.append(" (persist value: ");
buf.append(setting.getPersist());
buf.append(setting.isPersist());
buf.append("; persisted: ");
buf.append(setting.getPersisted());
buf.append(setting.isPersisted());
buf.append(')');
buf.append(StringUtil.NEWLINE);
}
@ -155,33 +163,33 @@ public class DefaultSpdySettingsFrame implements SpdySettingsFrame {
private boolean persist;
private boolean persisted;
public Setting(int value, boolean persist, boolean persisted) {
Setting(int value, boolean persist, boolean persisted) {
this.value = value;
this.persist = persist;
this.persisted = persisted;
}
public int getValue() {
int getValue() {
return value;
}
public void setValue(int value) {
void setValue(int value) {
this.value = value;
}
public boolean getPersist() {
boolean isPersist() {
return persist;
}
public void setPersist(boolean persist) {
void setPersist(boolean persist) {
this.persist = persist;
}
public boolean getPersisted() {
boolean isPersisted() {
return persisted;
}
public void setPersisted(boolean persisted) {
void setPersisted(boolean persisted) {
this.persisted = persisted;
}
}

View File

@ -23,29 +23,36 @@ import org.jboss.netty.util.internal.StringUtil;
public class DefaultSpdySynReplyFrame extends DefaultSpdyHeaderBlock
implements SpdySynReplyFrame {
private int streamID;
private int streamId;
private boolean last;
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
*/
public DefaultSpdySynReplyFrame(int streamID) {
super();
setStreamID(streamID);
public DefaultSpdySynReplyFrame(int streamId) {
setStreamId(streamId);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public boolean isLast() {
@ -65,7 +72,7 @@ public class DefaultSpdySynReplyFrame extends DefaultSpdyHeaderBlock
buf.append(')');
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Headers:");
buf.append(StringUtil.NEWLINE);

View File

@ -23,8 +23,8 @@ import org.jboss.netty.util.internal.StringUtil;
public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
implements SpdySynStreamFrame {
private int streamID;
private int associatedToStreamID;
private int streamId;
private int associatedToStreamId;
private byte priority;
private boolean last;
private boolean unidirectional;
@ -33,40 +33,55 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param associatedToStreamID the Associated-To-Stream-ID of this frame
* @param associatedToStreamId the Associated-To-Stream-ID of this frame
* @param priority the priority of the stream
*/
public DefaultSpdySynStreamFrame(
int streamID, int associatedToStreamID, byte priority) {
super();
setStreamID(streamID);
setAssociatedToStreamID(associatedToStreamID);
int streamID, int associatedToStreamId, byte priority) {
setStreamId(streamID);
setAssociatedToStreamId(associatedToStreamId);
setPriority(priority);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public int getAssociatedToStreamID() {
return associatedToStreamID;
return getAssociatedToStreamId();
}
public void setAssociatedToStreamID(int associatedToStreamID) {
if (associatedToStreamID < 0) {
public int getAssociatedToStreamId() {
return associatedToStreamId;
}
public void setAssociatedToStreamID(int associatedToStreamId) {
setAssociatedToStreamId(associatedToStreamId);
}
public void setAssociatedToStreamId(int associatedToStreamId) {
if (associatedToStreamId < 0) {
throw new IllegalArgumentException(
"Associated-To-Stream-ID cannot be negative: " +
associatedToStreamID);
associatedToStreamId);
}
this.associatedToStreamID = associatedToStreamID;
this.associatedToStreamId = associatedToStreamId;
}
public byte getPriority() {
@ -108,11 +123,11 @@ public class DefaultSpdySynStreamFrame extends DefaultSpdyHeaderBlock
buf.append(')');
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
if (associatedToStreamID != 0) {
if (associatedToStreamId != 0) {
buf.append("--> Associated-To-Stream-ID = ");
buf.append(associatedToStreamID);
buf.append(associatedToStreamId);
buf.append(StringUtil.NEWLINE);
}
buf.append("--> Priority = ");

View File

@ -22,30 +22,38 @@ import org.jboss.netty.util.internal.StringUtil;
*/
public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
private int streamID;
private int streamId;
private int deltaWindowSize;
/**
* Creates a new instance.
*
* @param streamID the Stream-ID of this frame
* @param streamId the Stream-ID of this frame
* @param deltaWindowSize the Delta-Window-Size of this frame
*/
public DefaultSpdyWindowUpdateFrame(int streamID, int deltaWindowSize) {
setStreamID(streamID);
public DefaultSpdyWindowUpdateFrame(int streamId, int deltaWindowSize) {
setStreamId(streamId);
setDeltaWindowSize(deltaWindowSize);
}
public int getStreamID() {
return streamID;
return getStreamId();
}
public void setStreamID(int streamID) {
if (streamID <= 0) {
public int getStreamId() {
return streamId;
}
public void setStreamID(int streamId) {
setStreamId(streamId);
}
public void setStreamId(int streamId) {
if (streamId <= 0) {
throw new IllegalArgumentException(
"Stream-ID must be positive: " + streamID);
"Stream-ID must be positive: " + streamId);
}
this.streamID = streamID;
this.streamId = streamId;
}
public int getDeltaWindowSize() {
@ -67,7 +75,7 @@ public class DefaultSpdyWindowUpdateFrame implements SpdyWindowUpdateFrame {
buf.append(getClass().getSimpleName());
buf.append(StringUtil.NEWLINE);
buf.append("--> Stream-ID = ");
buf.append(streamID);
buf.append(streamId);
buf.append(StringUtil.NEWLINE);
buf.append("--> Delta-Window-Size = ");
buf.append(deltaWindowSize);

View File

@ -309,9 +309,9 @@ final class SpdyCodecUtil {
/**
* Returns {@code true} if ID is for a server initiated stream or ping.
*/
static boolean isServerID(int ID) {
static boolean isServerId(int id) {
// Server initiated streams and pings have even IDs
return ID % 2 == 0;
return id % 2 == 0;
}
/**

View File

@ -23,15 +23,27 @@ import org.jboss.netty.buffer.ChannelBuffers;
*/
public interface SpdyDataFrame {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* @deprecated Use {@link #setStreamId(int)} instead.
*/
@Deprecated
void setStreamID(int streamID);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamID);
/**
* Returns {@code true} if this frame is the last frame to be transmitted

View File

@ -111,7 +111,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
byte flags = spdyDataFrame.isLast() ? SPDY_DATA_FLAG_FIN : 0;
ChannelBuffer header = ChannelBuffers.buffer(
ByteOrder.BIG_ENDIAN, SPDY_HEADER_SIZE);
header.writeInt(spdyDataFrame.getStreamID() & 0x7FFFFFFF);
header.writeInt(spdyDataFrame.getStreamId() & 0x7FFFFFFF);
header.writeByte(flags);
header.writeMedium(data.readableBytes());
return ChannelBuffers.wrappedBuffer(header, data);
@ -138,8 +138,8 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(SPDY_SYN_STREAM_FRAME);
frame.writeByte(flags);
frame.writeMedium(length);
frame.writeInt(spdySynStreamFrame.getStreamID());
frame.writeInt(spdySynStreamFrame.getAssociatedToStreamID());
frame.writeInt(spdySynStreamFrame.getStreamId());
frame.writeInt(spdySynStreamFrame.getAssociatedToStreamId());
if (version < 3) {
// Restrict priorities for SPDY/2 to between 0 and 3
byte priority = spdySynStreamFrame.getPriority();
@ -174,7 +174,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(SPDY_SYN_REPLY_FRAME);
frame.writeByte(flags);
frame.writeMedium(length);
frame.writeInt(spdySynReplyFrame.getStreamID());
frame.writeInt(spdySynReplyFrame.getStreamId());
if (version < 3) {
if (data.readableBytes() == 0) {
frame.writeInt(0);
@ -192,7 +192,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(version | 0x8000);
frame.writeShort(SPDY_RST_STREAM_FRAME);
frame.writeInt(8);
frame.writeInt(spdyRstStreamFrame.getStreamID());
frame.writeInt(spdyRstStreamFrame.getStreamId());
frame.writeInt(spdyRstStreamFrame.getStatus().getCode());
return frame;
@ -201,7 +201,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
SpdySettingsFrame spdySettingsFrame = (SpdySettingsFrame) msg;
byte flags = spdySettingsFrame.clearPreviouslyPersistedSettings() ?
SPDY_SETTINGS_CLEAR : 0;
Set<Integer> IDs = spdySettingsFrame.getIDs();
Set<Integer> IDs = spdySettingsFrame.getIds();
int numEntries = IDs.size();
int length = 4 + numEntries * 8;
ChannelBuffer frame = ChannelBuffers.buffer(
@ -214,7 +214,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
for (Integer ID: IDs) {
int id = ID.intValue();
byte ID_flags = (byte) 0;
if (spdySettingsFrame.persistValue(id)) {
if (spdySettingsFrame.isPersistValue(id)) {
ID_flags |= SPDY_SETTINGS_PERSIST_VALUE;
}
if (spdySettingsFrame.isPersisted(id)) {
@ -253,7 +253,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(version | 0x8000);
frame.writeShort(SPDY_PING_FRAME);
frame.writeInt(4);
frame.writeInt(spdyPingFrame.getID());
frame.writeInt(spdyPingFrame.getId());
return frame;
} else if (msg instanceof SpdyGoAwayFrame) {
@ -265,7 +265,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(version | 0x8000);
frame.writeShort(SPDY_GOAWAY_FRAME);
frame.writeInt(length);
frame.writeInt(spdyGoAwayFrame.getLastGoodStreamID());
frame.writeInt(spdyGoAwayFrame.getLastGoodStreamId());
if (version >= 3) {
frame.writeInt(spdyGoAwayFrame.getStatus().getCode());
}
@ -290,7 +290,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(SPDY_HEADERS_FRAME);
frame.writeByte(flags);
frame.writeMedium(length);
frame.writeInt(spdyHeadersFrame.getStreamID());
frame.writeInt(spdyHeadersFrame.getStreamId());
if (version < 3 && data.readableBytes() != 0) {
frame.writeShort(0);
}
@ -304,7 +304,7 @@ public class SpdyFrameEncoder extends OneToOneEncoder {
frame.writeShort(version | 0x8000);
frame.writeShort(SPDY_WINDOW_UPDATE_FRAME);
frame.writeInt(8);
frame.writeInt(spdyWindowUpdateFrame.getStreamID());
frame.writeInt(spdyWindowUpdateFrame.getStreamId());
frame.writeInt(spdyWindowUpdateFrame.getDeltaWindowSize());
return frame;
}

View File

@ -20,16 +20,28 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdyGoAwayFrame {
/**
* @deprecated Use {@link #getLastGoodStreamId()} instead.
*/
@Deprecated
int getLastGoodStreamID();
/**
* Returns the Last-good-stream-ID of this frame.
*/
int getLastGoodStreamID();
int getLastGoodStreamId();
/**
* @deprecated Use {@link #setLastGoodStreamId(int)} instead.
*/
@Deprecated
void setLastGoodStreamID(int lastGoodStreamId);
/**
* Sets the Last-good-stream-ID of this frame. The Last-good-stream-ID
* cannot be negative.
*/
void setLastGoodStreamID(int lastGoodStreamID);
void setLastGoodStreamId(int lastGoodStreamId);
/**
* Returns the status of this frame.

View File

@ -20,15 +20,27 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdyHeadersFrame extends SpdyHeaderBlock {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* @deprecated Use {@link #setStreamId(int)} instead.
*/
@Deprecated
void setStreamID(int streamId);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamId);
/**
* Returns {@code true} if this frame is the last frame to be transmitted

View File

@ -89,11 +89,11 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
// HTTP requests/responses are mapped one-to-one to SPDY streams.
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
if (SpdyCodecUtil.isServerID(streamID)) {
if (SpdyCodecUtil.isServerId(streamID)) {
// SYN_STREAM frames initiated by the server are pushed resources
int associatedToStreamID = spdySynStreamFrame.getAssociatedToStreamID();
int associatedToStreamID = spdySynStreamFrame.getAssociatedToStreamId();
// If a client receives a SYN_STREAM with an Associated-To-Stream-ID of 0
// it must reply with a RST_STREAM with error code INVALID_STREAM
@ -117,8 +117,8 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
HttpResponse httpResponse = createHttpResponse(spdyVersion, spdySynStreamFrame);
// Set the Stream-ID, Associated-To-Stream-ID, Priority, and URL as headers
SpdyHttpHeaders.setStreamID(httpResponse, streamID);
SpdyHttpHeaders.setAssociatedToStreamID(httpResponse, associatedToStreamID);
SpdyHttpHeaders.setStreamId(httpResponse, streamID);
SpdyHttpHeaders.setAssociatedToStreamId(httpResponse, associatedToStreamID);
SpdyHttpHeaders.setPriority(httpResponse, spdySynStreamFrame.getPriority());
SpdyHttpHeaders.setUrl(httpResponse, URL);
@ -141,7 +141,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
HttpRequest httpRequest = createHttpRequest(spdyVersion, spdySynStreamFrame);
// Set the Stream-ID as a header
SpdyHttpHeaders.setStreamID(httpRequest, streamID);
SpdyHttpHeaders.setStreamId(httpRequest, streamID);
if (spdySynStreamFrame.isLast()) {
return httpRequest;
@ -164,13 +164,13 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
} else if (msg instanceof SpdySynReplyFrame) {
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
int streamID = spdySynReplyFrame.getStreamID();
int streamID = spdySynReplyFrame.getStreamId();
try {
HttpResponse httpResponse = createHttpResponse(spdyVersion, spdySynReplyFrame);
// Set the Stream-ID as a header
SpdyHttpHeaders.setStreamID(httpResponse, streamID);
SpdyHttpHeaders.setStreamId(httpResponse, streamID);
if (spdySynReplyFrame.isLast()) {
HttpHeaders.setContentLength(httpResponse, 0);
@ -190,7 +190,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
} else if (msg instanceof SpdyHeadersFrame) {
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
Integer streamID = new Integer(spdyHeadersFrame.getStreamID());
Integer streamID = new Integer(spdyHeadersFrame.getStreamId());
HttpMessage httpMessage = messageMap.get(streamID);
// If message is not in map discard HEADERS frame.
@ -206,7 +206,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
} else if (msg instanceof SpdyDataFrame) {
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
Integer streamID = new Integer(spdyDataFrame.getStreamID());
Integer streamID = new Integer(spdyDataFrame.getStreamId());
HttpMessage httpMessage = messageMap.get(streamID);
// If message is not in map discard Data Frame.
@ -239,7 +239,7 @@ public class SpdyHttpDecoder extends OneToOneDecoder {
} else if (msg instanceof SpdyRstStreamFrame) {
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
Integer streamID = new Integer(spdyRstStreamFrame.getStreamID());
Integer streamID = new Integer(spdyRstStreamFrame.getStreamId());
messageMap.remove(streamID);
}

View File

@ -164,7 +164,7 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
HttpRequest httpRequest = (HttpRequest) msg;
SpdySynStreamFrame spdySynStreamFrame = createSynStreamFrame(httpRequest);
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
ChannelFuture future = getContentFuture(ctx, e, streamID, httpRequest);
Channels.write(ctx, future, spdySynStreamFrame, e.getRemoteAddress());
@ -173,12 +173,12 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
HttpResponse httpResponse = (HttpResponse) msg;
if (httpResponse.containsHeader(SpdyHttpHeaders.Names.ASSOCIATED_TO_STREAM_ID)) {
SpdySynStreamFrame spdySynStreamFrame = createSynStreamFrame(httpResponse);
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
ChannelFuture future = getContentFuture(ctx, e, streamID, httpResponse);
Channels.write(ctx, future, spdySynStreamFrame, e.getRemoteAddress());
} else {
SpdySynReplyFrame spdySynReplyFrame = createSynReplyFrame(httpResponse);
int streamID = spdySynReplyFrame.getStreamID();
int streamID = spdySynReplyFrame.getStreamId();
ChannelFuture future = getContentFuture(ctx, e, streamID, httpResponse);
Channels.write(ctx, future, spdySynReplyFrame, e.getRemoteAddress());
}
@ -262,13 +262,13 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
boolean chunked = httpMessage.isChunked();
// Get the Stream-ID, Associated-To-Stream-ID, Priority, URL, and scheme from the headers
int streamID = SpdyHttpHeaders.getStreamID(httpMessage);
int associatedToStreamID = SpdyHttpHeaders.getAssociatedToStreamID(httpMessage);
int streamID = SpdyHttpHeaders.getStreamId(httpMessage);
int associatedToStreamID = SpdyHttpHeaders.getAssociatedToStreamId(httpMessage);
byte priority = SpdyHttpHeaders.getPriority(httpMessage);
String URL = SpdyHttpHeaders.getUrl(httpMessage);
String scheme = SpdyHttpHeaders.getScheme(httpMessage);
SpdyHttpHeaders.removeStreamID(httpMessage);
SpdyHttpHeaders.removeAssociatedToStreamID(httpMessage);
SpdyHttpHeaders.removeStreamId(httpMessage);
SpdyHttpHeaders.removeAssociatedToStreamId(httpMessage);
SpdyHttpHeaders.removePriority(httpMessage);
SpdyHttpHeaders.removeUrl(httpMessage);
SpdyHttpHeaders.removeScheme(httpMessage);
@ -330,8 +330,8 @@ public class SpdyHttpEncoder implements ChannelDownstreamHandler {
boolean chunked = httpResponse.isChunked();
// Get the Stream-ID from the headers
int streamID = SpdyHttpHeaders.getStreamID(httpResponse);
SpdyHttpHeaders.removeStreamID(httpResponse);
int streamID = SpdyHttpHeaders.getStreamId(httpResponse);
SpdyHttpHeaders.removeStreamId(httpResponse);
// The Connection, Keep-Alive, Proxy-Connection, and Transfer-ENcoding
// headers are not valid and MUST not be sent.

View File

@ -59,49 +59,97 @@ public final class SpdyHttpHeaders {
private SpdyHttpHeaders() {
}
/**
* @deprecated Use {@link #removeStreamId(HttpMessage)} instead.
*/
@Deprecated
public static void removeStreamID(HttpMessage message) {
removeStreamId(message);
}
/**
* Removes the {@code "X-SPDY-Stream-ID"} header.
*/
public static void removeStreamID(HttpMessage message) {
public static void removeStreamId(HttpMessage message) {
message.removeHeader(Names.STREAM_ID);
}
/**
* @deprecated Use {@link #getStreamId(HttpMessage)} instead.
*/
@Deprecated
public static int getStreamID(HttpMessage message) {
return getStreamId(message);
}
/**
* Returns the value of the {@code "X-SPDY-Stream-ID"} header.
*/
public static int getStreamID(HttpMessage message) {
public static int getStreamId(HttpMessage message) {
return HttpHeaders.getIntHeader(message, Names.STREAM_ID);
}
/**
* @deprecated Use {@link #setStreamId(HttpMessage, int)} instead.
*/
@Deprecated
public static void setStreamID(HttpMessage message, int streamId) {
setStreamId(message, streamId);
}
/**
* Sets the {@code "X-SPDY-Stream-ID"} header.
*/
public static void setStreamID(HttpMessage message, int streamID) {
HttpHeaders.setIntHeader(message, Names.STREAM_ID, streamID);
public static void setStreamId(HttpMessage message, int streamId) {
HttpHeaders.setIntHeader(message, Names.STREAM_ID, streamId);
}
/**
* @deprecated Use {@link #removeAssociatedToStreamId(HttpMessage)} instead.
*/
@Deprecated
public static void removeAssociatedToStreamID(HttpMessage message) {
removeAssociatedToStreamId(message);
}
/**
* Removes the {@code "X-SPDY-Associated-To-Stream-ID"} header.
*/
public static void removeAssociatedToStreamID(HttpMessage message) {
public static void removeAssociatedToStreamId(HttpMessage message) {
message.removeHeader(Names.ASSOCIATED_TO_STREAM_ID);
}
/**
* @deprecated Use {@link #getAssociatedToStreamId(HttpMessage)} instead.
*/
@Deprecated
public static int getAssociatedToStreamID(HttpMessage message) {
return getAssociatedToStreamId(message);
}
/**
* Returns the value of the {@code "X-SPDY-Associated-To-Stream-ID"} header.
*
* @return the header value or {@code 0} if there is no such header or
* if the header value is not a number
*/
public static int getAssociatedToStreamID(HttpMessage message) {
public static int getAssociatedToStreamId(HttpMessage message) {
return HttpHeaders.getIntHeader(message, Names.ASSOCIATED_TO_STREAM_ID, 0);
}
/**
* @deprecated Use {@link #setAssociatedToStreamId(HttpMessage, int)} instead.
*/
@Deprecated
public static void setAssociatedToStreamID(HttpMessage message, int associatedToStreamId) {
setAssociatedToStreamId(message, associatedToStreamId);
}
/**
* Sets the {@code "X-SPDY-Associated-To-Stream-ID"} header.
*/
public static void setAssociatedToStreamID(HttpMessage message, int associatedToStreamID) {
HttpHeaders.setIntHeader(message, Names.ASSOCIATED_TO_STREAM_ID, associatedToStreamID);
public static void setAssociatedToStreamId(HttpMessage message, int associatedToStreamId) {
HttpHeaders.setIntHeader(message, Names.ASSOCIATED_TO_STREAM_ID, associatedToStreamId);
}
/**

View File

@ -20,13 +20,25 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdyPingFrame {
/**
* @deprecated Use {@link #getId()} instead.
*/
@Deprecated
int getID();
/**
* Returns the ID of this frame.
*/
int getID();
int getId();
/**
* @deprecated Use {@link #setId(int)} instead.
*/
@Deprecated
void setID(int id);
/**
* Sets the ID of this frame.
*/
void setID(int ID);
void setId(int id);
}

View File

@ -20,15 +20,27 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdyRstStreamFrame {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* @deprecated Use {@link #setStreamId(int)} instead.
*/
@Deprecated
void setStreamID(int streamId);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamId);
/**
* Returns the status of this frame.

View File

@ -35,26 +35,26 @@ final class SpdySession {
SpdySession() {
}
public int numActiveStreams() {
int numActiveStreams() {
return activeStreams.size();
}
public boolean noActiveStreams() {
boolean noActiveStreams() {
return activeStreams.isEmpty();
}
public boolean isActiveStream(int streamID) {
boolean isActiveStream(int streamID) {
return activeStreams.containsKey(new Integer(streamID));
}
// Stream-IDs should be iterated in priority order
public Set<Integer> getActiveStreams() {
Set<Integer> getActiveStreams() {
TreeSet<Integer> StreamIDs = new TreeSet<Integer>(new PriorityComparator());
StreamIDs.addAll(activeStreams.keySet());
return StreamIDs;
}
public void acceptStream(
void acceptStream(
int streamID, byte priority, boolean remoteSideClosed, boolean localSideClosed,
int sendWindowSize, int receiveWindowSize) {
if (!remoteSideClosed || !localSideClosed) {
@ -64,7 +64,7 @@ final class SpdySession {
}
}
public void removeStream(int streamID) {
void removeStream(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
activeStreams.remove(StreamID);
@ -77,12 +77,12 @@ final class SpdySession {
}
}
public boolean isRemoteSideClosed(int streamID) {
boolean isRemoteSideClosed(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state == null || state.isRemoteSideClosed();
}
public void closeRemoteSide(int streamID) {
void closeRemoteSide(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
if (state != null) {
@ -93,12 +93,12 @@ final class SpdySession {
}
}
public boolean isLocalSideClosed(int streamID) {
boolean isLocalSideClosed(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state == null || state.isLocalSideClosed();
}
public void closeLocalSide(int streamID) {
void closeLocalSide(int streamID) {
Integer StreamID = new Integer(streamID);
StreamState state = activeStreams.get(StreamID);
if (state != null) {
@ -114,29 +114,29 @@ final class SpdySession {
* no need to synchronize access to the StreamState
*/
public boolean hasReceivedReply(int streamID) {
boolean hasReceivedReply(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null && state.hasReceivedReply();
}
public void receivedReply(int streamID) {
void receivedReply(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
if (state != null) {
state.receivedReply();
}
}
public int getSendWindowSize(int streamID) {
int getSendWindowSize(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.getSendWindowSize() : -1;
}
public int updateSendWindowSize(int streamID, int deltaWindowSize) {
int updateSendWindowSize(int streamID, int deltaWindowSize) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.updateSendWindowSize(deltaWindowSize) : -1;
}
public int updateReceiveWindowSize(int streamID, int deltaWindowSize) {
int updateReceiveWindowSize(int streamID, int deltaWindowSize) {
StreamState state = activeStreams.get(new Integer(streamID));
if (deltaWindowSize > 0) {
state.setReceiveWindowSizeLowerBound(0);
@ -144,12 +144,12 @@ final class SpdySession {
return state != null ? state.updateReceiveWindowSize(deltaWindowSize) : -1;
}
public int getReceiveWindowSizeLowerBound(int streamID) {
int getReceiveWindowSizeLowerBound(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.getReceiveWindowSizeLowerBound() : 0;
}
public void updateAllReceiveWindowSizes(int deltaWindowSize) {
void updateAllReceiveWindowSizes(int deltaWindowSize) {
for (StreamState state: activeStreams.values()) {
state.updateReceiveWindowSize(deltaWindowSize);
if (deltaWindowSize < 0) {
@ -158,17 +158,17 @@ final class SpdySession {
}
}
public boolean putPendingWrite(int streamID, MessageEvent evt) {
boolean putPendingWrite(int streamID, MessageEvent evt) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null && state.putPendingWrite(evt);
}
public MessageEvent getPendingWrite(int streamID) {
MessageEvent getPendingWrite(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.getPendingWrite() : null;
}
public MessageEvent removePendingWrite(int streamID) {
MessageEvent removePendingWrite(int streamID) {
StreamState state = activeStreams.get(new Integer(streamID));
return state != null ? state.removePendingWrite() : null;
}
@ -185,7 +185,7 @@ final class SpdySession {
private final ConcurrentLinkedQueue<MessageEvent> pendingWriteQueue =
new ConcurrentLinkedQueue<MessageEvent>();
public StreamState(
StreamState(
byte priority, boolean remoteSideClosed, boolean localSideClosed,
int sendWindowSize, int receiveWindowSize) {
this.priority = priority;
@ -195,70 +195,70 @@ final class SpdySession {
this.receiveWindowSize = new AtomicInteger(receiveWindowSize);
}
public byte getPriority() {
byte getPriority() {
return priority;
}
public boolean isRemoteSideClosed() {
boolean isRemoteSideClosed() {
return remoteSideClosed;
}
public void closeRemoteSide() {
void closeRemoteSide() {
remoteSideClosed = true;
}
public boolean isLocalSideClosed() {
boolean isLocalSideClosed() {
return localSideClosed;
}
public void closeLocalSide() {
void closeLocalSide() {
localSideClosed = true;
}
public boolean hasReceivedReply() {
boolean hasReceivedReply() {
return receivedReply;
}
public void receivedReply() {
void receivedReply() {
receivedReply = true;
}
public int getSendWindowSize() {
int getSendWindowSize() {
return sendWindowSize.get();
}
public int updateSendWindowSize(int deltaWindowSize) {
int updateSendWindowSize(int deltaWindowSize) {
return sendWindowSize.addAndGet(deltaWindowSize);
}
public int updateReceiveWindowSize(int deltaWindowSize) {
int updateReceiveWindowSize(int deltaWindowSize) {
return receiveWindowSize.addAndGet(deltaWindowSize);
}
public int getReceiveWindowSizeLowerBound() {
int getReceiveWindowSizeLowerBound() {
return receiveWindowSizeLowerBound;
}
public void setReceiveWindowSizeLowerBound(int receiveWindowSizeLowerBound) {
void setReceiveWindowSizeLowerBound(int receiveWindowSizeLowerBound) {
this.receiveWindowSizeLowerBound = receiveWindowSizeLowerBound;
}
public boolean putPendingWrite(MessageEvent evt) {
boolean putPendingWrite(MessageEvent evt) {
return pendingWriteQueue.offer(evt);
}
public MessageEvent getPendingWrite() {
MessageEvent getPendingWrite() {
return pendingWriteQueue.peek();
}
public MessageEvent removePendingWrite() {
MessageEvent removePendingWrite() {
return pendingWriteQueue.poll();
}
}
private final class PriorityComparator implements Comparator<Integer> {
public PriorityComparator() {
PriorityComparator() {
super();
}

View File

@ -127,7 +127,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
*/
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
int streamID = spdyDataFrame.getStreamID();
int streamID = spdyDataFrame.getStreamId();
// Check if we received a data frame for a Stream-ID which is not open
if (!spdySession.isActiveStream(streamID)) {
@ -215,7 +215,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
*/
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
// Check if we received a valid SYN_STREAM frame
if (spdySynStreamFrame.isInvalid() ||
@ -250,7 +250,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
*/
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
int streamID = spdySynReplyFrame.getStreamID();
int streamID = spdySynReplyFrame.getStreamId();
// Check if we received a valid SYN_REPLY frame
if (spdySynReplyFrame.isInvalid() ||
@ -285,7 +285,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
*/
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
removeStream(spdyRstStreamFrame.getStreamID());
removeStream(spdyRstStreamFrame.getStreamId());
} else if (msg instanceof SpdySettingsFrame) {
@ -326,7 +326,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
if (isRemoteInitiatedID(spdyPingFrame.getID())) {
if (isRemoteInitiatedID(spdyPingFrame.getId())) {
Channels.write(ctx, Channels.future(e.getChannel()), spdyPingFrame, e.getRemoteAddress());
return;
}
@ -344,7 +344,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdyHeadersFrame) {
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
int streamID = spdyHeadersFrame.getStreamID();
int streamID = spdyHeadersFrame.getStreamId();
// Check if we received a valid HEADERS frame
if (spdyHeadersFrame.isInvalid()) {
@ -376,7 +376,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
if (flowControl) {
SpdyWindowUpdateFrame spdyWindowUpdateFrame = (SpdyWindowUpdateFrame) msg;
int streamID = spdyWindowUpdateFrame.getStreamID();
int streamID = spdyWindowUpdateFrame.getStreamId();
int deltaWindowSize = spdyWindowUpdateFrame.getDeltaWindowSize();
// Ignore frames for half-closed streams
@ -442,7 +442,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
if (msg instanceof SpdyDataFrame) {
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
final int streamID = spdyDataFrame.getStreamID();
final int streamID = spdyDataFrame.getStreamId();
// Frames must not be sent on half-closed streams
if (spdySession.isLocalSideClosed(streamID)) {
@ -530,7 +530,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdySynStreamFrame) {
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
if (isRemoteInitiatedID(streamID)) {
e.getFuture().setFailure(PROTOCOL_EXCEPTION);
@ -548,7 +548,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdySynReplyFrame) {
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
int streamID = spdySynReplyFrame.getStreamID();
int streamID = spdySynReplyFrame.getStreamId();
// Frames must not be sent on half-closed streams
if (!isRemoteInitiatedID(streamID) || spdySession.isLocalSideClosed(streamID)) {
@ -564,7 +564,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdyRstStreamFrame) {
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
removeStream(spdyRstStreamFrame.getStreamID());
removeStream(spdyRstStreamFrame.getStreamId());
} else if (msg instanceof SpdySettingsFrame) {
@ -595,9 +595,9 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdyPingFrame) {
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
if (isRemoteInitiatedID(spdyPingFrame.getID())) {
if (isRemoteInitiatedID(spdyPingFrame.getId())) {
e.getFuture().setFailure(new IllegalArgumentException(
"invalid PING ID: " + spdyPingFrame.getID()));
"invalid PING ID: " + spdyPingFrame.getId()));
return;
}
pings.getAndIncrement();
@ -612,7 +612,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
} else if (msg instanceof SpdyHeadersFrame) {
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
int streamID = spdyHeadersFrame.getStreamID();
int streamID = spdyHeadersFrame.getStreamId();
// Frames must not be sent on half-closed streams
if (spdySession.isLocalSideClosed(streamID)) {
@ -680,7 +680,7 @@ public class SpdySessionHandler extends SimpleChannelUpstreamHandler
*/
private boolean isRemoteInitiatedID(int ID) {
boolean serverID = SpdyCodecUtil.isServerID(ID);
boolean serverID = SpdyCodecUtil.isServerId(ID);
return server && !serverID || !server && serverID;
}

View File

@ -31,11 +31,17 @@ public interface SpdySettingsFrame {
int SETTINGS_INITIAL_WINDOW_SIZE = 7;
int SETTINGS_CLIENT_CERTIFICATE_VECTOR_SIZE = 8;
/**
* @deprecated Use {@link #getIds()} instead.
*/
@Deprecated
Set<Integer> getIDs();
/**
* Returns a {@code Set} of the setting IDs.
* The set's iterator will return the IDs in ascending order.
*/
Set<Integer> getIDs();
Set<Integer> getIds();
/**
* Returns {@code true} if the setting ID has a value.
@ -68,12 +74,18 @@ public interface SpdySettingsFrame {
*/
void removeValue(int ID);
/**
* @deprecated Use {@link #isPersistValue(int)} instead.
*/
@Deprecated
boolean persistValue(int ID);
/**
* Returns {@code true} if this setting should be persisted.
* Returns {@code false} if this setting should not be persisted
* or if the setting ID has no value.
*/
boolean persistValue(int ID);
boolean isPersistValue(int ID);
/**
* Sets if this setting should be persisted.

View File

@ -20,15 +20,27 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdySynReplyFrame extends SpdyHeaderBlock {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* @deprecated Use {@link #setStreamId(int)} instead.
*/
@Deprecated
void setStreamID(int streamID);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamID);
/**
* Returns {@code true} if this frame is the last frame to be transmitted

View File

@ -20,26 +20,50 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdySynStreamFrame extends SpdyHeaderBlock {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* @deprecated Use {@link #setStreamId(int)} instead.
*/
@Deprecated
void setStreamID(int streamID);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamId);
/**
* @deprecated Use {@link #getAssociatedToStreamId()} instead.
*/
@Deprecated
int getAssociatedToStreamID();
/**
* Returns the Associated-To-Stream-ID of this frame.
*/
int getAssociatedToStreamID();
int getAssociatedToStreamId();
/**
* @deprecated Use {@link #setAssociatedToStreamId(int)} instead.
*/
@Deprecated
void setAssociatedToStreamID(int associatedToStreamId);
/**
* Sets the Associated-To-Stream-ID of this frame.
* The Associated-To-Stream-ID cannot be negative.
*/
void setAssociatedToStreamID(int associatedToStreamID);
void setAssociatedToStreamId(int associatedToStreamId);
/**
* Returns the priority of the stream.

View File

@ -20,15 +20,26 @@ package org.jboss.netty.handler.codec.spdy;
*/
public interface SpdyWindowUpdateFrame {
/**
* @deprecated Use {@link #getStreamId()} instead.
*/
@Deprecated
int getStreamID();
/**
* Returns the Stream-ID of this frame.
*/
int getStreamID();
int getStreamId();
/**
* Use {@link #setStreamId(int)} instead.
*/
void setStreamID(int streamId);
/**
* Sets the Stream-ID of this frame. The Stream-ID must be positive.
*/
void setStreamID(int streamID);
void setStreamId(int streamId);
/**
* Returns the Delta-Window-Size of this frame.

View File

@ -20,10 +20,15 @@ import java.util.concurrent.Executor;
import org.jboss.netty.channel.ChannelEvent;
import org.jboss.netty.channel.ChannelHandlerContext;
import org.jboss.netty.util.EstimatableObjectWrapper;
import org.jboss.netty.util.internal.DeadLockProofWorker;
public abstract class ChannelEventRunnable implements Runnable, EstimatableObjectWrapper {
/**
* An <em>internal use only</em> thread-local variable that tells the
* {@link Executor} that this worker acquired a worker thread from.
*/
protected static final ThreadLocal<Executor> PARENT = new ThreadLocal<Executor>();
protected final ChannelHandlerContext ctx;
protected final ChannelEvent e;
int estimatedSize;
@ -60,10 +65,10 @@ public abstract class ChannelEventRunnable implements Runnable, EstimatableObjec
public final void run() {
try {
DeadLockProofWorker.PARENT.set(executor);
PARENT.set(executor);
doRun();
} finally {
DeadLockProofWorker.PARENT.remove();
PARENT.remove();
}
}

View File

@ -160,7 +160,7 @@ public class ExecutionHandler implements ChannelUpstreamHandler, ChannelDownstre
*/
public void releaseExternalResources() {
Executor executor = getExecutor();
ExecutorUtil.terminate(executor);
ExecutorUtil.terminate(ChannelEventRunnable.PARENT, executor);
if (executor instanceof ExternalResourceReleasable) {
((ExternalResourceReleasable) executor).releaseExternalResources();
}

View File

@ -36,7 +36,7 @@ public class ChunkedFile implements ChunkedInput {
private final long startOffset;
private final long endOffset;
private final int chunkSize;
private volatile long offset;
private long offset;
/**
* Creates a new instance that fetches data from the specified file.

View File

@ -39,7 +39,7 @@ public class ChunkedNioFile implements ChunkedInput {
private long startOffset;
private final long endOffset;
private final int chunkSize;
private volatile long offset;
private long offset;
/**
* Creates a new instance that fetches data from the specified file.

View File

@ -32,7 +32,7 @@ public class ChunkedNioStream implements ChunkedInput {
private final ReadableByteChannel in;
private final int chunkSize;
private volatile long offset;
private long offset;
/**
* Associated ByteBuffer

View File

@ -36,7 +36,7 @@ public class ChunkedStream implements ChunkedInput {
private final PushbackInputStream in;
private final int chunkSize;
private volatile long offset;
private long offset;
/**
* Creates a new instance that fetches data from the specified stream.

View File

@ -46,6 +46,12 @@ public final class ExecutorUtil {
* Shuts down the specified executors.
*/
public static void terminate(Executor... executors) {
terminate(DeadLockProofWorker.PARENT, executors);
}
/**
* Shuts down the specified executors using the given {@link ThreadLocal} to check if there is a deadlock
*/
public static void terminate(ThreadLocal<Executor> deadLockChecker, Executor... executors) {
// Check nulls.
if (executors == null) {
throw new NullPointerException("executors");
@ -60,7 +66,7 @@ public final class ExecutorUtil {
}
// Check dead lock.
final Executor currentParent = DeadLockProofWorker.PARENT.get();
final Executor currentParent = deadLockChecker.get();
if (currentParent != null) {
for (Executor e: executorsCopy) {
if (e == currentParent) {

View File

@ -54,7 +54,7 @@ public class SpdySessionHandlerTest {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdyDataFrame);
SpdyDataFrame spdyDataFrame = (SpdyDataFrame) msg;
Assert.assertTrue(spdyDataFrame.getStreamID() == streamID);
Assert.assertTrue(spdyDataFrame.getStreamId() == streamID);
Assert.assertTrue(spdyDataFrame.isLast() == last);
}
@ -62,7 +62,7 @@ public class SpdySessionHandlerTest {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdySynReplyFrame);
SpdySynReplyFrame spdySynReplyFrame = (SpdySynReplyFrame) msg;
Assert.assertTrue(spdySynReplyFrame.getStreamID() == streamID);
Assert.assertTrue(spdySynReplyFrame.getStreamId() == streamID);
Assert.assertTrue(spdySynReplyFrame.isLast() == last);
assertHeaderBlock(spdySynReplyFrame, headers);
}
@ -71,7 +71,7 @@ public class SpdySessionHandlerTest {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdyRstStreamFrame);
SpdyRstStreamFrame spdyRstStreamFrame = (SpdyRstStreamFrame) msg;
Assert.assertTrue(spdyRstStreamFrame.getStreamID() == streamID);
Assert.assertTrue(spdyRstStreamFrame.getStreamId() == streamID);
Assert.assertTrue(spdyRstStreamFrame.getStatus().equals(status));
}
@ -79,21 +79,21 @@ public class SpdySessionHandlerTest {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdyPingFrame);
SpdyPingFrame spdyPingFrame = (SpdyPingFrame) msg;
Assert.assertTrue(spdyPingFrame.getID() == ID);
Assert.assertTrue(spdyPingFrame.getId() == ID);
}
private static void assertGoAway(Object msg, int lastGoodStreamID) {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdyGoAwayFrame);
SpdyGoAwayFrame spdyGoAwayFrame = (SpdyGoAwayFrame) msg;
Assert.assertTrue(spdyGoAwayFrame.getLastGoodStreamID() == lastGoodStreamID);
Assert.assertTrue(spdyGoAwayFrame.getLastGoodStreamId() == lastGoodStreamID);
}
private static void assertHeaders(Object msg, int streamID, SpdyHeaderBlock headers) {
Assert.assertNotNull(msg);
Assert.assertTrue(msg instanceof SpdyHeadersFrame);
SpdyHeadersFrame spdyHeadersFrame = (SpdyHeadersFrame) msg;
Assert.assertTrue(spdyHeadersFrame.getStreamID() == streamID);
Assert.assertTrue(spdyHeadersFrame.getStreamId() == streamID);
assertHeaderBlock(spdyHeadersFrame, headers);
}
@ -153,7 +153,7 @@ public class SpdySessionHandlerTest {
// Check if session handler closed the streams using the number
// of concurrent streams and that it returns REFUSED_STREAM
// if it receives a SYN_STREAM frame it does not wish to accept
spdySynStreamFrame.setStreamID(localStreamID);
spdySynStreamFrame.setStreamId(localStreamID);
spdySynStreamFrame.setLast(true);
spdySynStreamFrame.setUnidirectional(true);
sessionHandler.offer(spdySynStreamFrame);
@ -181,11 +181,11 @@ public class SpdySessionHandlerTest {
// Check if session handler returns PROTOCOL_ERROR if it receives
// a SYN_STREAM frame with an invalid Stream-ID
spdySynStreamFrame.setStreamID(localStreamID - 1);
spdySynStreamFrame.setStreamId(localStreamID - 1);
sessionHandler.offer(spdySynStreamFrame);
assertRstStream(sessionHandler.poll(), localStreamID - 1, SpdyStreamStatus.PROTOCOL_ERROR);
Assert.assertNull(sessionHandler.peek());
spdySynStreamFrame.setStreamID(localStreamID);
spdySynStreamFrame.setStreamId(localStreamID);
// Check if session handler correctly limits the number of
// concurrent streams in the SETTINGS frame
@ -204,18 +204,18 @@ public class SpdySessionHandlerTest {
Assert.assertNull(sessionHandler.peek());
// Check if session handler rejects HEADERS for closed streams
int testStreamID = spdyDataFrame.getStreamID();
int testStreamID = spdyDataFrame.getStreamId();
sessionHandler.offer(spdyDataFrame);
assertDataFrame(sessionHandler.poll(), testStreamID, spdyDataFrame.isLast());
Assert.assertNull(sessionHandler.peek());
spdyHeadersFrame.setStreamID(testStreamID);
spdyHeadersFrame.setStreamId(testStreamID);
sessionHandler.offer(spdyHeadersFrame);
assertRstStream(sessionHandler.poll(), testStreamID, SpdyStreamStatus.INVALID_STREAM);
Assert.assertNull(sessionHandler.peek());
// Check if session handler returns PROTOCOL_ERROR if it receives
// an invalid HEADERS frame
spdyHeadersFrame.setStreamID(localStreamID);
spdyHeadersFrame.setStreamId(localStreamID);
spdyHeadersFrame.setInvalid();
sessionHandler.offer(spdyHeadersFrame);
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.PROTOCOL_ERROR);
@ -223,7 +223,7 @@ public class SpdySessionHandlerTest {
// Check if session handler returns identical local PINGs
sessionHandler.offer(localPingFrame);
assertPing(sessionHandler.poll(), localPingFrame.getID());
assertPing(sessionHandler.poll(), localPingFrame.getId());
Assert.assertNull(sessionHandler.peek());
// Check if session handler ignores un-initiated remote PINGs
@ -238,14 +238,14 @@ public class SpdySessionHandlerTest {
// Check if session handler returns REFUSED_STREAM if it receives
// SYN_STREAM frames after sending a GOAWAY frame
spdySynStreamFrame.setStreamID(localStreamID);
spdySynStreamFrame.setStreamId(localStreamID);
sessionHandler.offer(spdySynStreamFrame);
assertRstStream(sessionHandler.poll(), localStreamID, SpdyStreamStatus.REFUSED_STREAM);
Assert.assertNull(sessionHandler.peek());
// Check if session handler ignores Data frames after sending
// a GOAWAY frame
spdyDataFrame.setStreamID(localStreamID);
spdyDataFrame.setStreamId(localStreamID);
sessionHandler.offer(spdyDataFrame);
Assert.assertNull(sessionHandler.peek());
@ -288,11 +288,11 @@ public class SpdySessionHandlerTest {
new DefaultSpdySynStreamFrame(streamID, 0, (byte) 0);
spdySynStreamFrame.setLast(true);
Channels.write(e.getChannel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
spdySynStreamFrame.setStreamID(spdySynStreamFrame.getStreamID() + 2);
spdySynStreamFrame.setStreamId(spdySynStreamFrame.getStreamId() + 2);
Channels.write(e.getChannel(), spdySynStreamFrame);
// Limit the number of concurrent streams to 3
@ -317,7 +317,7 @@ public class SpdySessionHandlerTest {
SpdySynStreamFrame spdySynStreamFrame = (SpdySynStreamFrame) msg;
int streamID = spdySynStreamFrame.getStreamID();
int streamID = spdySynStreamFrame.getStreamId();
SpdySynReplyFrame spdySynReplyFrame = new DefaultSpdySynReplyFrame(streamID);
spdySynReplyFrame.setLast(spdySynStreamFrame.isLast());
for (Map.Entry<String, String> entry: spdySynStreamFrame.getHeaders()) {