Deprecated receive size predictor

This commit is contained in:
Trustin Lee 2008-12-08 09:17:10 +00:00
parent 1fa791c4a4
commit 95d3b145e2
4 changed files with 18 additions and 9 deletions

View File

@ -44,10 +44,11 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(DefaultNioSocketChannelConfig.class);
private static final ReceiveBufferSizePredictor UNUSED_PREDICTOR =
new DefaultReceiveBufferSizePredictor();
private volatile int writeBufferHighWaterMark = 64 * 1024;
private volatile int writeBufferLowWaterMark = 32 * 1024;
private volatile ReceiveBufferSizePredictor predictor =
new DefaultReceiveBufferSizePredictor();
private volatile int writeSpinCount = 16;
DefaultNioSocketChannelConfig(Socket socket) {
@ -115,15 +116,15 @@ class DefaultNioSocketChannelConfig extends DefaultSocketChannelConfig
}
public ReceiveBufferSizePredictor getReceiveBufferSizePredictor() {
return predictor;
logger.warn(
"Detected an access to a deprecated configuration parameter: " +
"receiveBufferSizePredictor");
return UNUSED_PREDICTOR;
}
public void setReceiveBufferSizePredictor(
ReceiveBufferSizePredictor predictor) {
if (predictor == null) {
throw new NullPointerException("predictor");
}
this.predictor = predictor;
getReceiveBufferSizePredictor();
}
public boolean isReadWriteFair() {

View File

@ -86,20 +86,24 @@ public interface NioSocketChannelConfig extends SocketChannelConfig {
*/
void setWriteSpinCount(int writeSpinCount);
// TODO Deprecate receiveBufferSizePredictor
/**
* @deprecated Works fine without prediction since 3.1.
*
* Returns the {@link ReceiveBufferSizePredictor} which predicts the
* number of readable bytes in the socket receive buffer. The default
* predictor is {@link DefaultReceiveBufferSizePredictor}.
* .
*/
@Deprecated
ReceiveBufferSizePredictor getReceiveBufferSizePredictor();
/**
* @deprecated Works fine without prediction since 3.1.
*
* Sets the {@link ReceiveBufferSizePredictor} which predicts the
* number of readable bytes in the socket receive buffer. The default
* predictor is {@link DefaultReceiveBufferSizePredictor}.
*/
@Deprecated
void setReceiveBufferSizePredictor(ReceiveBufferSizePredictor predictor);
/**

View File

@ -26,6 +26,7 @@ import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.buffer.DirectChannelBufferFactory;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.ChannelFuture;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
@ -73,6 +74,7 @@ public class DiscardClient {
bootstrap.getPipeline().addLast("handler", handler);
bootstrap.setOption("tcpNoDelay", true);
bootstrap.setOption("keepAlive", true);
bootstrap.setOption("bufferFactory", DirectChannelBufferFactory.getInstance());
// Start the connection attempt.
ChannelFuture future = bootstrap.connect(new InetSocketAddress(host, port));

View File

@ -26,6 +26,7 @@ import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.buffer.DirectChannelBufferFactory;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
@ -52,6 +53,7 @@ public class DiscardServer {
bootstrap.getPipeline().addLast("handler", handler);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
bootstrap.setOption("child.bufferFactory", DirectChannelBufferFactory.getInstance());
// Bind and start to accept incoming connections.
bootstrap.bind(new InetSocketAddress(8080));